Skip to content

Commit 6b4ff78

Browse files
ingemaralexrudall
authored andcommitted
fixup! Refactor stream handling to expose event labels
1 parent d8a1951 commit 6b4ff78

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/openai/stream.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(user_proc:, parser: EventStreamParser::Parser.new)
1818
end
1919

2020
def call(chunk, _bytes, env)
21-
handle_http_error(chunk: chunk, env: env) if env&.status != 200
21+
handle_http_error(chunk: chunk, env: env) if env && env.status != 200
2222

2323
parser.feed(chunk) do |event, data|
2424
next if data == DONE

spec/openai/client/stream_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let(:user_proc) { proc { |data, event| [data, event] } }
33
let(:stream) { OpenAI::Stream.new(user_proc: user_proc) }
44
let(:bytes) { 0 }
5-
let(:env) { Faraday::Env.new(status: 200) }
5+
let(:env) { Faraday::Env.new.tap { |env| env.status = 200 } }
66

77
describe "#call" do
88
context "with a proc" do

0 commit comments

Comments
 (0)