Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:fix response format bug #282

Merged
merged 9 commits into from
Mar 8, 2023
Merged
5 changes: 4 additions & 1 deletion openai/api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,10 @@ def _interpret_response_line(
headers=rheaders,
)
try:
data = json.loads(rbody)
if 'text/plain' in rheaders.get('Content-Type'):
data = rbody
else:
data = json.loads(rbody)
except (JSONDecodeError, UnicodeDecodeError) as e:
raise error.APIError(
f"HTTP code {rcode} from API ({rbody})", rbody, rcode, headers=rheaders
Expand Down