fix(azure.py): correctly raise async exceptions

This commit is contained in:
Krrish Dholakia 2023-12-21 12:23:07 +05:30
parent 87fca1808a
commit 812f9ca1b3
2 changed files with 5 additions and 1 deletions

View file

@ -262,7 +262,10 @@ class AzureChatCompletion(BaseLLM):
exception_mapping_worked = True
raise e
except Exception as e:
raise AzureOpenAIError(status_code=500, message=str(e))
if hasattr(e, "status_code"):
raise e
else:
raise AzureOpenAIError(status_code=500, message=str(e))
def streaming(self,
logging_obj,

View file

@ -68,6 +68,7 @@ def test_chat_completion_exception_azure(client):
# make an openai client to call _make_status_error_from_response
openai_client = openai.OpenAI(api_key="anything")
openai_exception = openai_client._make_status_error_from_response(response=response)
print(openai_exception)
assert isinstance(openai_exception, openai.AuthenticationError)
except Exception as e: