Fix: the error of Ollama embeddings interface returning "500 Internal Server Error" (#6350)

### What problem does this PR solve?

Fix the error where the Ollama embeddings interface returns a “500
Internal Server Error” when using models such as xiaobu-embedding-v2 for
embedding.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
zhou 2025-03-21 15:25:48 +08:00 committed by GitHub
parent f537b6ca00
commit 85480f6292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,14 +260,16 @@ class OllamaEmbed(Base):
tks_num = 0
for txt in texts:
res = self.client.embeddings(prompt=txt,
model=self.model_name)
model=self.model_name,
options={"use_mmap": True})
arr.append(res["embedding"])
tks_num += 128
return np.array(arr), tks_num
def encode_queries(self, text):
res = self.client.embeddings(prompt=text,
model=self.model_name)
model=self.model_name,
options={"use_mmap": True})
return np.array(res["embedding"]), 128