mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-31 06:56:59 +00:00
fix(openai.py): fix exception raised
This commit is contained in:
parent
e2d75a100a
commit
20be76123b
1 changed files with 13 additions and 5 deletions
|
|
@ -1160,11 +1160,18 @@ class OpenAIChatCompletion(BaseLLM):
|
|||
"complete_input_dict": data,
|
||||
},
|
||||
)
|
||||
headers, response = self.make_sync_openai_chat_completion_request(
|
||||
openai_client=openai_client,
|
||||
data=data,
|
||||
timeout=timeout,
|
||||
)
|
||||
try:
|
||||
headers, response = self.make_sync_openai_chat_completion_request(
|
||||
openai_client=openai_client,
|
||||
data=data,
|
||||
timeout=timeout,
|
||||
)
|
||||
except Exception as e:
|
||||
status_code = getattr(e, "status_code", 500)
|
||||
error_headers = getattr(e, "headers", None)
|
||||
raise OpenAIError(
|
||||
status_code=status_code, message=str(e), headers=error_headers
|
||||
)
|
||||
|
||||
logging_obj.model_call_details["response_headers"] = headers
|
||||
streamwrapper = CustomStreamWrapper(
|
||||
|
|
@ -1263,6 +1270,7 @@ class OpenAIChatCompletion(BaseLLM):
|
|||
|
||||
error_headers = getattr(e, "headers", None)
|
||||
if response is not None and hasattr(response, "text"):
|
||||
error_headers = getattr(e, "headers", None)
|
||||
raise OpenAIError(
|
||||
status_code=500,
|
||||
message=f"{str(e)}\n\nOriginal Response: {response.text}",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue