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
add dimensions for ollama embedding (#18536)
Small05a78fb0cf8f
diff --git a/litellm/llms/ollama/completion/handler.py b/litellm/llms/ollama/completion/handler.pyindex 9e6497e66ab..71956158f52 100644--- a/litellm/llms/ollama/completion/handler.py+++ b/litellm/llms/ollama/completion/handler.py@@ -15,7 +15,7 @@ def _prepare_ollama_embedding_payload() -> Dict[str, Any]:data: Dict[str, Any] = {"model": model, "input": prompts}- special_optional_params = ["truncate", "options", "keep_alive"]+ special_optional_params = ["truncate", "options", "keep_alive","dimensions"]for k, v in optional_params.items():if k in special_optional_params:diff --git a/litellm/utils.py b/litellm/utils.pyindex 8b597d02883..32f54b652ef 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -3148,6 +3148,21 @@ def get_optional_params_embeddings( # noqa: PLR0915drop_params=drop_params if drop_params is not None else False,)+ elif custom_llm_provider == "ollama":+ if 'dimensions' in non_default_params:+ optional_params['dimensions']=non_default_params.pop('dimensions')+ if len(non_default_params.keys()) > 0:+ if (+ litellm.drop_params is True or drop_params is True+ ): # drop the unsupported non-default values+ keys = list(non_default_params.keys())+ for k in keys:+ non_default_params.pop(k, None)+ else:+ raise UnsupportedParamsError(+ status_code=500,+ message=f"Setting {non_default_params} is not supported by {custom_llm_provider}. To drop it from the call, set `litellm.drop_params = True`.",+ )elif (custom_llm_provider != "openai"and custom_llm_provider != "azure"