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
LiteLLM Minor Fixes & Improvements (01/18/2025) - p1 (#7857)
Krish Dholakiae67f18b153f1
diff --git a/litellm/llms/ollama_chat.py b/litellm/llms/ollama_chat.pyindex 76a0604c21b..38fe549ca6b 100644--- a/litellm/llms/ollama_chat.py+++ b/litellm/llms/ollama_chat.py@@ -154,6 +154,8 @@ class OllamaChatConfig(OpenAIGPTConfig):optional_params["stop"] = valueif param == "response_format" and value["type"] == "json_object":optional_params["format"] = "json"+ if param == "response_format" and value["type"] == "json_schema":+ optional_params["format"] = value["json_schema"]["schema"]### FUNCTION CALLING LOGIC ###if param == "tools":# ollama actually supports json outputdiff --git a/litellm/types/router.py b/litellm/types/router.pyindex 8c671fe52c8..1575db27e0c 100644--- a/litellm/types/router.py+++ b/litellm/types/router.py@@ -5,7 +5,7 @@ litellm.Router Types - includes RouterConfig, UpdateRouterConfig, ModelInfo etcimport datetimeimport enumimport uuid-from typing import Any, Dict, List, Literal, Optional, Tuple, Union+from typing import Any, Dict, List, Literal, Optional, Tuple, Union, get_type_hintsimport httpxfrom pydantic import BaseModel, ConfigDict, Field@@ -14,7 +14,7 @@ from typing_extensions import Required, TypedDictfrom ..exceptions import RateLimitErrorfrom .completion import CompletionRequestfrom .embedding import EmbeddingRequest-from .utils import ModelResponse+from .utils import ModelResponse, ProviderSpecificModelInfoclass ConfigurableClientsideParamsCustomAuth(TypedDict):@@ -530,6 +530,12 @@ class ModelGroupInfo(BaseModel):supported_openai_params: Optional[List[str]] = Field(default=[])configurable_clientside_auth_params: CONFIGURABLE_CLIENTSIDE_AUTH_PARAMS = None+ def __init__(self, **data):+ for field_name, field_type in get_type_hints(self.__class__).items():+ if field_type == bool and data.get(field_name) is None:+ data[field_name] = False+ super().__init__(**data)+class AssistantsTypedDict(TypedDict):custom_llm_provider: Literal["azure", "openai"]diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 5cc99131ae8..da25487453e 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -88,6 +88,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False):supports_audio_output: Optional[bool]supports_pdf_input: Optional[bool]supports_native_streaming: Optional[bool]+ supports_parallel_function_calling: Optional[bool]class ModelInfoBase(ProviderSpecificModelInfo, total=False):diff --git a/tests/local_testing/test_get_model_info.py b/tests/local_testing/test_get_model_info.pyindex 10fa4782f04..008a0ad20a6 100644--- a/tests/local_testing/test_get_model_info.py+++ b/tests/local_testing/test_get_model_info.py@@ -339,3 +339,32 @@ def test_get_model_info_bedrock_models():assert (v[base_model_key] == base_model_value), f"{base_model_key} is not equal to {base_model_value} for model {k}"+++def test_get_model_info_huggingface_models(monkeypatch):+ from litellm import Router+ from litellm.types.router import ModelGroupInfo++ monkeypatch.setenv("HUGGINGFACE_API_KEY", "hf_abc123")++ router = Router(+ model_list=[+ {+ "model_name": "meta-llama/Meta-Llama-3-8B-Instruct",+ "litellm_params": {+ "model": "huggingface/meta-llama/Meta-Llama-3-8B-Instruct",+ "api_base": "https://api-inference.huggingface.co/models/meta-llama/Llama-3.3-70B-Instruct",+ "api_key": os.environ["HUGGINGFACE_API_KEY"],+ },+ }+ ]+ )+ info = litellm.get_model_info("huggingface/meta-llama/Meta-Llama-3-8B-Instruct")+ print("info", info)+ assert info is not None++ ModelGroupInfo(+ model_group="meta-llama/Meta-Llama-3-8B-Instruct",+ providers=["huggingface"],+ **info,+ )