Seunggg commited on
Commit
ba7f366
·
verified ·
1 Parent(s): aac64e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
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("## 🌱 植物助手 - 实时联动版\n结合 Render 实时传感器数据 + 本地 LoRA 模型,生成更合理建议。")
70
-
71
  sensor_box = gr.Textbox(label="🧪 当前传感器数据", lines=6, interactive=False)
72
- user_input = gr.Textbox(label="植物问题", lines=4)
73
  answer_box = gr.Textbox(label="🤖 回答建议", lines=8, interactive=False)
 
74
 
75
- user_input.submit(fn=respond, inputs=user_input, outputs=[sensor_box, answer_box])
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()