From ef69eefcdbba291d9a2057e20f74caff537d2402 Mon Sep 17 00:00:00 2001 From: onukura <26293997+onukura@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:26:40 +0000 Subject: [PATCH 1/2] Fix ollama api_base to enable remote url --- litellm/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/litellm/main.py b/litellm/main.py index 5f2b34482..12a119d80 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -2759,6 +2759,12 @@ def embedding( model_response=EmbeddingResponse(), ) elif custom_llm_provider == "ollama": + api_base = ( + litellm.api_base + or api_base + or get_secret("OLLAMA_API_BASE") + or "http://localhost:11434" + ) ollama_input = None if isinstance(input, list) and len(input) > 1: raise litellm.BadRequestError( @@ -2779,6 +2785,7 @@ def embedding( if aembedding == True: response = ollama.ollama_aembeddings( + api_base=api_base, model=model, prompt=ollama_input, encoding=encoding, From 2df63cc621ab0c8d222374cbbbe3d173c22c1310 Mon Sep 17 00:00:00 2001 From: onukura <26293997+onukura@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:25:22 +0000 Subject: [PATCH 2/2] Fix ollama embedding response --- litellm/llms/ollama.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litellm/llms/ollama.py b/litellm/llms/ollama.py index 3611ccd8b..05a3134fc 100644 --- a/litellm/llms/ollama.py +++ b/litellm/llms/ollama.py @@ -396,6 +396,7 @@ async def ollama_aembeddings( response_json = await response.json() embeddings = response_json["embedding"] + embeddings = [embeddings] # Ollama currently does not support batch embedding ## RESPONSE OBJECT output_data = [] for idx, embedding in enumerate(embeddings):