Evaaaaa06 commited on
Commit
f7e4a3b
·
verified ·
1 Parent(s): f40d7ce

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -3
main.py CHANGED
@@ -145,9 +145,18 @@ def handle_image_message(event):
145
  # 儲存當前文字訊息
146
  user_text = event.message.text
147
  store_user_message(user_id, "text", user_text)
148
-
149
- # 結合圖片與文字分析
150
- out = analyze_with_gemini(image_path, user_text)
 
 
 
 
 
 
 
 
 
151
 
152
  else:
153
  global working_status
 
145
  # 儲存當前文字訊息
146
  user_text = event.message.text
147
  store_user_message(user_id, "text", user_text)
148
+
149
+ try:
150
+ # 確保圖片存在
151
+ if not os.path.exists(image_path):
152
+ raise FileNotFoundError(f"圖片路徑無效:{image_path}")
153
+
154
+ organ = PIL.Image.open(image_path)
155
+ completion = chat.send_message([user_text, organ])
156
+ out = completion.text
157
+
158
+ except Exception as e:
159
+ out = f"發生錯誤: {e}"
160
 
161
  else:
162
  global working_status