Spaces:
Sleeping
Sleeping
File size: 843 Bytes
5847e55 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from src.rag import FaissDB
import argparse
from dotenv import load_dotenv
import os
load_dotenv()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--path_to_index", type=str, required=True)
args = parser.parse_args()
path_to_index = args.path_to_index
try:
faiss_db = FaissDB(emb_model=os.getenv("OPENAI_EMBEDDINGS_MODEL"))
faiss_db.load_index(path_to_index)
except Exception as e:
print(f"Error loading index: {e}")
exit(1)
while True:
query = input("Enter query: ")
if query == "exit":
break
try:
documents = faiss_db.similarity_search(query)
print("\n\n".join(documents))
except Exception as e:
print(f"Error searching for documents: {e}")
continue
|