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
Merge branch 'devin_ai_fix_azure_cancellederror_35329' of https://github.com/BerriAI/litellm into devin_ai_fix_azure_cancellederror_35329
mateo-berri70be37a73c22
diff --cc tests/e2e/router/test_reliability_cancel_on_disconnect_e2e.pyindex 21fd2d70603,557103bdfab..7d46a980034--- a/tests/e2e/router/test_reliability_cancel_on_disconnect_e2e.py+++ b/tests/e2e/router/test_reliability_cancel_on_disconnect_e2e.py@@@ -34,9 -21,9 +34,9 @@@ import timimport pytestfrom complexity_router_client import ComplexityRouterClientfrom e2e_config import unique_marker- from e2e_http import NetworkError, StreamingResponse-from e2e_http import AbandonedRequest++from e2e_http import AbandonedRequest, StreamingResponsefrom lifecycle import ResourceManager- from models import ChatMessage, ChatResponse, ReliabilityChatBody, RouterSettingsOverride+ from models import ChatMessage, ReliabilityChatBody, RouterSettingsOverridefrom reliability_support import (chat_override,create_azure_benched_on_first_failure_deployment,@@@ -46,51 -33,18 +46,50 @@@pytestmark = pytest.mark.e2e-ABANDON_AFTER_SECONDS = 2.0-LONG_GENERATION_MAX_TOKENS = 4000-FOLLOW_UP_CALLS = 3-FOLLOW_UP_SPACING_SECONDS = 1.0-COOLDOWN_SECONDS = 60.0+CLIENT_HANGS_UP_AFTER_SECONDS = 8.0+LONG_ANSWER_MAX_TOKENS = 4096+BENCH_OUTLASTS_TEST_SECONDS = 300.0+SETTLE_AFTER_HANGUP_SECONDS = 3.0+CALLS_AFTER_HANGUP = 6+++def _say_hi(client: ComplexityRouterClient, key: str, group: str) -> StreamingResponse:+ return chat_override(+ client.proxy,+ key,+ group,+ f"say hi {unique_marker()}",+ override=RouterSettingsOverride(num_retries=0),+ )-def _long_generation_prompt(marker: str) -> str:- return (- f"Write a detailed, multi-chapter short story of at least 3000 words about {marker}. "- "Do not stop early and do not summarize."+def _hang_up_mid_answer(client: ComplexityRouterClient, key: str, group: str) -> None:+ """Send a request whose answer takes far longer than the client waits, so the- read timeout closes the socket while the provider is still generating."""- outcome = client.proxy.transport.post(++ client closes the socket while the provider is still generating."""++ outcome = client.proxy.transport.abandon(+ "/chat/completions",+ headers=client.proxy.transport.bearer(key),+ json=ReliabilityChatBody(+ model=group,+ messages=[+ ChatMessage(+ role="user",+ content=f"Write a 3000 word essay on the history of the telegraph. {unique_marker()}",+ )+ ],+ max_tokens=LONG_ANSWER_MAX_TOKENS,+ router_settings_override=RouterSettingsOverride(num_retries=0),+ ),- response_type=ChatResponse,- timeout=CLIENT_HANGS_UP_AFTER_SECONDS,++ after=CLIENT_HANGS_UP_AFTER_SECONDS,)+ match outcome:- case NetworkError(message=message) if "Read timed out" in message:++ case AbandonedRequest():+ return- case _:++ case StreamingResponse(status_code=status_code, body=body):+ pytest.fail(+ f"the client should have hung up {CLIENT_HANGS_UP_AFTER_SECONDS:.0f}s into a long answer with the "- f"call still in flight, but the proxy answered first: {outcome!r}"++ f"call still in flight, but the proxy answered first with {status_code}: {body[:300]}"+ )class TestReliabilityCancelOnDisconnect: