BrianChuan commited on
Commit
c0164b7
·
1 Parent(s): a33c96d

Adjust the css style test

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -10,10 +10,7 @@ from langchain_huggingface import HuggingFaceEmbeddings
10
  from langchain_community.vectorstores import FAISS
11
  from PIL import Image
12
  from dotenv import load_dotenv
13
-
14
- # --- 匯入組員的模組 ---
15
- import emotion
16
- # ---------------------------
17
 
18
  load_dotenv()
19
 
@@ -77,8 +74,23 @@ def generate_content_with_groq(restaurant_name, restaurant_detail, user_diary, m
77
 
78
  client = OpenAI(api_key=GROQ_API_KEY, base_url="https://api.groq.com/openai/v1")
79
 
80
- system_prompt = "你是一個幽默、懂吃且善解人意的 AI 朋友..."
81
- user_msg = f"【狀態】心情分數:{mood_score}\n【日記】{user_diary}\n【建議原因】{mood_guide_reason}\n【餐廳】{restaurant_name}\n資料:{restaurant_detail}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  debug_log = ""
84
  if debug_mode:
@@ -177,7 +189,7 @@ def bridge_predict_frame(frame, st):
177
  # 這裡會讀取 emotion.py 中我們剛剛修改過的 CSS
178
  combined_css = emotion.css
179
 
180
- with gr.Blocks(title="AI 心情食堂", css=combined_css) as demo:
181
 
182
  st_state = gr.State(emotion.AppState())
183
 
@@ -208,7 +220,7 @@ with gr.Blocks(title="AI 心情食堂", css=combined_css) as demo:
208
  )
209
  food_input = gr.Radio(["吃飯", "吃麵", "隨便"], label="2. 想吃什麼", value="隨便")
210
  diary_input = gr.Textbox(lines=4, label="3. 心情日記", placeholder="寫下今天發生的事...")
211
- debug_mode_btn = gr.Checkbox(label="🔧 開啟除錯模式", value=False)
212
 
213
  submit_btn = gr.Button("🍱 送出給 Agent", variant="primary")
214
 
@@ -246,7 +258,7 @@ with gr.Blocks(title="AI 心情食堂", css=combined_css) as demo:
246
 
247
  submit_btn.click(
248
  fn=mood_agent_logic,
249
- inputs=[score_input, food_input, diary_input, debug_mode_btn],
250
  outputs=[agent_output, image_output, map_output, debug_output]
251
  )
252
 
 
10
  from langchain_community.vectorstores import FAISS
11
  from PIL import Image
12
  from dotenv import load_dotenv
13
+ import emotion # 情緒辨識
 
 
 
14
 
15
  load_dotenv()
16
 
 
74
 
75
  client = OpenAI(api_key=GROQ_API_KEY, base_url="https://api.groq.com/openai/v1")
76
 
77
+ system_prompt = "你是一個幽默、懂吃且善解人意的 AI 朋友。請根據使用者的日記、心情以及「心情美食指南」來推薦餐廳。"
78
+ user_msg = f"""
79
+ 【狀態】心情分數:{mood_score},日記:{user_diary}
80
+ 【心情美食指南建議】
81
+ 因為分數是 {mood_score},建議吃這類食物的原因是:「{mood_guide_reason}」。
82
+
83
+ 【推薦餐廳】
84
+ 名稱:{restaurant_name}
85
+ 資料:{restaurant_detail}
86
+
87
+ 任務:
88
+ 請用繁體中文寫一段溫暖有趣的回覆:
89
+ 1. 先回應他的日記與測驗人設。
90
+ 2. 引用「心情美食指南」的原因,告訴他為什麼現在適合吃這家餐廳(例如:「就像指南說的,現在你需要一點多巴胺...」)。
91
+ 3. 介紹這家餐廳的特色。
92
+ (只需要回覆文字內容)
93
+ """
94
 
95
  debug_log = ""
96
  if debug_mode:
 
189
  # 這裡會讀取 emotion.py 中我們剛剛修改過的 CSS
190
  combined_css = emotion.css
191
 
192
+ with gr.Blocks(title="AI 心情食堂") as demo:
193
 
194
  st_state = gr.State(emotion.AppState())
195
 
 
220
  )
221
  food_input = gr.Radio(["吃飯", "吃麵", "隨便"], label="2. 想吃什麼", value="隨便")
222
  diary_input = gr.Textbox(lines=4, label="3. 心情日記", placeholder="寫下今天發生的事...")
223
+ # debug_mode_btn = gr.Checkbox(label="🔧 開啟除錯模式", value=False)
224
 
225
  submit_btn = gr.Button("🍱 送出給 Agent", variant="primary")
226
 
 
258
 
259
  submit_btn.click(
260
  fn=mood_agent_logic,
261
+ inputs=[score_input, food_input, diary_input],
262
  outputs=[agent_output, image_output, map_output, debug_output]
263
  )
264