fix: incorrect URL for Ollama embeddings endpoint (#2750)

This commit is contained in:
Sarah Wooders
2025-08-07 22:56:23 -07:00
committed by GitHub

View File

@@ -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,18 +155,18 @@ 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:
response = client.post(
f"{self.base_url}/api/embeddings",
f"{self.base_url}/embeddings",
headers=headers,
json=json_data,
)
response_json = response.json()
return response_json["embedding"]
return response_json["data"][0]["embedding"]
class GoogleEmbeddings: