Spaces:
Sleeping
Sleeping
Tushar Malik
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -413,7 +413,7 @@ def create_vector_db_and_annoy_index(pdf_path, vector_db_path, annoy_index_path)
|
|
| 413 |
# Cell 9: Run the store embeddings function (example)
|
| 414 |
# Replace 'example.pdf' with your PDF file path.
|
| 415 |
# It will create 'vector_db.pkl' and 'vector_index.ann'
|
| 416 |
-
|
| 417 |
|
| 418 |
# # Cell 10: Query the chatbot with user input
|
| 419 |
# async def query_chatbot():
|
|
@@ -502,32 +502,16 @@ def create_vector_db_and_annoy_index(pdf_path, vector_db_path, annoy_index_path)
|
|
| 502 |
|
| 503 |
import gradio as gr
|
| 504 |
|
| 505 |
-
def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods,
|
| 506 |
vector_db_path = "vector_db.pkl"
|
| 507 |
annoy_index_path = "vector_index.ann"
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 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')
|
| 524 |
-
# store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
|
| 525 |
-
|
| 526 |
-
# else:
|
| 527 |
-
# return "Please upload a PDF file."
|
| 528 |
-
|
| 529 |
-
# Load the documents and create embeddings with the provided chunk_size and overlap
|
| 530 |
-
#store_embeddings_in_vector_db('med.pdf', 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
|
| 531 |
|
| 532 |
chatbot = MistralRAGChatbot(vector_db_path, annoy_index_path)
|
| 533 |
|
|
|
|
| 413 |
# Cell 9: Run the store embeddings function (example)
|
| 414 |
# Replace 'example.pdf' with your PDF file path.
|
| 415 |
# It will create 'vector_db.pkl' and 'vector_index.ann'
|
| 416 |
+
create_vector_db_and_annoy_index('med.pdf', 'vector_db.pkl', 'vector_index.ann')
|
| 417 |
|
| 418 |
# # Cell 10: Query the chatbot with user input
|
| 419 |
# async def query_chatbot():
|
|
|
|
| 502 |
|
| 503 |
import gradio as gr
|
| 504 |
|
| 505 |
+
def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods, chunk_size, overlap):
|
| 506 |
vector_db_path = "vector_db.pkl"
|
| 507 |
annoy_index_path = "vector_index.ann"
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
+
|
| 513 |
+
#Load the documents and create embeddings with the provided chunk_size and overlap
|
| 514 |
+
store_embeddings_in_vector_db('med.pdf', 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
chatbot = MistralRAGChatbot(vector_db_path, annoy_index_path)
|
| 517 |
|