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(lint) : resolve LIT006 violations
KnyazSh30ed0c14b56f
diff --git a/litellm/llms/gigachat/passthrough/transformation.py b/litellm/llms/gigachat/passthrough/transformation.pyindex 7f37fb91bf6..605037020e3 100644--- a/litellm/llms/gigachat/passthrough/transformation.py+++ b/litellm/llms/gigachat/passthrough/transformation.py@@ -178,10 +178,9 @@ class GigaChatPassthroughConfig(BasePassthroughConfig):)translated_chunk = gigachat_iterator.chunk_parser(chunk=message)- if isinstance(translated_chunk, dict) and generic_chunk_has_all_required_fields(- cast(dict, translated_chunk)- ):+ if isinstance(translated_chunk, dict) and generic_chunk_has_all_required_fields(translated_chunk):chunk_obj = convert_generic_chunk_to_model_response_stream(+ # cast-ok: validated TypedDictcast(GenericStreamingChunk, translated_chunk))elif isinstance(translated_chunk, ModelResponseStream):diff --git a/litellm/passthrough/main.py b/litellm/passthrough/main.pyindex 829aa769491..b3cfb4b61c6 100644--- a/litellm/passthrough/main.py+++ b/litellm/passthrough/main.py@@ -10,8 +10,10 @@ from functools import partialfrom typing import (Any,AsyncGenerator,+ AsyncIterator,Coroutine,Generator,+ Iterator,List,cast,)@@ -32,6 +34,16 @@ base_llm_http_handler = BaseLLMHTTPHandler()from .utils import BasePassthroughUtils+async def _as_async_generator(iterable: AsyncIterator[bytes]) -> AsyncGenerator[bytes, Any]:+ async for chunk in iterable:+ yield chunk+++def _as_generator(iterable: Iterator[bytes]) -> Generator[bytes, Any, Any]:+ for chunk in iterable:+ yield chunk++class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):def __init__(self,@@ -80,7 +92,7 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):self._initialized = Truetry:self._response.raise_for_status()- self._iterator = cast(AsyncGenerator[bytes, Any], self._response.aiter_bytes())+ self._iterator = _as_async_generator(self._response.aiter_bytes())except Exception: # noqa: BLE001try:await self._response.aclose()@@ -123,7 +135,7 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):if not self._initialized:await selftry:- chunk = await self._iterator.__anext__()+ chunk = await anext(self._iterator)self._raw_bytes.append(chunk)return chunkexcept Exception: # noqa: BLE001@@ -148,6 +160,7 @@ class AsyncPassthroughStreamingResponse(AsyncGenerator[Any, Any]):self._start_flush()try:if self._initialized:+ await self._iterator.aclose()await self._response.aclose()except Exception: # noqa: BLE001pass@@ -165,7 +178,7 @@ class PassthroughStreamingResponse(Generator[Any, Any, Any]):self.status_code = response.status_codeself._litellm_logging_obj = litellm_logging_objself._provider_config = provider_config- self._iterator: Generator[bytes, Any, Any] = cast(Generator[bytes, Any, Any], response.iter_bytes())+ self._iterator: Generator[bytes, Any, Any] = _as_generator(response.iter_bytes())self._raw_bytes: List[bytes] = []self._flush_scheduled = False@@ -383,7 +396,13 @@ def llm_passthrough_route(_is_async = bool(kwargs.get("allm_passthrough_route", False))- litellm_logging_obj = cast(LiteLLMLoggingObj, kwargs.get("litellm_logging_obj"))+ _raw_logging_obj = kwargs.get("litellm_logging_obj")+ if not isinstance(_raw_logging_obj, LiteLLMLoggingObj):+ raise TypeError(+ "litellm_logging_obj is required and must be a LiteLLMLoggingObj instance; "+ f"got {type(_raw_logging_obj).__name__}"+ )+ litellm_logging_obj: LiteLLMLoggingObj = _raw_logging_objmodel, custom_llm_provider, api_key, api_base = get_llm_provider(model=model,diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.pyindex ad3f22af7a1..dca24203105 100644--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py@@ -455,7 +455,13 @@ async def milvus_proxy_route(request_body = await get_request_body(request)# check collectionName- collection_name = cast(str | None, request_body.get("collectionName"))+ _raw_collection_name = request_body.get("collectionName")+ if _raw_collection_name is not None and not isinstance(_raw_collection_name, str):+ raise HTTPException(+ status_code=400,+ detail=f"collectionName must be a string. Got {type(_raw_collection_name).__name__}",+ )+ collection_name: str | None = _raw_collection_nameextra_headers = {}base_target_url: str | None = Noneif not collection_name: