Skip to content

Commit

Permalink
Revert bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudall committed Nov 6, 2023
1 parent 1de4f79 commit 1e463b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/openai/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ def to_json_stream(user_proc:)

proc do |chunk, _bytes, env|
if env && env.status != 200
parser.feed(chunk) do |_type, data|
emit_json(json: data, user_proc: user_proc) unless data == "[DONE]"
end
raise_error = Faraday::Response::RaiseError.new
raise_error.on_complete(env.merge(body: JSON.parse(chunk)))
end

parser.feed(chunk) do |_type, data|
user_proc.call(JSON.parse(data)) unless data == "[DONE]"
end
end
end
Expand Down

0 comments on commit 1e463b4

Please sign in to comment.