myagent-ai 1.16.13 → 1.16.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -693,6 +693,41 @@ class MainAgent(BaseAgent):
693
693
  )
694
694
  break
695
695
 
696
+ # [v1.16.13] 特殊处理模型不支持图片输入 — 去掉图片用纯文本重试
697
+ _vision_keywords = ["doesn't support image", "does not support image", "model_incompatible", "image input", "not support vision", "unsupported multimodal", "image capability"]
698
+ if any(kw in _llm_error.lower() for kw in _vision_keywords) and context.metadata.get("user_images"):
699
+ logger.warning(f"[{task_id}] 模型不支持图片输入,去掉图片用纯文本重试")
700
+ context.metadata["user_images"] = []
701
+ # 用纯文本消息替换最后一条多模态消息
702
+ _text_only_msg = context.user_message or "请处理上述上下文。"
703
+ if len(messages) > 0 and isinstance(messages[-1].content, list):
704
+ messages[-1] = Message(role="user", content=_text_only_msg)
705
+ # 重试 LLM 调用
706
+ if stream_response and self.llm:
707
+ response = await self._call_llm_stream(
708
+ messages, text_delta_callback=text_delta_callback,
709
+ stream_response=stream_response,
710
+ )
711
+ else:
712
+ response = await self._call_llm(messages)
713
+ if response.success:
714
+ # 纯文本重试成功,给回复加上提示前缀
715
+ _vision_prefix = "⚠️ 当前模型不支持图片识别,已自动使用纯文本模式处理(图片未发送给模型)。\n\n"
716
+ llm_raw = _vision_prefix + response.content
717
+ context.working_memory["final_response"] = llm_raw
718
+ await self._emit_v2_event("v2_reasoning", {"content": llm_raw}, stream_callback)
719
+ if self.memory:
720
+ self.memory.add_session(
721
+ session_id=context.session_id,
722
+ role="assistant",
723
+ content=llm_raw,
724
+ )
725
+ break
726
+ else:
727
+ # 纯文本也失败了,走下面的通用错误处理
728
+ _llm_error = response.error or ""
729
+ logger.error(f"[{task_id}] 纯文本重试也失败: {_llm_error}")
730
+
696
731
  # 其他 LLM 错误
697
732
  error_msg = f"LLM 调用失败: {response.error}"
698
733
  context.working_memory["final_response"] = error_msg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.16.13",
3
+ "version": "1.16.14",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
@@ -43,4 +43,4 @@
43
43
  "python": ">=3.10",
44
44
  "node": ">=18"
45
45
  }
46
- }
46
+ }