The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(azure): propagate asyncio.CancelledError instead of raising AzureOpenAIError(500)
Devin AI7a2a158e71f3
diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.pyindex ccb9eb8f5c8..bc834e211f2 100644--- a/litellm/llms/azure/azure.py+++ b/litellm/llms/azure/azure.py@@ -467,7 +467,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):additional_args={"complete_input_dict": data},original_response=str(e),)- raise AzureOpenAIError(status_code=500, message=str(e))+ raiseexcept Exception as e:message = getattr(e, "message", str(e))body = getattr(e, "body", None)diff --git a/tests/test_litellm/llms/azure/test_azure.py b/tests/test_litellm/llms/azure/test_azure.pynew file mode 100644index 00000000000..dec4a1dd975--- /dev/null+++ b/tests/test_litellm/llms/azure/test_azure.py@@ -0,0 +1,31 @@+import asyncio+import os+import sys++import pytest+from openai import AsyncAzureOpenAI++sys.path.insert(0, os.path.abspath("../../../.."))++import litellm+++async def test_acompletion_propagates_cancelled_error():+ client = AsyncAzureOpenAI(+ api_key="fake-key",+ api_version="2024-02-01",+ azure_endpoint="https://fake-resource.openai.azure.com",+ )++ async def cancelled_create(**kwargs):+ raise asyncio.CancelledError()++ client.chat.completions.with_raw_response.create = cancelled_create++ with pytest.raises(asyncio.CancelledError):+ await litellm.acompletion(+ model="azure/fake-deployment",+ messages=[{"role": "user", "content": "hi"}],+ client=client,+ )