Evaaaaa06 commited on
Commit
38279da
·
verified ·
1 Parent(s): c0ca9ac

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -8
main.py CHANGED
@@ -62,13 +62,6 @@ async def webhook(
62
  raise HTTPException(status_code=400, detail="Invalid signature")
63
  return "ok"
64
 
65
- # 處理文字訊息事件
66
- @line_handler.add(MessageEvent, message=TextMessage)
67
- def handle_message(event):
68
- global working_status
69
-
70
-
71
-
72
 
73
  #設定open AI API 金鑰
74
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
@@ -145,7 +138,7 @@ def get_previous_message(user_id):
145
  # 返回倒數第二則訊息(上一則)
146
  return us
147
 
148
- @line_handler.add(MessageEvent, message=ImageMessage)
149
  def handle_image_message(event):
150
  # 從 LINE API 獲取圖片數據
151
  image_path = get_image_url(event.message.id)
@@ -178,6 +171,7 @@ def handle_image_message(event):
178
  out = analyze_with_openai(image_path, user_text)
179
 
180
  else:
 
181
  # 檢查事件類型和訊息類型
182
  if event.type != "message" or event.message.type != "text":
183
  # 回覆錯誤訊息
 
62
  raise HTTPException(status_code=400, detail="Invalid signature")
63
  return "ok"
64
 
 
 
 
 
 
 
 
65
 
66
  #設定open AI API 金鑰
67
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
 
138
  # 返回倒數第二則訊息(上一則)
139
  return us
140
 
141
+ @line_handler.add(MessageEvent, message=(ImageMessage,TextMessage))
142
  def handle_image_message(event):
143
  # 從 LINE API 獲取圖片數據
144
  image_path = get_image_url(event.message.id)
 
171
  out = analyze_with_openai(image_path, user_text)
172
 
173
  else:
174
+ global working_status
175
  # 檢查事件類型和訊息類型
176
  if event.type != "message" or event.message.type != "text":
177
  # 回覆錯誤訊息