Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,7 @@ def get_embeddings():
|
|
68 |
def update_vectors(files, parser):
|
69 |
global uploaded_documents
|
70 |
if not files:
|
71 |
-
return "Please upload at least one PDF file."
|
72 |
|
73 |
embed = get_embeddings()
|
74 |
total_chunks = 0
|
@@ -88,7 +88,8 @@ def update_vectors(files, parser):
|
|
88 |
|
89 |
database.save_local("faiss_database")
|
90 |
|
91 |
-
|
|
|
92 |
|
93 |
def generate_chunked_response(prompt, model, max_tokens=1000, num_calls=3, temperature=0.2, should_stop=False):
|
94 |
print(f"Starting generate_chunked_response with {num_calls} calls")
|
@@ -410,10 +411,10 @@ css = """
|
|
410 |
|
411 |
uploaded_documents = []
|
412 |
|
413 |
-
def display_documents():
|
414 |
return gr.CheckboxGroup(
|
415 |
-
choices=
|
416 |
-
value=
|
417 |
label="Select documents to query"
|
418 |
)
|
419 |
|
@@ -469,12 +470,16 @@ with demo:
|
|
469 |
file_input = gr.Files(label="Upload your PDF documents", file_types=[".pdf"])
|
470 |
parser_dropdown = gr.Dropdown(choices=["pypdf", "llamaparse"], label="Select PDF Parser", value="llamaparse")
|
471 |
update_button = gr.Button("Upload Document")
|
|
|
472 |
|
473 |
update_output = gr.Textbox(label="Update Status")
|
474 |
-
update_button.click(
|
475 |
-
|
|
|
|
|
|
|
476 |
|
477 |
-
|
478 |
"""
|
479 |
## How to use
|
480 |
1. Upload PDF documents using the file input at the top.
|
|
|
68 |
def update_vectors(files, parser):
|
69 |
global uploaded_documents
|
70 |
if not files:
|
71 |
+
return "Please upload at least one PDF file.", []
|
72 |
|
73 |
embed = get_embeddings()
|
74 |
total_chunks = 0
|
|
|
88 |
|
89 |
database.save_local("faiss_database")
|
90 |
|
91 |
+
status_message = f"Vector store updated successfully. Processed {total_chunks} chunks from {len(files)} files using {parser}."
|
92 |
+
return status_message, [doc["name"] for doc in uploaded_documents]
|
93 |
|
94 |
def generate_chunked_response(prompt, model, max_tokens=1000, num_calls=3, temperature=0.2, should_stop=False):
|
95 |
print(f"Starting generate_chunked_response with {num_calls} calls")
|
|
|
411 |
|
412 |
uploaded_documents = []
|
413 |
|
414 |
+
def display_documents(document_list):
|
415 |
return gr.CheckboxGroup(
|
416 |
+
choices=document_list,
|
417 |
+
value=document_list,
|
418 |
label="Select documents to query"
|
419 |
)
|
420 |
|
|
|
470 |
file_input = gr.Files(label="Upload your PDF documents", file_types=[".pdf"])
|
471 |
parser_dropdown = gr.Dropdown(choices=["pypdf", "llamaparse"], label="Select PDF Parser", value="llamaparse")
|
472 |
update_button = gr.Button("Upload Document")
|
473 |
+
document_selector = gr.CheckboxGroup(label="Select documents to query")
|
474 |
|
475 |
update_output = gr.Textbox(label="Update Status")
|
476 |
+
update_button.click(
|
477 |
+
update_vectors,
|
478 |
+
inputs=[file_input, parser_dropdown],
|
479 |
+
outputs=[update_output, document_selector]
|
480 |
+
)
|
481 |
|
482 |
+
gr.Markdown(
|
483 |
"""
|
484 |
## How to use
|
485 |
1. Upload PDF documents using the file input at the top.
|