Pijush2023 commited on
Commit
5faf413
·
verified ·
1 Parent(s): 51b2bf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1565,6 +1565,8 @@ def fetch_google_flights(departure_id="JFK", arrival_id="BHM", outbound_date=cur
1565
  # def insert_prompt(current_text, prompt):
1566
  # return prompt[0] if prompt else current_text
1567
 
 
 
1568
  # Function to process PDF, extract text, split it into chunks, and upload to the vector DB
1569
  def process_pdf(pdf_file):
1570
  with pdfplumber.open(pdf_file) as pdf:
@@ -1579,7 +1581,8 @@ def process_pdf(pdf_file):
1579
  # Embed and upload the chunks into the vector database
1580
  chunk_ids = []
1581
  for chunk in chunks:
1582
- chunk_id = vectorstore.add_documents([chunk])
 
1583
  chunk_ids.append(chunk_id)
1584
 
1585
  return f"Uploaded {len(chunks)} chunks to the vector database."
 
1565
  # def insert_prompt(current_text, prompt):
1566
  # return prompt[0] if prompt else current_text
1567
 
1568
+
1569
+ from langchain_core.documents import Document
1570
  # Function to process PDF, extract text, split it into chunks, and upload to the vector DB
1571
  def process_pdf(pdf_file):
1572
  with pdfplumber.open(pdf_file) as pdf:
 
1581
  # Embed and upload the chunks into the vector database
1582
  chunk_ids = []
1583
  for chunk in chunks:
1584
+ document = Document(page_content=chunk)
1585
+ chunk_id = vectorstore.add_documents([document])
1586
  chunk_ids.append(chunk_id)
1587
 
1588
  return f"Uploaded {len(chunks)} chunks to the vector database."