Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -342,24 +342,6 @@ for name in enabled_tool_names:
|
|
342 |
tools.append(tool_map[name])
|
343 |
|
344 |
|
345 |
-
# -----------------------------
|
346 |
-
# Create FAISS Vector Store
|
347 |
-
# -----------------------------
|
348 |
-
import faiss
|
349 |
-
class MyVectorStore:
|
350 |
-
def __init__(self, index: faiss.Index):
|
351 |
-
self.index = index
|
352 |
-
|
353 |
-
def save_local(self, path: str):
|
354 |
-
# Save the FAISS index to the specified file
|
355 |
-
faiss.write_index(self.index, path)
|
356 |
-
print(f"Index saved to {path}")
|
357 |
-
|
358 |
-
@classmethod
|
359 |
-
def load_local(cls, path: str):
|
360 |
-
# Load the FAISS index from the specified file
|
361 |
-
index = faiss.read_index(path)
|
362 |
-
return cls(index)
|
363 |
|
364 |
# -----------------------------
|
365 |
# Prepare Documents
|
@@ -431,8 +413,7 @@ class MyVectorStore:
|
|
431 |
index = faiss.read_index(path)
|
432 |
return cls(index)
|
433 |
|
434 |
-
|
435 |
-
if __name__ == "__main__":
|
436 |
# Process JSON data
|
437 |
with open("questions.json", "r", encoding="utf-8") as f:
|
438 |
json_data = json.load(f)
|
@@ -465,7 +446,7 @@ if __name__ == "__main__":
|
|
465 |
# Create LangChain Retriever Tool
|
466 |
# -----------------------------
|
467 |
|
468 |
-
retriever = FAISS.
|
469 |
|
470 |
question_retriever_tool = create_retriever_tool(
|
471 |
retriever=retriever,
|
|
|
342 |
tools.append(tool_map[name])
|
343 |
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
|
346 |
# -----------------------------
|
347 |
# Prepare Documents
|
|
|
413 |
index = faiss.read_index(path)
|
414 |
return cls(index)
|
415 |
|
416 |
+
|
|
|
417 |
# Process JSON data
|
418 |
with open("questions.json", "r", encoding="utf-8") as f:
|
419 |
json_data = json.load(f)
|
|
|
446 |
# Create LangChain Retriever Tool
|
447 |
# -----------------------------
|
448 |
|
449 |
+
retriever = FAISS. loaded_store("/home/wendy/Downloads/faiss_index.index", embedding_model).as_retriever()
|
450 |
|
451 |
question_retriever_tool = create_retriever_tool(
|
452 |
retriever=retriever,
|