Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -410,13 +410,16 @@ with gr.Blocks(css=custom_css, title="Document Q&A System") as demo:
|
|
| 410 |
<div style='text-align:center; color:#1976D2; margin-bottom:18px;'>Upload a document, ask questions, or use your voice!</div>
|
| 411 |
""")
|
| 412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
# Document upload section
|
| 414 |
with gr.Row(elem_classes="centered-main"):
|
| 415 |
with gr.Column():
|
| 416 |
with gr.Group(elem_classes="compact-box"):
|
| 417 |
gr.Markdown("<div class='section-title'>1. Upload Document</div>")
|
| 418 |
file_input = gr.File(label="Upload Document", file_types=[".pdf", ".txt", ".doc", ".docx"], file_count="single", type="binary", elem_classes="upload-btn")
|
| 419 |
-
file_output = gr.Textbox(label="Upload Status", interactive=False, elem_classes="textbox")
|
| 420 |
reset_btn = gr.Button("Reset Chat & Upload New Document", elem_classes="reset-btn")
|
| 421 |
def reset_all():
|
| 422 |
rag.thread_id = None
|
|
@@ -429,7 +432,6 @@ with gr.Blocks(css=custom_css, title="Document Q&A System") as demo:
|
|
| 429 |
with gr.Column():
|
| 430 |
with gr.Group(elem_classes="compact-box"):
|
| 431 |
gr.Markdown("<div class='section-title'>2. Chat with your Document</div>")
|
| 432 |
-
chatbot = gr.Chatbot(height=350, elem_classes="gradio-chatbot", label=None, type="messages")
|
| 433 |
with gr.Row():
|
| 434 |
question = gr.Textbox(label="Type your question and press Enter", placeholder="Ask a question about your document...", elem_classes="textbox")
|
| 435 |
send_btn = gr.Button("Send", elem_classes="send-btn")
|
|
|
|
| 410 |
<div style='text-align:center; color:#1976D2; margin-bottom:18px;'>Upload a document, ask questions, or use your voice!</div>
|
| 411 |
""")
|
| 412 |
|
| 413 |
+
# Define shared components at the top
|
| 414 |
+
chatbot = gr.Chatbot(height=350, elem_classes="gradio-chatbot", label=None, type="messages")
|
| 415 |
+
file_output = gr.Textbox(label="Upload Status", interactive=False, elem_classes="textbox")
|
| 416 |
+
|
| 417 |
# Document upload section
|
| 418 |
with gr.Row(elem_classes="centered-main"):
|
| 419 |
with gr.Column():
|
| 420 |
with gr.Group(elem_classes="compact-box"):
|
| 421 |
gr.Markdown("<div class='section-title'>1. Upload Document</div>")
|
| 422 |
file_input = gr.File(label="Upload Document", file_types=[".pdf", ".txt", ".doc", ".docx"], file_count="single", type="binary", elem_classes="upload-btn")
|
|
|
|
| 423 |
reset_btn = gr.Button("Reset Chat & Upload New Document", elem_classes="reset-btn")
|
| 424 |
def reset_all():
|
| 425 |
rag.thread_id = None
|
|
|
|
| 432 |
with gr.Column():
|
| 433 |
with gr.Group(elem_classes="compact-box"):
|
| 434 |
gr.Markdown("<div class='section-title'>2. Chat with your Document</div>")
|
|
|
|
| 435 |
with gr.Row():
|
| 436 |
question = gr.Textbox(label="Type your question and press Enter", placeholder="Ask a question about your document...", elem_classes="textbox")
|
| 437 |
send_btn = gr.Button("Send", elem_classes="send-btn")
|