jarif commited on
Commit
8b99414
·
verified ·
1 Parent(s): 0624502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -30,7 +30,7 @@ def load_llm():
30
  return HuggingFacePipeline(pipeline=pipe)
31
 
32
  def load_faiss_index():
33
- index_path = "faiss_index.index"
34
  if not os.path.exists(index_path):
35
  st.warning("FAISS index not found. Please create the index first.")
36
  raise RuntimeError("FAISS index not found.")
@@ -38,7 +38,9 @@ def load_faiss_index():
38
  try:
39
  faiss_index = faiss.read_index(index_path)
40
  logger.info(f"FAISS index loaded successfully from {index_path}")
41
- return FAISS(faiss_index)
 
 
42
  except Exception as e:
43
  st.error(f"Failed to load FAISS index: {e}")
44
  logger.exception("Exception in load_faiss_index")
 
30
  return HuggingFacePipeline(pipeline=pipe)
31
 
32
  def load_faiss_index():
33
+ index_path = "faiss_index/index.faiss" # Update path to match the created index
34
  if not os.path.exists(index_path):
35
  st.warning("FAISS index not found. Please create the index first.")
36
  raise RuntimeError("FAISS index not found.")
 
38
  try:
39
  faiss_index = faiss.read_index(index_path)
40
  logger.info(f"FAISS index loaded successfully from {index_path}")
41
+ embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
42
+ retriever = FAISS(faiss_index, embeddings)
43
+ return retriever
44
  except Exception as e:
45
  st.error(f"Failed to load FAISS index: {e}")
46
  logger.exception("Exception in load_faiss_index")