Mikiko Bazeley commited on
Commit
ca5e5c3
1 Parent(s): f6edda2

Trying Don Branson solution

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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
 
@@ -104,7 +104,7 @@ rag_prompt = PromptTemplate.from_template(RAG_PROMPT_TEMPLATE)
104
  """
105
  ### 1. CREATE HUGGINGFACE ENDPOINT FOR LLM
106
  hf_llm = HuggingFaceEndpoint(
107
- endpoint_url=f"{HF_LLM_ENDPOINT}",
108
  max_new_tokens=512,
109
  top_k=10,
110
  top_p=0.95,
 
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
 
 
104
  """
105
  ### 1. CREATE HUGGINGFACE ENDPOINT FOR LLM
106
  hf_llm = HuggingFaceEndpoint(
107
+ endpoint_url=HF_LLM_ENDPOINT,
108
  max_new_tokens=512,
109
  top_k=10,
110
  top_p=0.95,