PebllaRyan commited on
Commit
0eac169
·
verified ·
1 Parent(s): 6907256

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -36
app.py CHANGED
@@ -164,44 +164,57 @@ def record_feedback(user_query, final_answer, feedback_choice, improved_answer):
164
 
165
  # === 6. 构建 Gradio 界面 ===
166
 
167
- with gr.Blocks() as demo:
168
- gr.Markdown("# 🧠 AI促销推荐助手")
169
- gr.Markdown("请填写以下信息,我们将根据历史案例为你定制促销建议。")
170
-
171
- with gr.Row():
172
- store_name = gr.Textbox(label="店家名称", placeholder="例如:小王烧烤")
173
- store_type = gr.Textbox(label="餐馆类型", placeholder="例如:中式快餐 / 咖啡馆")
174
-
175
- with gr.Row():
176
- location = gr.Textbox(label="地理位置", placeholder="例如:北京市朝阳区")
177
- budget = gr.Textbox(label="促销预算(选填)", placeholder="例如:500元以内,可留空")
178
-
179
- problem = gr.Textbox(label="目前遇到的问题或目标", placeholder="例如:下午人流少,希望提高堂食销量", lines=3)
180
- ai_answer = gr.Textbox(label="AI 回答", lines=8)
181
-
182
- submit_btn = gr.Button("提交问题")
183
-
184
- submit_btn.click(
185
- fn=lambda sn, st, loc, bud, prob: ask_promotion_ai(
186
- format_query(sn, st, loc, bud, prob)
187
- ),
188
- inputs=[store_name, store_type, location, budget, problem],
189
- outputs=[ai_answer]
190
- )
 
 
 
 
 
 
 
 
 
 
 
191
 
192
  gr.Markdown("---")
193
- gr.Markdown("### 🙏 请对 AI 的回答进行评价")
194
-
195
- feedback_choice = gr.Radio(["好", "不好"], label="你觉得这个回答怎么样?")
196
- improved_answer = gr.Textbox(label="如果选择“不好”,你觉得更好的回答是什么?", lines=3)
197
- feedback_btn = gr.Button("提交反馈")
198
- feedback_output = gr.Markdown()
199
-
200
- feedback_btn.click(
201
- fn=record_feedback,
202
- inputs=[problem, ai_answer, feedback_choice, improved_answer],
203
- outputs=[feedback_output]
204
- )
 
 
205
 
206
  # 启动 Gradio app
207
  demo.launch()
 
164
 
165
  # === 6. 构建 Gradio 界面 ===
166
 
167
+ with gr.Blocks(css="""
168
+ body { font-family: 'Helvetica Neue', sans-serif; background: #f9f9fb; }
169
+ .gradio-container { max-width: 800px; margin: auto; padding: 2em 2em; border-radius: 12px; background: white; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05); }
170
+ h1, h2, h3 { color: #2c2c2c; }
171
+ .gr-button { background-color: #3b82f6 !important; color: white !important; border-radius: 8px; }
172
+ .gr-button:hover { background-color: #2563eb !important; }
173
+ textarea, input { border-radius: 6px !important; }
174
+ .gr-textbox { margin-bottom: 10px !important; }
175
+ label { font-weight: 600; margin-bottom: 4px; display: inline-block; color: #4b5563; }
176
+ """) as demo:
177
+
178
+ gr.Markdown("## 🧠 AI促销推荐助手")
179
+ gr.Markdown("填写信息后,我们将根据历史促销案例为你生成专属策略建议。")
180
+
181
+ with gr.Group():
182
+ with gr.Row():
183
+ store_name = gr.Textbox(label="🏷️ 店家名称", placeholder="例如:小王烧烤")
184
+ store_type = gr.Textbox(label="🍽️ 餐馆类型", placeholder="例如:中式快餐 / 咖啡馆")
185
+
186
+ with gr.Row():
187
+ location = gr.Textbox(label="📍 地理位置", placeholder="例如:北京市朝阳区")
188
+ budget = gr.Textbox(label="💰 促销预算(选填)", placeholder="例如:500元以内,可留空")
189
+
190
+ problem = gr.Textbox(label="❓ 当前问题或目标", placeholder="例如:下午人流少,希望提高堂食销量", lines=3)
191
+ submit_btn = gr.Button("🚀 提交问题")
192
+
193
+ ai_answer = gr.Textbox(label="📋 AI 回答", lines=10)
194
+
195
+ submit_btn.click(
196
+ fn=lambda sn, st, loc, bud, prob: ask_promotion_ai(
197
+ format_query(sn, st, loc, bud, prob)
198
+ ),
199
+ inputs=[store_name, store_type, location, budget, problem],
200
+ outputs=[ai_answer]
201
+ )
202
 
203
  gr.Markdown("---")
204
+ gr.Markdown("### 🙏 你对这次 AI 回答满意吗?")
205
+
206
+ with gr.Group():
207
+ feedback_choice = gr.Radio(["好", "不好"], label="你的评价")
208
+ improved_answer = gr.Textbox(label="💡 如果不满意,你觉得更好的答案是?", lines=3)
209
+ feedback_btn = gr.Button("📩 提交反馈")
210
+ feedback_output = gr.Markdown()
211
+
212
+ feedback_btn.click(
213
+ fn=record_feedback,
214
+ inputs=[problem, ai_answer, feedback_choice, improved_answer],
215
+ outputs=[feedback_output]
216
+ )
217
+
218
 
219
  # 启动 Gradio app
220
  demo.launch()