myagent-ai 1.16.14 → 1.16.15

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/web/api_server.py +34 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.16.14",
3
+ "version": "1.16.15",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
package/web/api_server.py CHANGED
@@ -827,6 +827,8 @@ class ApiServer:
827
827
  try:
828
828
  agent_cfg = self._read_agent_config(agent_path)
829
829
  model_chain = self._build_model_chain(agent_cfg, agent_path)
830
+ # [v1.16.14] 有图片时,优先使用支持 vision 的模型
831
+ model_chain = self._reorder_model_chain_for_images(model_chain, bool(user_images))
830
832
  logger.info(f"[{session_id}] model_chain={'有' if model_chain else '无'}, llm={'有' if self.core.llm else '无'}")
831
833
 
832
834
  task_plan_context = self._build_task_plan_context(agent_path, chat_mode, message, session_id=session_id)
@@ -3572,6 +3574,38 @@ class ApiServer:
3572
3574
 
3573
3575
  return chain
3574
3576
 
3577
+ def _reorder_model_chain_for_images(self, model_chain: list[dict], has_images: bool) -> list[dict]:
3578
+ """[v1.16.14] 当消息包含图片时,将支持 vision 的模型优先排列
3579
+
3580
+ 检查每个模型的 input_modes 字段,如果包含 "image",则优先使用。
3581
+ 如果都没有 vision 能力,则保持原序(会触发 main_agent 的纯文本降级)。
3582
+ """
3583
+ if not has_images or not model_chain:
3584
+ return model_chain
3585
+
3586
+ # 从 models_library 获取每个模型的 input_modes
3587
+ vision_models = []
3588
+ text_only_models = []
3589
+ for mc in model_chain:
3590
+ mc_id = mc.get("id", "")
3591
+ input_modes = ["text"] # 默认
3592
+ if mc_id:
3593
+ for me in self.core.config.models_library:
3594
+ if me.id == mc_id:
3595
+ input_modes = me.input_modes or ["text"]
3596
+ break
3597
+ if "image" in input_modes:
3598
+ vision_models.append(mc)
3599
+ else:
3600
+ text_only_models.append(mc)
3601
+
3602
+ if vision_models:
3603
+ logger.info(f"消息含图片,优先使用 vision 模型: {[m.get('name', m.get('model')) for m in vision_models]}")
3604
+ return vision_models + text_only_models
3605
+ else:
3606
+ logger.info("消息含图片,但模型链中无 vision 模型,将尝试当前主模型(失败后自动降级纯文本)")
3607
+ return model_chain
3608
+
3575
3609
  async def _try_model_chain(self, model_chain: list[dict], message: str, session_id: str,
3576
3610
  agent_path: str = None, agent_system_prompt: str = None,
3577
3611
  chat_mode: str = "") -> str: