From 6a3e8c0265cec35be988056083de286ccb57082f Mon Sep 17 00:00:00 2001 From: Ramakrishna Yekulla Date: Thu, 26 Jun 2025 17:46:59 +0530 Subject: [PATCH] fix: ValueError in faiss vector database serialization (#2519) - Replace np.savetxt/np.loadtxt with np.save/np.load for binary data - Fixes 'could not convert string to uint8' error during server startup - Issue occurred during faiss index deserialization, not Ollama connectivity - Affects Ollama template and other configurations using faiss vector_io --- llama_stack/providers/inline/vector_io/faiss/faiss.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama_stack/providers/inline/vector_io/faiss/faiss.py b/llama_stack/providers/inline/vector_io/faiss/faiss.py index 355750b25..8b2ae5e6e 100644 --- a/llama_stack/providers/inline/vector_io/faiss/faiss.py +++ b/llama_stack/providers/inline/vector_io/faiss/faiss.py @@ -73,7 +73,7 @@ class FaissIndex(EmbeddingIndex): self.chunk_by_index = {int(k): Chunk.model_validate_json(v) for k, v in data["chunk_by_index"].items()} buffer = io.BytesIO(base64.b64decode(data["faiss_index"])) - self.index = faiss.deserialize_index(np.loadtxt(buffer, dtype=np.uint8)) + self.index = faiss.deserialize_index(np.load(buffer, allow_pickle=False)) async def _save_index(self): if not self.kvstore or not self.bank_id: @@ -81,7 +81,7 @@ class FaissIndex(EmbeddingIndex): np_index = faiss.serialize_index(self.index) buffer = io.BytesIO() - np.savetxt(buffer, np_index) + np.save(buffer, np_index, allow_pickle=False) data = { "chunk_by_index": {k: v.model_dump_json() for k, v in self.chunk_by_index.items()}, "faiss_index": base64.b64encode(buffer.getvalue()).decode("utf-8"),