From 6baaf629e518bb1319589a24f136e7ec340e5755 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Sat, 25 Nov 2023 11:09:19 -0800 Subject: [PATCH] (fix) embedding: filter out metadata from optional_params --- litellm/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 07fd2846f6..125a2daccf 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -1711,6 +1711,11 @@ def embedding( - exception_type: If an exception occurs during the API call. """ azure = kwargs.get("azure", None) + optional_params = {} + for param in kwargs: + if param != "metadata": # filter out metadata from optional_params + optional_params[param] = kwargs[param] + model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(model=model, custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key) try: response = None @@ -1754,9 +1759,9 @@ def embedding( logging_obj=logging, timeout=timeout, model_response=EmbeddingResponse(), - optional_params=kwargs, + optional_params=optional_params, ) - elif model in litellm.open_ai_embedding_models: + elif model in litellm.open_ai_embedding_models or custom_llm_provider == "openai": api_base = ( api_base or litellm.api_base @@ -1788,7 +1793,7 @@ def embedding( logging_obj=logging, timeout=timeout, model_response=EmbeddingResponse(), - optional_params=kwargs + optional_params=optional_params ) elif model in litellm.cohere_embedding_models: cohere_key = ( @@ -1801,7 +1806,7 @@ def embedding( response = cohere.embedding( model=model, input=input, - optional_params=kwargs, + optional_params=optional_params, encoding=encoding, api_key=cohere_key, logging_obj=logging,