myagent-ai 1.16.14 → 1.16.16
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.
- package/package.json +1 -1
- package/web/api_server.py +35 -1
package/package.json
CHANGED
package/web/api_server.py
CHANGED
|
@@ -150,7 +150,7 @@ def _agent_color(name: str) -> str:
|
|
|
150
150
|
class ApiServer:
|
|
151
151
|
def __init__(self, app_core):
|
|
152
152
|
self.core = app_core
|
|
153
|
-
self.app = web.Application()
|
|
153
|
+
self.app = web.Application(client_max_size=50 * 1024 * 1024) # 50MB,支持大文件上传(PDF/Word等)
|
|
154
154
|
self._exec_progress: dict = {}
|
|
155
155
|
# Wrap the executor to track progress in real-time (deferred to initialize())
|
|
156
156
|
self._executor_wrapped = False
|
|
@@ -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:
|