Spaces:
Sleeping
Sleeping
Tushar Malik commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -501,12 +501,17 @@ create_vector_db_and_annoy_index('med.pdf', 'vector_db.pkl', 'vector_index.ann')
|
|
| 501 |
|
| 502 |
import gradio as gr
|
| 503 |
|
| 504 |
-
def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods, chunk_size, overlap):
|
| 505 |
vector_db_path = "vector_db.pkl"
|
| 506 |
annoy_index_path = "vector_index.ann"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
|
| 508 |
# Load the documents and create embeddings with the provided chunk_size and overlap
|
| 509 |
-
store_embeddings_in_vector_db('med.pdf', 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
|
| 510 |
|
| 511 |
chatbot = MistralRAGChatbot(vector_db_path, annoy_index_path)
|
| 512 |
|
|
@@ -538,6 +543,7 @@ iface = gr.Interface(
|
|
| 538 |
fn=chatbot_interface,
|
| 539 |
theme=gr.themes.Soft(),
|
| 540 |
inputs=[
|
|
|
|
| 541 |
gr.Textbox(lines=5, label="User Query"),
|
| 542 |
gr.Dropdown(["Detailed", "Concise", "Creative", "Technical"], label="Response Style"),
|
| 543 |
gr.Dropdown(["annoy", "tfidf", "bm25", "euclidean", "jaccard"], label="Retrieval Methods", multiselect=True), # This line is changed
|
|
|
|
| 501 |
|
| 502 |
import gradio as gr
|
| 503 |
|
| 504 |
+
def chatbot_interface(user_query, response_style, selected_retrieval_methods, selected_reranking_methods, pdf_file, chunk_size, overlap):
|
| 505 |
vector_db_path = "vector_db.pkl"
|
| 506 |
annoy_index_path = "vector_index.ann"
|
| 507 |
+
if pdf_file is not None:
|
| 508 |
+
pdf_path = pdf_file.name # Get the path of the uploaded file
|
| 509 |
+
store_embeddings_in_vector_db(pdf_path, 'vector_db.pkl', 'vector_index.ann', chunk_size, overlap)
|
| 510 |
+
else:
|
| 511 |
+
return "Please upload a PDF file."
|
| 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 |
|
|
|
|
| 543 |
fn=chatbot_interface,
|
| 544 |
theme=gr.themes.Soft(),
|
| 545 |
inputs=[
|
| 546 |
+
gr.File(label="Upload PDF File"),
|
| 547 |
gr.Textbox(lines=5, label="User Query"),
|
| 548 |
gr.Dropdown(["Detailed", "Concise", "Creative", "Technical"], label="Response Style"),
|
| 549 |
gr.Dropdown(["annoy", "tfidf", "bm25", "euclidean", "jaccard"], label="Retrieval Methods", multiselect=True), # This line is changed
|