Spaces:
Paused
Paused
Shreyas094
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -476,41 +476,22 @@ def display_documents():
|
|
476 |
label="Select documents to query"
|
477 |
)
|
478 |
|
479 |
-
|
480 |
-
|
481 |
-
This function wraps the chatbot functionality with all parameters.
|
482 |
-
It will be used as the main function for gr.Interface.
|
483 |
-
"""
|
484 |
-
try:
|
485 |
-
for response in respond(message, history, model, temperature, num_calls, use_web_search, selected_docs):
|
486 |
-
history.append((message, response))
|
487 |
-
yield history
|
488 |
-
except Exception as e:
|
489 |
-
history.append((message, f"An error occurred: {str(e)}"))
|
490 |
-
yield history
|
491 |
|
492 |
-
# Define the components that were previously in additional_inputs
|
493 |
-
model_dropdown = gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3])
|
494 |
-
temperature_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.2, step=0.1, label="Temperature")
|
495 |
-
api_calls_slider = gr.Slider(minimum=1, maximum=5, value=1, step=1, label="Number of API Calls")
|
496 |
use_web_search = gr.Checkbox(label="Use Web Search", value=True)
|
497 |
-
document_selector = gr.CheckboxGroup(label="Select documents to query")
|
498 |
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
gr.
|
504 |
-
"
|
505 |
-
model_dropdown,
|
506 |
-
temperature_slider,
|
507 |
-
api_calls_slider,
|
508 |
use_web_search,
|
509 |
-
document_selector
|
510 |
],
|
511 |
-
outputs=gr.Chatbot(),
|
512 |
title="AI-powered Web Search and PDF Chat Assistant",
|
513 |
-
description="Chat with your PDFs or use web search to answer questions",
|
514 |
theme=gr.themes.Soft(
|
515 |
primary_hue="orange",
|
516 |
secondary_hue="amber",
|
|
|
476 |
label="Select documents to query"
|
477 |
)
|
478 |
|
479 |
+
# Define the checkbox outside the demo block
|
480 |
+
document_selector = gr.CheckboxGroup(label="Select documents to query")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
|
|
|
|
|
|
|
|
|
482 |
use_web_search = gr.Checkbox(label="Use Web Search", value=True)
|
|
|
483 |
|
484 |
+
demo = gr.ChatInterface(
|
485 |
+
respond,
|
486 |
+
additional_inputs=[
|
487 |
+
gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3]),
|
488 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.2, step=0.1, label="Temperature"),
|
489 |
+
gr.Slider(minimum=1, maximum=5, value=1, step=1, label="Number of API Calls"),
|
|
|
|
|
|
|
490 |
use_web_search,
|
491 |
+
document_selector # Add the document selector to the chat interface
|
492 |
],
|
|
|
493 |
title="AI-powered Web Search and PDF Chat Assistant",
|
494 |
+
description="Chat with your PDFs or use web search to answer questions (Please use toggle under Additional Inputs to swithc between PDF and Web Search, Default Value Web Search)",
|
495 |
theme=gr.themes.Soft(
|
496 |
primary_hue="orange",
|
497 |
secondary_hue="amber",
|