We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1de4f79 commit 1e463b4Copy full SHA for 1e463b4
lib/openai/http.rb
@@ -49,9 +49,12 @@ def to_json_stream(user_proc:)
49
50
proc do |chunk, _bytes, env|
51
if env && env.status != 200
52
- parser.feed(chunk) do |_type, data|
53
- emit_json(json: data, user_proc: user_proc) unless data == "[DONE]"
54
- end
+ raise_error = Faraday::Response::RaiseError.new
+ raise_error.on_complete(env.merge(body: JSON.parse(chunk)))
+ end
55
+
56
+ parser.feed(chunk) do |_type, data|
57
+ user_proc.call(JSON.parse(data)) unless data == "[DONE]"
58
end
59
60
0 commit comments