Seunggg commited on
Commit
47cf770
·
verified ·
1 Parent(s): e5c24a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -71,15 +71,11 @@ def respond(user_input):
71
 
72
  # Gradio 界面
73
  with gr.Blocks() as demo:
74
- with gr.Row():
75
- sensor_box = gr.Textbox(label="🧪 当前传感器数据", lines=6, interactive=False, value=get_sensor_data(), live=True)
76
- question_box = gr.Textbox(label="🌿 植物问题", lines=4)
77
- answer_box = gr.Textbox(label="🤖 回答建议", lines=8, interactive=False)
78
 
79
- # 用户提交后生成回答
80
- question_box.submit(fn=respond, inputs=question_box, outputs=[sensor_box, answer_box])
81
 
82
- # 5 秒自动更新传感器数据
83
- sensor_box.change(fn=show_sensor_data, inputs=None, outputs=sensor_box).every(5)
84
 
85
  demo.launch()
 
71
 
72
  # Gradio 界面
73
  with gr.Blocks() as demo:
74
+ sensor_box = gr.Textbox(label="🧪 当前传感器数据", lines=6, interactive=False, value=get_sensor_data())
 
 
 
75
 
76
+ def auto_refresh():
77
+ return get_sensor_data()
78
 
79
+ sensor_box.change(fn=auto_refresh, inputs=None, outputs=sensor_box).every(5)
 
80
 
81
  demo.launch()