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
code QA fixes
Ishaan Jaffer13fa573d6138
diff --git a/litellm/_lazy_imports.py b/litellm/_lazy_imports.pyindex b25e6830640..6f96f9f8ff3 100644--- a/litellm/_lazy_imports.py+++ b/litellm/_lazy_imports.py@@ -1,5 +1,6 @@-from typing import Any, Optional, castimport sys+from typing import Any, Optional, cast+def _get_litellm_globals() -> dict:"""Helper to get the globals dictionary of the litellm module."""@@ -262,7 +263,9 @@ def _lazy_import_utils(name: str) -> Any: # noqa: PLR0915return _supports_response_schemaif name == "supports_parallel_function_calling":- from .utils import supports_parallel_function_calling as _supports_parallel_function_calling+ from .utils import (+ supports_parallel_function_calling as _supports_parallel_function_calling,+ )_globals["supports_parallel_function_calling"] = _supports_parallel_function_callingreturn _supports_parallel_function_calling@@ -428,7 +431,9 @@ def _lazy_import_cost_calculator(name: str) -> Any:return _cost_per_tokenif name == "response_cost_calculator":- from .cost_calculator import response_cost_calculator as _response_cost_calculator+ from .cost_calculator import (+ response_cost_calculator as _response_cost_calculator,+ )_globals["response_cost_calculator"] = _response_cost_calculatorreturn _response_cost_calculator@@ -500,9 +505,7 @@ def _lazy_import_types_utils(name: str) -> Any:return _CredentialItemif name == "PriorityReservationDict":- from .types.utils import (- PriorityReservationDict as _PriorityReservationDict,- )+ from .types.utils import PriorityReservationDict as _PriorityReservationDict_globals["PriorityReservationDict"] = _PriorityReservationDictreturn _PriorityReservationDict@@ -522,9 +525,7 @@ def _lazy_import_types_utils(name: str) -> Any:return _SearchProvidersif name == "GenericStreamingChunk":- from .types.utils import (- GenericStreamingChunk as _GenericStreamingChunk,- )+ from .types.utils import GenericStreamingChunk as _GenericStreamingChunk_globals["GenericStreamingChunk"] = _GenericStreamingChunkreturn _GenericStreamingChunk@@ -568,13 +569,17 @@ def _lazy_import_llm_client_cache(name: str) -> Any:_globals = _get_litellm_globals()if name == "LLMClientCache":- from litellm.caching.llm_caching_handler import LLMClientCache as _LLMClientCache+ from litellm.caching.llm_caching_handler import (+ LLMClientCache as _LLMClientCache,+ )_globals["LLMClientCache"] = _LLMClientCachereturn _LLMClientCacheif name == "in_memory_llm_clients_cache":- from litellm.caching.llm_caching_handler import LLMClientCache as _LLMClientCache+ from litellm.caching.llm_caching_handler import (+ LLMClientCache as _LLMClientCache,+ )instance = _LLMClientCache()# Only populate the requested singleton name to keep lazy-import@@ -594,7 +599,9 @@ def _lazy_import_litellm_logging(name: str) -> Any:return _Loggingif name == "modify_integration":- from litellm.litellm_core_utils.litellm_logging import modify_integration as _modify_integration+ from litellm.litellm_core_utils.litellm_logging import (+ modify_integration as _modify_integration,+ )_globals["modify_integration"] = _modify_integrationreturn _modify_integration@@ -669,9 +676,7 @@ def _lazy_import_types(name: str) -> Any:_globals = _get_litellm_globals()if name == "GuardrailItem":- from litellm.types.guardrails import (- GuardrailItem as _GuardrailItem,- )+ from litellm.types.guardrails import GuardrailItem as _GuardrailItem_globals["GuardrailItem"] = _GuardrailItemreturn _GuardrailItem@@ -679,7 +684,7 @@ def _lazy_import_types(name: str) -> Any:raise AttributeError(f"Types lazy import: unknown attribute {name!r}")-def _lazy_import_llm_configs(name: str) -> Any:+def _lazy_import_llm_configs(name: str) -> Any: # noqa: PLR0915"""Lazy import for LLM config classes."""_globals = _get_litellm_globals()@@ -724,9 +729,7 @@ def _lazy_import_llm_configs(name: str) -> Any:return _AzureAnthropicConfigif name == "BytezChatConfig":- from .llms.bytez.chat.transformation import (- BytezChatConfig as _BytezChatConfig,- )+ from .llms.bytez.chat.transformation import BytezChatConfig as _BytezChatConfig_globals["BytezChatConfig"] = _BytezChatConfigreturn _BytezChatConfig@@ -780,9 +783,7 @@ def _lazy_import_llm_configs(name: str) -> Any:return _OobaboogaConfigif name == "MaritalkConfig":- from .llms.maritalk import (- MaritalkConfig as _MaritalkConfig,- )+ from .llms.maritalk import MaritalkConfig as _MaritalkConfig_globals["MaritalkConfig"] = _MaritalkConfigreturn _MaritalkConfig@@ -820,17 +821,13 @@ def _lazy_import_llm_configs(name: str) -> Any:return _AnthropicTextConfigif name == "GroqSTTConfig":- from .llms.groq.stt.transformation import (- GroqSTTConfig as _GroqSTTConfig,- )+ from .llms.groq.stt.transformation import GroqSTTConfig as _GroqSTTConfig_globals["GroqSTTConfig"] = _GroqSTTConfigreturn _GroqSTTConfigif name == "TritonConfig":- from .llms.triton.completion.transformation import (- TritonConfig as _TritonConfig,- )+ from .llms.triton.completion.transformation import TritonConfig as _TritonConfig_globals["TritonConfig"] = _TritonConfigreturn _TritonConfig@@ -1004,9 +1001,7 @@ def _lazy_import_llm_configs(name: str) -> Any:return _VoyageRerankConfigif name == "ClarifaiConfig":- from .llms.clarifai.chat.transformation import (- ClarifaiConfig as _ClarifaiConfig,- )+ from .llms.clarifai.chat.transformation import ClarifaiConfig as _ClarifaiConfig_globals["ClarifaiConfig"] = _ClarifaiConfigreturn _ClarifaiConfigdiff --git a/litellm/rag/main.py b/litellm/rag/main.pyindex b8461a8daa6..0ccbb435e53 100644--- a/litellm/rag/main.py+++ b/litellm/rag/main.py@@ -35,8 +35,6 @@ from litellm.rag.rag_query import RAGQueryfrom litellm.types.rag import (RAGIngestOptions,RAGIngestResponse,- RAGQueryRequest,- RAGQueryResponse,)from litellm.types.utils import ModelResponsefrom litellm.utils import clientdiff --git a/litellm/rag/rag_query.py b/litellm/rag/rag_query.pyindex 53cc6d0089c..bf346efb3f2 100644--- a/litellm/rag/rag_query.py+++ b/litellm/rag/rag_query.py@@ -1,12 +1,10 @@-from typing import Any, Dict, List, Optional, Union, cast+from typing import Any, Dict, List, Optional, Union-import litellmfrom litellm.types.llms.openai import AllMessageValues, ChatCompletionUserMessagefrom litellm.types.utils import ModelResponsefrom litellm.types.vector_stores import (VectorStoreResultContent,VectorStoreSearchResponse,- VectorStoreSearchResult,)