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 8e1d6a2 commit 2be9bf8Copy full SHA for 2be9bf8
lib/openai/http.rb
@@ -7,10 +7,9 @@ module HTTP
7
include HTTPHeaders
8
9
def get(path:, parameters: nil)
10
- response = conn.get(uri(path: path), parameters) { |req| req.headers = headers }
11
- parse_jsonl(response.body)
12
- rescue JSON::ParserError
13
- response.body
+ parse_jsonl(conn.get(uri(path: path), parameters) do |req|
+ req.headers = headers
+ end&.body)
14
end
15
16
def post(path:)
@@ -49,6 +48,8 @@ def parse_jsonl(response)
49
48
response = response.gsub("}\n{", "},{").prepend("[").concat("]")
50
51
JSON.parse(response)
+ rescue JSON::ParserError
52
+ response
53
54
55
# Given a proc, returns an outer proc that can be used to iterate over a JSON stream of chunks.
0 commit comments