fix(azure.py): improve error handling for azure image gen responses

This commit is contained in:
Krrish Dholakia 2024-07-08 16:39:05 -07:00
parent 3045a2d9b3
commit 381347082d

View file

@ -1108,7 +1108,10 @@ class AzureChatCompletion(BaseLLM):
"api-key": api_key, "api-key": api_key,
}, },
) )
operation_location_url = response.headers["operation-location"] if "operation-location" in response.headers:
operation_location_url = response.headers["operation-location"]
else:
raise AzureOpenAIError(status_code=500, message=response.text)
response = await async_handler.get( response = await async_handler.get(
url=operation_location_url, url=operation_location_url,
headers={ headers={
@ -1220,7 +1223,10 @@ class AzureChatCompletion(BaseLLM):
"api-key": api_key, "api-key": api_key,
}, },
) )
operation_location_url = response.headers["operation-location"] if "operation-location" in response.headers:
operation_location_url = response.headers["operation-location"]
else:
raise AzureOpenAIError(status_code=500, message=response.text)
response = sync_handler.get( response = sync_handler.get(
url=operation_location_url, url=operation_location_url,
headers={ headers={