Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
gr.Markdown("---")
|
| 193 |
-
gr.Markdown("### 🙏
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 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()
|