asemxin commited on
Commit
4179d57
·
1 Parent(s): 554cff6

fix: Vision 图片内容写入对话历史,支持文字追问

Browse files
Files changed (1) hide show
  1. image_daemon.py +7 -0
image_daemon.py CHANGED
@@ -219,6 +219,13 @@ def handle_image_message(message_id, chat_id, image_key):
219
  if vision:
220
  result = send_text(token, chat_id, vision)
221
  log(f"📤 已发送感悟 (code={result.get('code', '?')})")
 
 
 
 
 
 
 
222
  else:
223
  log("⚠️ Vision 分析失败,无回复")
224
 
 
219
  if vision:
220
  result = send_text(token, chat_id, vision)
221
  log(f"📤 已发送感悟 (code={result.get('code', '?')})")
222
+ # 将图片对话写入历史,以便用户后续文字追问时能引用
223
+ history = _chat_history.get(chat_id, [])
224
+ history = history + [
225
+ {"role": "user", "content": "[用户发送了一张图片]"},
226
+ {"role": "assistant", "content": vision}
227
+ ]
228
+ _chat_history[chat_id] = history[-(MAX_HISTORY * 2):]
229
  else:
230
  log("⚠️ Vision 分析失败,无回复")
231