acastelan commited on
Commit
3512e9d
1 Parent(s): 35b0bdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -53,9 +53,9 @@ hf_embeddings = HuggingFaceEndpointEmbeddings(
53
  huggingfacehub_api_token=HF_TOKEN,
54
  )
55
 
56
- if os.path.exists("./data/vectorstore/"):
57
  vectorstore = FAISS.load_local(
58
- "./data/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,7 +63,7 @@ if os.path.exists("./data/vectorstore/"):
63
  print("Loaded Vectorstore")
64
  else:
65
  print("Indexing Files")
66
- os.makedirs("./data/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,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("./data/vectorstore/")
75
 
76
  hf_retriever = vectorstore.as_retriever()
77
 
 
53
  huggingfacehub_api_token=HF_TOKEN,
54
  )
55
 
56
+ if os.path.exists("./data/vectorstore"):
57
  vectorstore = FAISS.load_local(
58
+ "./data/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("./data/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("./data/vectorstore")
75
 
76
  hf_retriever = vectorstore.as_retriever()
77