wt002 commited on
Commit
9fabb76
·
verified ·
1 Parent(s): 918897e

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +11 -4
agent.py CHANGED
@@ -353,7 +353,7 @@ class MyVectorStore:
353
 
354
  def save_local(self, path: str):
355
  # Save the FAISS index to the specified file
356
- faiss.write_index(self.index, "/home/wendy/Downloads")
357
  print(f"Index saved to {path}")
358
 
359
  @classmethod
@@ -397,10 +397,17 @@ vector_store = FAISS.from_documents(docs, embedding_model)
397
 
398
  # Save the FAISS index
399
  vector_store = MyVectorStore(index)
400
- vector_store.save_local("/home/wt/Downloads/faiss_index.index")
401
 
402
- # Load the FAISS index later
403
- loaded_vector_store = MyVectorStore.load_local("faiss_index.index")
 
 
 
 
 
 
 
 
404
 
405
 
406
 
 
353
 
354
  def save_local(self, path: str):
355
  # Save the FAISS index to the specified file
356
+ faiss.write_index(self.index, path)
357
  print(f"Index saved to {path}")
358
 
359
  @classmethod
 
397
 
398
  # Save the FAISS index
399
  vector_store = MyVectorStore(index)
 
400
 
401
+ # Assuming you already have a FAISS index
402
+ index = faiss.IndexFlatL2(768) # Or whatever dimensionality your embeddings have
403
+ vector_store = MyVectorStore(index)
404
+
405
+ # Save
406
+ vector_store.save_local("/home/wendy/Downloads/faiss_index.index")
407
+
408
+ # Load
409
+ loaded_store = MyVectorStore.load_local("/home/wendy/Downloads/faiss_index.index")
410
+
411
 
412
 
413