completion-kit 0.5.13 → 0.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ec878fca14222f69bc34d85967b065b298ea669be11f60c49b52af13aefdfe5
4
- data.tar.gz: 8211fc882175c1e69c52f2cba5a5e14668af4ddfc5784362252e8c051a59bee1
3
+ metadata.gz: 119b2978f4176a40950e2874176272851530c0b00a1a5dc9387f76ffd8caba62
4
+ data.tar.gz: ca60f782bcd182e9af024d34479e78f21c85b8e8605ade8f825d00cdc448c4ea
5
5
  SHA512:
6
- metadata.gz: 2afc081fde8f6722aadee50f973bc1512be15e5cbd19913881f0f38f06df37fee4f1cdbda54cfcb230892e73df7b27f6fdf537ea71df7da49ddfba39d2c9f644
7
- data.tar.gz: 02cfae669de0b9a1f7a10bbedd7eecda8d708802ff85c1d8c6a50368fb49385e43f19b388f2ea45313b90e14a3d53464688b897ad23378964cfb55103bd3a8c2
6
+ metadata.gz: 1ce0a05b7b22f363f0386fffa2b94c60b94e767ac0a732b1309d70dbda9d951407f5abc42d02e3992f56a20bc902f9bcba938dedd405cfd02cb8577a0b8d4fe5
7
+ data.tar.gz: 0ed8728ca2853047cd6c659d696cdfbbeac681f726d3d368e183187ac179f434933a6f0d3b819e4bb5318f5d643aebbd4991a92014e7117993cee9200a6cca37
@@ -15,7 +15,7 @@ module CompletionKit
15
15
  return "Error: API key not configured" unless configured?
16
16
 
17
17
  model = options[:model] || "gpt-4.1-mini"
18
- max_tokens = options[:max_tokens] || 1000
18
+ max_tokens = options[:max_tokens] || 8192
19
19
  temperature = options[:temperature] || 0.7
20
20
 
21
21
  response = post_responses(model: model, prompt: prompt, max_tokens: max_tokens, temperature: temperature)
@@ -36,8 +36,14 @@ module CompletionKit
36
36
 
37
37
  if response.success?
38
38
  data = JSON.parse(response.body)
39
+ if data["status"] == "incomplete"
40
+ reason = data.dig("incomplete_details", "reason") || "unknown"
41
+ return "Error: response incomplete (#{reason}) — increase max_tokens=#{max_tokens} or pick a non-reasoning judge model"
42
+ end
39
43
  message = Array(data["output"]).find { |o| o["type"] == "message" }
40
- message&.dig("content", 0, "text").to_s.strip
44
+ content = message&.dig("content", 0, "text").to_s.strip
45
+ return "Error: model returned empty content" if content.empty?
46
+ content
41
47
  else
42
48
  "Error: #{response.status} - #{response.body}"
43
49
  end
@@ -13,7 +13,7 @@ module CompletionKit
13
13
  return "Error: API key not configured" unless configured?
14
14
 
15
15
  model = options[:model] || "openai/gpt-4o-mini"
16
- max_tokens = options[:max_tokens] || 1000
16
+ max_tokens = options[:max_tokens] || 8192
17
17
  temperature = options[:temperature] || 0.7
18
18
 
19
19
  response = post_chat(model: model, prompt: prompt, max_tokens: max_tokens, temperature: temperature)
@@ -34,7 +34,13 @@ module CompletionKit
34
34
 
35
35
  if response.success?
36
36
  data = JSON.parse(response.body)
37
- data.dig("choices", 0, "message", "content").to_s.strip
37
+ choice = data.dig("choices", 0) || {}
38
+ if choice["finish_reason"] == "length"
39
+ return "Error: response truncated by max_tokens=#{max_tokens} before visible content was emitted (reasoning model burned through the budget)"
40
+ end
41
+ content = choice.dig("message", "content").to_s.strip
42
+ return "Error: model returned empty content" if content.empty?
43
+ content
38
44
  else
39
45
  "Error: #{response.status} - #{response.body}"
40
46
  end
@@ -1,3 +1,3 @@
1
1
  module CompletionKit
2
- VERSION = "0.5.13"
2
+ VERSION = "0.5.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: completion-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.13
4
+ version: 0.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Bastin