Skip to content

Commit 1e463b4

Browse files
committed
Revert bad merge
1 parent 1de4f79 commit 1e463b4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/openai/http.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ def to_json_stream(user_proc:)
4949

5050
proc do |chunk, _bytes, env|
5151
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
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]"
5558
end
5659
end
5760
end

0 commit comments

Comments
 (0)