Tushar Malik commited on
Commit
9582098
·
verified ·
1 Parent(s): a589416

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -510,17 +510,14 @@ def chatbot_interface(user_query, response_style, selected_retrieval_methods, se
510
 
511
 
512
  if pdf_file is not None:
513
- # Assume `pdf_file` is the path to the file, so no need for `.read()`
514
- with tempfile.NamedTemporaryFile(mode="wb", suffix=".pdf", delete=False) as tmp:
515
- with open(pdf_file, "rb") as f: # Open the file in binary mode
516
- tmp.write(f.read()) # Write the file content to the temporary file
517
- pdf_path = tmp.name # Store the path of the temporary file
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')
 
510
 
511
 
512
  if pdf_file is not None:
513
+ pdf_path = pdf_file.name # Get the file path
514
+ # Now you can process the file path as needed
515
+ return f"File path: {pdf_path}\nUser Query: {user_query}\nResponse Style: {response_style}\nRetrieval Methods: {retrieval_methods}\nReranking Methods: {reranking_methods}\nChunk Size: {chunk_size}\nOverlap: {overlap}"
516
+ else:
517
+ return "No file uploaded."
 
518
  # Create vector DB and Annoy index
519
  create_vector_db_and_annoy_index(pdf_path, vector_db_path, annoy_index_path)
520
  store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
 
 
521
  # if pdf_file is not None:
522
  # pdf_path = pdf_file.name # Get the path of the uploaded file
523
  # create_vector_db_and_annoy_index(pdf_path, 'vector_db.pkl', 'vector_index.ann')