fix(embedding): do not append /v1 to Ollama native embedding base_url (#16974)

This commit is contained in:
iwasaki
2026-07-16 14:21:55 +09:00
committed by GitHub
parent d2f4304ff4
commit d577b49a00

View File

@@ -469,7 +469,10 @@ class OllamaEmbed(Base):
_special_tokens = ["<|endoftext|>"]
def __init__(self, key, model_name, **kwargs):
self.base_url = ensure_v1(kwargs["base_url"])
# Native ollama.Client builds paths like "/api/embed" directly off this
# host; unlike the OpenAI-compatible providers below, it must NOT go
# through ensure_v1 (which appends "/v1") or every request 404s.
self.base_url = kwargs["base_url"].rstrip("/")
self.client = Client(host=self.base_url) if not key or key == "x" else Client(host=self.base_url, headers={"Authorization": f"Bearer {key}"})
self.model_name = model_name
self.keep_alive = kwargs.get("ollama_keep_alive", int(os.environ.get("OLLAMA_KEEP_ALIVE", -1)))