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 MYPY errors
Ishaan Jaff7dce6a81a843
diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.pyindex d230023a231..9b514b102d8 100644--- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py+++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py@@ -29,7 +29,7 @@ from litellm.types.passthrough_endpoints.pass_through_endpoints import (EndpointType,PassthroughStandardLoggingPayload,)-from litellm.types.utils import LlmProviders, PassthroughCallTypes+from litellm.types.utils import ImageResponse, LlmProviders, PassthroughCallTypesfrom litellm.utils import ModelResponse, TextCompletionResponse@@ -42,8 +42,7 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):def llm_provider_name(self) -> LlmProviders:return LlmProviders.OPENAI- @staticmethod- def get_provider_config(model: str) -> OpenAIConfigType:+ def get_provider_config(self, model: str) -> OpenAIConfigType:"""Get OpenAI provider configuration for the given model."""return OpenAIConfig()@@ -92,8 +91,8 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):and "/v1/images/edits" in parsed_url.path)- @staticmethoddef _get_user_from_metadata(+ self,passthrough_logging_payload: PassthroughStandardLoggingPayload,) -> Optional[str]:"""Extract user information from passthrough logging payload."""@@ -239,13 +238,12 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):try:response_cost = 0.0- litellm_model_response = None+ litellm_model_response: Optional[Union[ModelResponse, TextCompletionResponse, ImageResponse]] = None+ handler_instance = OpenAIPassthroughLoggingHandler()if is_chat_completions:# Handle chat completions with existing logic- provider_config = OpenAIPassthroughLoggingHandler.get_provider_config(- model=model- )+ provider_config = handler_instance.get_provider_config(model=model)litellm_model_response = provider_config.transform_response(raw_response=httpx_response,model_response=litellm.ModelResponse(),@@ -284,8 +282,6 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):except Exception:pass# Create a simple response object for logging- from litellm.types.utils import ImageResponse-litellm_model_response = ImageResponse(data=response_body.get("data", []),model=model,@@ -311,8 +307,6 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):except Exception:pass# Create a simple response object for logging- from litellm.types.utils import ImageResponse-litellm_model_response = ImageResponse(data=response_body.get("data", []),model=model,@@ -332,7 +326,7 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):PassthroughStandardLoggingPayload] = kwargs.get("passthrough_logging_payload")if passthrough_logging_payload:- user = OpenAIPassthroughLoggingHandler._get_user_from_metadata(+ user = handler_instance._get_user_from_metadata(passthrough_logging_payload=passthrough_logging_payload,)if user:@@ -369,7 +363,7 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):)return {- "result": litellm_model_response or response_body,+ "result": litellm_model_response,"kwargs": kwargs,}@@ -480,6 +474,7 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):# Build complete response from chunks using our streaming handlerhandler = OpenAIPassthroughLoggingHandler()+ handler_instance = handlercomplete_response = handler._build_complete_streaming_response(all_chunks=all_chunks,litellm_logging_obj=litellm_logging_obj,@@ -516,7 +511,7 @@ class OpenAIPassthroughLoggingHandler(BasePassthroughLoggingHandler):"passthrough_logging_payload")if passthrough_logging_payload:- user = OpenAIPassthroughLoggingHandler._get_user_from_metadata(+ user = handler_instance._get_user_from_metadata(passthrough_logging_payload=passthrough_logging_payload,)if user: