Update main.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|