Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -401,17 +401,20 @@ with gr.Blocks(title="Enhanced JSON Chatbot") as demo:
|
|
| 401 |
|
| 402 |
status = gr.Markdown("π Ready. Upload JSON file to begin.")
|
| 403 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
with gr.Row():
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
user_box = gr.Textbox(
|
| 408 |
-
label="Ask about your JSON data...",
|
| 409 |
-
placeholder="e.g., Who are the batch instructors? or Who is Shukdev Datta?",
|
| 410 |
-
lines=2
|
| 411 |
-
)
|
| 412 |
-
with gr.Column(scale=1):
|
| 413 |
-
clear_btn = gr.Button("Clear Chat", variant="secondary", size="sm")
|
| 414 |
-
reload_btn = gr.Button("Reload JSON", variant="secondary", size="sm")
|
| 415 |
|
| 416 |
# States
|
| 417 |
state_corpus = gr.State([])
|
|
@@ -491,6 +494,12 @@ with gr.Blocks(title="Enhanced JSON Chatbot") as demo:
|
|
| 491 |
outputs=[chatbot],
|
| 492 |
).then(lambda: "", outputs=[user_box]) # Clear input after submit
|
| 493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
reload_btn.click(
|
| 495 |
load_json_to_corpus,
|
| 496 |
inputs=[json_file, fallback_path, max_val_len],
|
|
|
|
| 401 |
|
| 402 |
status = gr.Markdown("π Ready. Upload JSON file to begin.")
|
| 403 |
|
| 404 |
+
chatbot = gr.Chatbot(height=500)
|
| 405 |
+
|
| 406 |
+
with gr.Row():
|
| 407 |
+
user_box = gr.Textbox(
|
| 408 |
+
label="Ask about your JSON data...",
|
| 409 |
+
placeholder="e.g., Who are the batch instructors? or Who is Shukdev Datta?",
|
| 410 |
+
lines=2,
|
| 411 |
+
scale=4
|
| 412 |
+
)
|
| 413 |
+
send_btn = gr.Button("Send", variant="primary", size="lg", scale=1)
|
| 414 |
+
|
| 415 |
with gr.Row():
|
| 416 |
+
clear_btn = gr.Button("Clear Chat", variant="secondary")
|
| 417 |
+
reload_btn = gr.Button("Reload JSON", variant="secondary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
|
| 419 |
# States
|
| 420 |
state_corpus = gr.State([])
|
|
|
|
| 494 |
outputs=[chatbot],
|
| 495 |
).then(lambda: "", outputs=[user_box]) # Clear input after submit
|
| 496 |
|
| 497 |
+
send_btn.click(
|
| 498 |
+
ask_enhanced,
|
| 499 |
+
inputs=[api_key_tb, user_box, chatbot, state_corpus, topk_slider, per_table_cap],
|
| 500 |
+
outputs=[chatbot],
|
| 501 |
+
).then(lambda: "", outputs=[user_box]) # Clear input after send
|
| 502 |
+
|
| 503 |
reload_btn.click(
|
| 504 |
load_json_to_corpus,
|
| 505 |
inputs=[json_file, fallback_path, max_val_len],
|