Update app.py
Browse files
app.py
CHANGED
@@ -53,9 +53,9 @@ hf_embeddings = HuggingFaceEndpointEmbeddings(
|
|
53 |
huggingfacehub_api_token=HF_TOKEN,
|
54 |
)
|
55 |
|
56 |
-
if os.path.exists("./
|
57 |
vectorstore = FAISS.load_local(
|
58 |
-
"./
|
59 |
hf_embeddings,
|
60 |
allow_dangerous_deserialization=True # this is necessary to load the vectorstore from disk as it's stored as a `.pkl` file.
|
61 |
)
|
@@ -63,7 +63,7 @@ if os.path.exists("./data/vectorstore"):
|
|
63 |
print("Loaded Vectorstore")
|
64 |
else:
|
65 |
print("Indexing Files")
|
66 |
-
os.makedirs("./
|
67 |
### 4. INDEX FILES
|
68 |
### NOTE: REMEMBER TO BATCH THE DOCUMENTS WITH MAXIMUM BATCH SIZE = 32
|
69 |
for i in range(0, len(split_documents), 32):
|
@@ -71,7 +71,7 @@ else:
|
|
71 |
vectorstore = FAISS.from_documents(split_documents[i:i+32], hf_embeddings)
|
72 |
continue
|
73 |
vectorstore.add_documents(split_documents[i:i+32])
|
74 |
-
vectorstore.save_local("./
|
75 |
|
76 |
hf_retriever = vectorstore.as_retriever()
|
77 |
|
|
|
53 |
huggingfacehub_api_token=HF_TOKEN,
|
54 |
)
|
55 |
|
56 |
+
if os.path.exists("./vectorstore"):
|
57 |
vectorstore = FAISS.load_local(
|
58 |
+
"./vectorstore",
|
59 |
hf_embeddings,
|
60 |
allow_dangerous_deserialization=True # this is necessary to load the vectorstore from disk as it's stored as a `.pkl` file.
|
61 |
)
|
|
|
63 |
print("Loaded Vectorstore")
|
64 |
else:
|
65 |
print("Indexing Files")
|
66 |
+
os.makedirs("./vectorstore", exist_ok=True)
|
67 |
### 4. INDEX FILES
|
68 |
### NOTE: REMEMBER TO BATCH THE DOCUMENTS WITH MAXIMUM BATCH SIZE = 32
|
69 |
for i in range(0, len(split_documents), 32):
|
|
|
71 |
vectorstore = FAISS.from_documents(split_documents[i:i+32], hf_embeddings)
|
72 |
continue
|
73 |
vectorstore.add_documents(split_documents[i:i+32])
|
74 |
+
vectorstore.save_local("./vectorstore")
|
75 |
|
76 |
hf_retriever = vectorstore.as_retriever()
|
77 |
|