Commit 9b5f8dbd

guaguaguaxia <guaguaguaxia@Gmail.com>
2023-03-09 04:33:49
fix:fix response format bug (#282)
* fix:fix bug * fix:fix response_format bug * fix:fix response_format bug * fix:fix response_format bug * fix:fix response_format bug * fix:fix response_format bug * fix:fix response_format bug * fix:fix response_format bug
1 parent fad5a24
Changed files (1)
openai/api_requestor.py
@@ -666,7 +666,10 @@ class APIRequestor:
                 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