Muzammil6376 commited on
Commit
8439939
Β·
verified Β·
1 Parent(s): d179e57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -89,10 +89,12 @@ def process_pdf(pdf_file):
89
  # combine text chunks and image captions
90
  docs = chunks + captions
91
 
92
- # embed and index
93
  vectors = embeddings.embed_documents(docs)
94
- index = FAISS.from_embeddings(vectors, docs)
95
- retriever = index.as_retriever(search_kwargs={"k":2})
 
 
96
 
97
  status = f"βœ… Indexed β€” {len(chunks)} text chunks + {len(captions)} captions"
98
  return os.path.basename(pdf_file.name), status, gr.update(interactive=True)
 
89
  # combine text chunks and image captions
90
  docs = chunks + captions
91
 
92
+ # embed and index
93
  vectors = embeddings.embed_documents(docs)
94
+ # FAISS.from_embeddings expects list of (text, embedding) pairs
95
+ pairs = list(zip(docs, vectors))
96
+ index = FAISS.from_embeddings(pairs)
97
+ retriever = index.as_retriever(search_kwargs={"k":2})(search_kwargs={"k":2})
98
 
99
  status = f"βœ… Indexed β€” {len(chunks)} text chunks + {len(captions)} captions"
100
  return os.path.basename(pdf_file.name), status, gr.update(interactive=True)