JC321 commited on
Commit
81d13ee
·
verified ·
1 Parent(s): 39d15d3

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +11 -6
  2. requirements.txt +1 -1
app.py CHANGED
@@ -246,9 +246,9 @@ with gr.Blocks(title="SEC Financial Data Query Assistant") as demo:
246
  # 左侧:聊天机器人
247
  with gr.Column(scale=1):
248
  gr.Markdown("## 💬 AI Financial Assistant")
 
249
  chatbot = gr.Chatbot(
250
  height=500,
251
- placeholder="Ask me about financial data for any US listed company!",
252
  label="Chat with AI Assistant"
253
  )
254
  chat_input = gr.Textbox(
@@ -277,13 +277,17 @@ with gr.Blocks(title="SEC Financial Data Query Assistant") as demo:
277
  submit_btn = gr.Button("🔍 Query", variant="primary", size="lg")
278
  output = gr.Markdown(label="Query Results")
279
 
280
- # 聊天机器人事件
 
 
 
281
  chat_submit.click(
282
  fn=chatbot_response,
283
  inputs=[chat_input, chatbot],
284
  outputs=chatbot
285
- ).then(
286
- lambda: "",
 
287
  outputs=chat_input
288
  )
289
 
@@ -291,8 +295,9 @@ with gr.Blocks(title="SEC Financial Data Query Assistant") as demo:
291
  fn=chatbot_response,
292
  inputs=[chat_input, chatbot],
293
  outputs=chatbot
294
- ).then(
295
- lambda: "",
 
296
  outputs=chat_input
297
  )
298
 
 
246
  # 左侧:聊天机器人
247
  with gr.Column(scale=1):
248
  gr.Markdown("## 💬 AI Financial Assistant")
249
+ gr.Markdown("*Ask me about financial data for any US listed company!*")
250
  chatbot = gr.Chatbot(
251
  height=500,
 
252
  label="Chat with AI Assistant"
253
  )
254
  chat_input = gr.Textbox(
 
277
  submit_btn = gr.Button("🔍 Query", variant="primary", size="lg")
278
  output = gr.Markdown(label="Query Results")
279
 
280
+ # Chatbot 事件处理
281
+ def clear_input():
282
+ return ""
283
+
284
  chat_submit.click(
285
  fn=chatbot_response,
286
  inputs=[chat_input, chatbot],
287
  outputs=chatbot
288
+ )
289
+ chat_submit.click(
290
+ fn=clear_input,
291
  outputs=chat_input
292
  )
293
 
 
295
  fn=chatbot_response,
296
  inputs=[chat_input, chatbot],
297
  outputs=chatbot
298
+ )
299
+ chat_input.submit(
300
+ fn=clear_input,
301
  outputs=chat_input
302
  )
303
 
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio>=4.0.0
2
  requests
 
1
+ gradio>=4.44.0
2
  requests