diff --git a/lib/openai/http.rb b/lib/openai/http.rb index 2f60eb0b..0f773052 100644 --- a/lib/openai/http.rb +++ b/lib/openai/http.rb @@ -7,9 +7,15 @@ module HTTP include HTTPHeaders def get(path:, parameters: nil) - parse_jsonl(conn.get(uri(path: path), parameters) do |req| + response = conn.get(uri(path: path), parameters) do |req| req.headers = headers - end&.body) + end + + begin + parse_jsonl(response.body) + rescue JSON::ParserError + response.body + end end def post(path:)