Tushar Malik commited on
Commit
a0631cd
·
verified ·
1 Parent(s): ed8b7cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -505,16 +505,22 @@ import gradio as gr
505
  def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods, pdf_file, chunk_size, overlap):
506
  vector_db_path = "vector_db.pkl"
507
  annoy_index_path = "vector_index.ann"
508
- if pdf_file is not None:
509
- with tempfile.NamedTemporaryFile(mode="wb", suffix=".pdf", delete=False) as tmp:
510
- tmp.write(pdf_file) # Write the uploaded file content to the temporary file
511
- pdf_path = tmp.name
512
-
513
- # Create vector DB and Annoy index
514
- create_vector_db_and_annoy_index(pdf_path, vector_db_path, annoy_index_path)
515
- store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
516
- else:
517
- return "Please upload a PDF file."
 
 
 
 
 
 
518
  # if pdf_file is not None:
519
  # pdf_path = pdf_file.name # Get the path of the uploaded file
520
  # create_vector_db_and_annoy_index(pdf_path, 'vector_db.pkl', 'vector_index.ann')
 
505
  def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods, pdf_file, chunk_size, overlap):
506
  vector_db_path = "vector_db.pkl"
507
  annoy_index_path = "vector_index.ann"
508
+
509
+ pdf_path = pdf_file.name
510
+ create_vector_db_and_annoy_index(pdf_path, 'vector_db.pkl', 'vector_index.ann')
511
+ store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
512
+
513
+
514
+ # if pdf_file is not None:
515
+ # with tempfile.NamedTemporaryFile(mode="wb", suffix=".pdf", delete=False) as tmp:
516
+ # tmp.write(pdf_file) # Write the uploaded file content to the temporary file
517
+ # pdf_path = tmp.name
518
+
519
+ # # Create vector DB and Annoy index
520
+ # create_vector_db_and_annoy_index(pdf_path, vector_db_path, annoy_index_path)
521
+ # store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
522
+ # else:
523
+ # return "Please upload a PDF file."
524
  # if pdf_file is not None:
525
  # pdf_path = pdf_file.name # Get the path of the uploaded file
526
  # create_vector_db_and_annoy_index(pdf_path, 'vector_db.pkl', 'vector_index.ann')