ask-llm-providers 0.1.11 → 0.1.13
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 +4 -4
- data/lib/ask/llm/version.rb +1 -1
- data/lib/ask/provider/openai.rb +8 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8a74bb6d0bdeec2f86e1ec7e352c121e2c69c44837293e545d78a6a189552c0
|
|
4
|
+
data.tar.gz: 654529c6b21c4ba943f8d0bcf8eb7361a209ab470b918b4bc77f3afc4ba37321
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9b3fa669828ecadda4d43b6295019b9a47af5aef9cfeb2f1289fc8025a7275e41d83ab6f1a8154964872b7ff3055f54601b73df10e84cc4f7c2318912a191f9
|
|
7
|
+
data.tar.gz: 633f84f8cfcbfa71d266bbb8ca6c813157e0a312f7cebd69879cf2d5ee53b81cc63d4733ad967290742bf03b781c142197f9c5b23446f5ea72929689b6e262ac
|
data/lib/ask/llm/version.rb
CHANGED
data/lib/ask/provider/openai.rb
CHANGED
|
@@ -113,7 +113,8 @@ module Ask
|
|
|
113
113
|
fm[:tool_calls] = calls.map { |t|
|
|
114
114
|
id = t.respond_to?(:id) ? t.id : (t[:id] || t["id"])
|
|
115
115
|
name = t.respond_to?(:name) ? t.name : (t.dig(:function, :name) || t.dig("function", "name") || t[:name])
|
|
116
|
-
|
|
116
|
+
raw_args = t.respond_to?(:arguments) ? t.arguments : (t.dig(:function, :arguments) || t.dig("function", "arguments") || t[:arguments])
|
|
117
|
+
args = raw_args.is_a?(String) ? raw_args : JSON.generate(raw_args)
|
|
117
118
|
{ id: id, type: "function", function: { name: name, arguments: args } }
|
|
118
119
|
}
|
|
119
120
|
end
|
|
@@ -152,11 +153,13 @@ module Ask
|
|
|
152
153
|
req.options.on_data = proc { |data, _bytes, _env| process_chunk(data, stream, model, &block) }
|
|
153
154
|
end.tap { |resp|
|
|
154
155
|
unless resp.success?
|
|
155
|
-
err_body =
|
|
156
|
-
|
|
157
|
-
rescue
|
|
158
|
-
|
|
156
|
+
err_body = case resp.body
|
|
157
|
+
when Hash then resp.body
|
|
158
|
+
when String then (JSON.parse(resp.body) rescue { "error" => { "message" => "HTTP #{resp.status}: #{resp.body[0..200]}" } })
|
|
159
|
+
else { "error" => { "message" => "HTTP #{resp.status}: empty response body" } }
|
|
159
160
|
end
|
|
161
|
+
err_body["error"] ||= {}
|
|
162
|
+
err_body["error"]["_status"] = resp.status
|
|
160
163
|
raise LLM::HTTP.map_error(resp.status, err_body, provider: "OpenAI")
|
|
161
164
|
end
|
|
162
165
|
}
|