Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ea5dde

Browse files
authored
Fix recording of reponse headers in exceptions. (openai#44)
These were passed as positional arguments, but in the wrong position, which meant they were passed into the `json_body` parameter of the `OpenAIError` constructor.
1 parent 25b681a commit 7ea5dde

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

openai/api_requestor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ def _interpret_response_line(
300300
) -> OpenAIResponse:
301301
if rcode == 503:
302302
raise error.ServiceUnavailableError(
303-
"The server is overloaded or not ready yet.", rbody, rcode, rheaders
303+
"The server is overloaded or not ready yet.", rbody, rcode, headers=rheaders
304304
)
305305
try:
306306
if hasattr(rbody, "decode"):
307307
rbody = rbody.decode("utf-8")
308308
data = json.loads(rbody)
309309
except (JSONDecodeError, UnicodeDecodeError):
310310
raise error.APIError(
311-
f"HTTP code {rcode} from API ({rbody})", rbody, rcode, rheaders
311+
f"HTTP code {rcode} from API ({rbody})", rbody, rcode, headers=rheaders
312312
)
313313
resp = OpenAIResponse(data, rheaders)
314314
# In the future, we might add a "status" parameter to errors

0 commit comments

Comments
 (0)