Rulga commited on
Commit
97c7ccf
·
1 Parent(s): ecd5a30

Refactor message input handling to remove style method and add Enter key submission for user input

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -737,30 +737,22 @@ with gr.Blocks() as demo:
737
  label="Your question",
738
  placeholder="Enter your question...",
739
  scale=4
740
- ).style(container=False) # Используем style вместо submit_on_enter
741
  submit_btn = gr.Button("Send", variant="primary")
742
- clear_btn = gr.Button("Clear") # Add clear button
743
-
744
- with gr.Column(scale=1):
745
- gr.Markdown("### Knowledge Base Management")
746
- gr.Markdown("""
747
- - **Update**: Add new documents to existing base
748
- - **Rebuild**: Create new base from scratch
749
- """)
750
- with gr.Row():
751
- update_kb_btn = gr.Button("📝 Update Base", variant="secondary", scale=1)
752
- rebuild_kb_btn = gr.Button("🔄 Rebuild Base", variant="primary", scale=1)
753
- kb_status = gr.Textbox(
754
- label="Status",
755
- placeholder="Knowledge base status will appear here...",
756
- interactive=False
757
- )
758
 
 
759
  submit_btn.click(
760
  respond_and_clear,
761
  [msg, chatbot, conversation_id],
762
  [chatbot, conversation_id, msg]
763
  )
 
 
 
 
 
 
764
  update_kb_btn.click(update_kb, None, kb_status)
765
  rebuild_kb_btn.click(rebuild_kb, None, kb_status)
766
 
 
737
  label="Your question",
738
  placeholder="Enter your question...",
739
  scale=4
740
+ )
741
  submit_btn = gr.Button("Send", variant="primary")
742
+ clear_btn = gr.Button("Clear")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
 
744
+ # Add event handlers
745
  submit_btn.click(
746
  respond_and_clear,
747
  [msg, chatbot, conversation_id],
748
  [chatbot, conversation_id, msg]
749
  )
750
+ # Add Enter key handler
751
+ msg.submit(
752
+ respond_and_clear,
753
+ [msg, chatbot, conversation_id],
754
+ [chatbot, conversation_id, msg]
755
+ )
756
  update_kb_btn.click(update_kb, None, kb_status)
757
  rebuild_kb_btn.click(rebuild_kb, None, kb_status)
758