mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
Merge 6a3e8c0265
into 40fdce79b3
This commit is contained in:
commit
c83bd54b8c
1 changed files with 2 additions and 2 deletions
|
@ -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()}
|
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"]))
|
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):
|
async def _save_index(self):
|
||||||
if not self.kvstore or not self.bank_id:
|
if not self.kvstore or not self.bank_id:
|
||||||
|
@ -81,7 +81,7 @@ class FaissIndex(EmbeddingIndex):
|
||||||
|
|
||||||
np_index = faiss.serialize_index(self.index)
|
np_index = faiss.serialize_index(self.index)
|
||||||
buffer = io.BytesIO()
|
buffer = io.BytesIO()
|
||||||
np.savetxt(buffer, np_index)
|
np.save(buffer, np_index, allow_pickle=False)
|
||||||
data = {
|
data = {
|
||||||
"chunk_by_index": {k: v.model_dump_json() for k, v in self.chunk_by_index.items()},
|
"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"),
|
"faiss_index": base64.b64encode(buffer.getvalue()).decode("utf-8"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue