Skip to content

Commit 0338f54

Browse files
authored
fix: incorrect URL for Ollama embeddings endpoint (#2750)
2 parents 3f7eab0 + 2203ff9 commit 0338f54

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

letta/embeddings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ def get_text_embedding(self, text: str):
139139

140140
class OllamaEmbeddings:
141141

142+
# Uses OpenAI API standard
142143
# Format:
143-
# curl http://localhost:11434/api/embeddings -d '{
144+
# curl http://localhost:11434/v1/embeddings -d '{
144145
# "model": "mxbai-embed-large",
145-
# "prompt": "Llamas are members of the camelid family"
146+
# "input": "Llamas are members of the camelid family"
146147
# }'
147148

148149
def __init__(self, model: str, base_url: str, ollama_additional_kwargs: dict):
@@ -154,18 +155,18 @@ def get_text_embedding(self, text: str):
154155
import httpx
155156

156157
headers = {"Content-Type": "application/json"}
157-
json_data = {"model": self.model, "prompt": text}
158+
json_data = {"model": self.model, "input": text}
158159
json_data.update(self.ollama_additional_kwargs)
159160

160161
with httpx.Client() as client:
161162
response = client.post(
162-
f"{self.base_url}/api/embeddings",
163+
f"{self.base_url}/embeddings",
163164
headers=headers,
164165
json=json_data,
165166
)
166167

167168
response_json = response.json()
168-
return response_json["embedding"]
169+
return response_json["data"][0]["embedding"]
169170

170171

171172
class GoogleEmbeddings:

0 commit comments

Comments
 (0)