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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 119b2978f4176a40950e2874176272851530c0b00a1a5dc9387f76ffd8caba62
|
|
4
|
+
data.tar.gz: ca60f782bcd182e9af024d34479e78f21c85b8e8605ade8f825d00cdc448c4ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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] ||
|
|
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] ||
|
|
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
|
|
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
|