Skip to content

Commit 1ded4b7

Browse files
authored
Merge pull request alexrudall#262 from obie/main
stream option should take any callable not just a proc
2 parents 468d2c8 + 667ebf4 commit 1ded4b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/openai/http.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ def get(path:)
88

99
def json_post(path:, parameters:)
1010
to_json(conn.post(uri(path: path)) do |req|
11-
if parameters[:stream].is_a?(Proc)
11+
if parameters[:stream].respond_to?(:call)
1212
req.options.on_data = to_json_stream(user_proc: parameters[:stream])
1313
parameters[:stream] = true # Necessary to tell OpenAI to stream.
14+
elsif parameters[:stream]
15+
raise ArgumentError, "stream must be callable"
1416
end
1517

1618
req.headers = headers

0 commit comments

Comments
 (0)