Update app.py
Browse files
app.py
CHANGED
@@ -66,15 +66,14 @@ def auto_update_sensor():
|
|
66 |
return gr.Textbox.update(value=get_sensor_data())
|
67 |
|
68 |
with gr.Blocks() as demo:
|
69 |
-
gr.Markdown("
|
70 |
-
|
71 |
sensor_box = gr.Textbox(label="🧪 当前传感器数据", lines=6, interactive=False)
|
72 |
-
|
73 |
answer_box = gr.Textbox(label="🤖 回答建议", lines=8, interactive=False)
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
# 自动刷新传感器数据,每 5 秒
|
78 |
-
demo.load(fn=auto_update_sensor, inputs=None, outputs=sensor_box, every=5)
|
79 |
|
80 |
-
demo.launch()
|
|
|
66 |
return gr.Textbox.update(value=get_sensor_data())
|
67 |
|
68 |
with gr.Blocks() as demo:
|
69 |
+
gr.Markdown("# 🌱 植物助手 - 实时联动版")
|
70 |
+
|
71 |
sensor_box = gr.Textbox(label="🧪 当前传感器数据", lines=6, interactive=False)
|
72 |
+
question = gr.Textbox(label="植物问题", lines=4, placeholder="请输入植物相关的问题 😊")
|
73 |
answer_box = gr.Textbox(label="🤖 回答建议", lines=8, interactive=False)
|
74 |
+
send_btn = gr.Button("发送")
|
75 |
|
76 |
+
demo.load(fn=get_sensor_data, inputs=None, outputs=sensor_box, every=5)
|
77 |
+
send_btn.click(fn=respond, inputs=question, outputs=[sensor_box, answer_box])
|
|
|
|
|
78 |
|
79 |
+
demo.launch()
|