Spaces:
Paused
Paused
gkbalu
commited on
Commit
·
01fb99d
1
Parent(s):
ccadc61
W4 D1 HW
Browse files
app.py
CHANGED
@@ -51,9 +51,9 @@ hf_embeddings = HuggingFaceEndpointEmbeddings(
|
|
51 |
huggingfacehub_api_token=HF_TOKEN,
|
52 |
)
|
53 |
|
54 |
-
if os.path.exists(
|
55 |
vectorstore = FAISS.load_local(
|
56 |
-
|
57 |
hf_embeddings,
|
58 |
allow_dangerous_deserialization=True # this is necessary to load the vectorstore from disk as it's stored as a `.pkl` file.
|
59 |
)
|
@@ -61,13 +61,13 @@ if os.path.exists("./data/vectorstore"):
|
|
61 |
print("Loaded Vectorstore")
|
62 |
else:
|
63 |
print("Indexing Files")
|
64 |
-
os.makedirs(
|
65 |
for i in range(0, len(split_documents), 32):
|
66 |
if i == 0:
|
67 |
vectorstore = FAISS.from_documents(split_documents[i:i+32], hf_embeddings)
|
68 |
continue
|
69 |
vectorstore.add_documents(split_documents[i:i+32])
|
70 |
-
vectorstore.save_local(
|
71 |
|
72 |
hf_retriever = vectorstore.as_retriever()
|
73 |
|
|
|
51 |
huggingfacehub_api_token=HF_TOKEN,
|
52 |
)
|
53 |
|
54 |
+
if os.path.exists(VECTORSTORE_PATH):
|
55 |
vectorstore = FAISS.load_local(
|
56 |
+
VECTORSTORE_PATH,
|
57 |
hf_embeddings,
|
58 |
allow_dangerous_deserialization=True # this is necessary to load the vectorstore from disk as it's stored as a `.pkl` file.
|
59 |
)
|
|
|
61 |
print("Loaded Vectorstore")
|
62 |
else:
|
63 |
print("Indexing Files")
|
64 |
+
os.makedirs(VECTORSTORE_PATH, exist_ok=True)
|
65 |
for i in range(0, len(split_documents), 32):
|
66 |
if i == 0:
|
67 |
vectorstore = FAISS.from_documents(split_documents[i:i+32], hf_embeddings)
|
68 |
continue
|
69 |
vectorstore.add_documents(split_documents[i:i+32])
|
70 |
+
vectorstore.save_local(VECTORSTORE_PATH)
|
71 |
|
72 |
hf_retriever = vectorstore.as_retriever()
|
73 |
|