Skip to content

Commit 48ed9dd

Browse files
committed
Update image processing prompt
1 parent 45b62b0 commit 48ed9dd

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

linebot/app/services/handlers/image_handler.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@ def handle_image_message(event):
2525
temp_image_file.write(chunk)
2626

2727
# 使用 vision 函式處理圖片
28-
response = process_image(
29-
temp_file_path, "圖片內容有什麼?"
30-
) # TODO: 設定圖片處理的 prompt
28+
response_image_text = process_image(
29+
temp_file_path, "請分析圖片內容有什麼,並且提醒使用者,這個功能是實驗性質的,可能會有錯誤或不準確的情況,不會套用到 Dify API 中,所以單純只是分析圖片內容而已。如果覺得有趣我們可以更新這一部分!不要使用 markdown 語法,可以用表情符號"
30+
)
3131
# 刪除臨時檔案
3232
os.remove(temp_file_path)
33-
return [TextSendMessage(text=response, quick_reply=create_quick_reply())]
33+
if not response_image_text:
34+
return [
35+
TextSendMessage(
36+
text="抱歉,無法處理圖片內容,我好像壞掉了",
37+
quick_reply=create_quick_reply(),
38+
)
39+
]
40+
# 使用 Dify API 進行推論
41+
return [TextSendMessage(text=response_image_text, quick_reply=create_quick_reply())]
3442
except Exception as e:
3543
logger.error(f"處理圖片訊息時發生錯誤: {str(e)}", exc_info=True)
3644
return [

0 commit comments

Comments
 (0)