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 e66a540 commit 16849cfCopy full SHA for 16849cf
lib/openai/http.rb
@@ -49,12 +49,9 @@ def to_json_stream(user_proc:)
49
50
proc do |chunk, _bytes, env|
51
if env && env.status != 200
52
- raise_error = Faraday::Response::RaiseError.new
53
- raise_error.on_complete(env.merge(body: JSON.parse(chunk)))
54
- end
55
-
56
- parser.feed(chunk) do |_type, data|
57
- user_proc.call(JSON.parse(data)) unless data == "[DONE]"
+ parser.feed(chunk) do |_type, data|
+ emit_json(json: data, user_proc: user_proc) unless data == "[DONE]"
+ end
58
end
59
60
0 commit comments