From 82686e731af1d1778d6f1bb5c5e271b2d5e46499 Mon Sep 17 00:00:00 2001 From: Anton Devson <99696803+antondevson@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:39:14 -0400 Subject: [PATCH 1/2] Use correct URL for Ollama embeddings Since the prefixing of the base url with `/v1` (OpenAI API standard) happens elsewhere and is even saved in the database, it's easier to fix this here for now. --- letta/embeddings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letta/embeddings.py b/letta/embeddings.py index dffcd571..0da697f4 100644 --- a/letta/embeddings.py +++ b/letta/embeddings.py @@ -159,7 +159,7 @@ class OllamaEmbeddings: with httpx.Client() as client: response = client.post( - f"{self.base_url}/api/embeddings", + f"{self.base_url}/embeddings", headers=headers, json=json_data, ) From 2203ff9092840ca9f9cee02ee911cfda0b7ee0bc Mon Sep 17 00:00:00 2001 From: natn0 Date: Wed, 6 Aug 2025 01:58:50 -0400 Subject: [PATCH 2/2] Updated call to OpenAI API compatible endpoint in Ollama to correct request and return data --- letta/embeddings.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/letta/embeddings.py b/letta/embeddings.py index 0da697f4..7dace6ee 100644 --- a/letta/embeddings.py +++ b/letta/embeddings.py @@ -139,10 +139,11 @@ class AzureOpenAIEmbedding: class OllamaEmbeddings: + # Uses OpenAI API standard # Format: - # curl http://localhost:11434/api/embeddings -d '{ + # curl http://localhost:11434/v1/embeddings -d '{ # "model": "mxbai-embed-large", - # "prompt": "Llamas are members of the camelid family" + # "input": "Llamas are members of the camelid family" # }' def __init__(self, model: str, base_url: str, ollama_additional_kwargs: dict): @@ -154,7 +155,7 @@ class OllamaEmbeddings: import httpx headers = {"Content-Type": "application/json"} - json_data = {"model": self.model, "prompt": text} + json_data = {"model": self.model, "input": text} json_data.update(self.ollama_additional_kwargs) with httpx.Client() as client: @@ -165,7 +166,7 @@ class OllamaEmbeddings: ) response_json = response.json() - return response_json["embedding"] + return response_json["data"][0]["embedding"] class GoogleEmbeddings: