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

Update app.py

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