Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -78,7 +78,7 @@ def update_vectors(files, parser):
|
|
78 |
data = load_document(file, parser)
|
79 |
all_data.extend(data)
|
80 |
total_chunks += len(data)
|
81 |
-
uploaded_documents
|
82 |
|
83 |
if os.path.exists("faiss_database"):
|
84 |
database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
|
@@ -88,7 +88,11 @@ 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")
|
@@ -469,11 +473,14 @@ 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 |
-
document_selector
|
473 |
|
474 |
update_output = gr.Textbox(label="Update Status")
|
475 |
-
|
476 |
-
|
|
|
|
|
|
|
|
|
477 |
|
478 |
gr.Markdown(
|
479 |
"""
|
|
|
78 |
data = load_document(file, parser)
|
79 |
all_data.extend(data)
|
80 |
total_chunks += len(data)
|
81 |
+
uploaded_documents = [{"name": file.name, "selected": True} for file in files]
|
82 |
|
83 |
if os.path.exists("faiss_database"):
|
84 |
database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
|
|
|
88 |
|
89 |
database.save_local("faiss_database")
|
90 |
|
91 |
+
return f"Vector store updated successfully. Processed {total_chunks} chunks from {len(files)} files using {parser}.", gr.CheckboxGroup(
|
92 |
+
choices=[doc["name"] for doc in uploaded_documents],
|
93 |
+
value=[doc["name"] for doc in uploaded_documents if doc["selected"]],
|
94 |
+
label="Select documents to query"
|
95 |
+
)
|
96 |
|
97 |
def generate_chunked_response(prompt, model, max_tokens=1000, num_calls=3, temperature=0.2, should_stop=False):
|
98 |
print(f"Starting generate_chunked_response with {num_calls} calls")
|
|
|
473 |
file_input = gr.Files(label="Upload your PDF documents", file_types=[".pdf"])
|
474 |
parser_dropdown = gr.Dropdown(choices=["pypdf", "llamaparse"], label="Select PDF Parser", value="llamaparse")
|
475 |
update_button = gr.Button("Upload Document")
|
|
|
476 |
|
477 |
update_output = gr.Textbox(label="Update Status")
|
478 |
+
document_selector = gr.CheckboxGroup(label="Select documents to query")
|
479 |
+
|
480 |
+
# Update both the output text and the document selector
|
481 |
+
update_button.click(update_vectors,
|
482 |
+
inputs=[file_input, parser_dropdown],
|
483 |
+
outputs=[update_output, document_selector])
|
484 |
|
485 |
gr.Markdown(
|
486 |
"""
|