diff --git a/wwwroot/api/cockpit_chat_v2.dspy b/wwwroot/api/cockpit_chat_v2.dspy index f5e8930..1b5bd25 100644 --- a/wwwroot/api/cockpit_chat_v2.dspy +++ b/wwwroot/api/cockpit_chat_v2.dspy @@ -63,6 +63,7 @@ if action == 'send_message': # 2. 收集 (绝对路径, 文件名),稍后复制进项目根目录,让会话 agent 的 read_file 能找到 file_ctx = '' _uploads = [] # [(src_abs, filename)] + _img_uploads = [] # 图片上传(原生视觉,2026-09-10):不进文本上下文,走多模态注入 _fval = (params_kw or {}).get('file') _fpaths = _fval if isinstance(_fval, list) else ([_fval] if _fval else []) for _fp in _fpaths: @@ -70,6 +71,13 @@ if action == 'send_message': _abs = FileStorage().realPath(_fp) _name = os.path.basename(_abs) _uploads.append((_abs, _name)) + from pipeline_core.upload_tools import is_image + if is_image(_name): + # 图片走原生视觉(gateway.build_image_parts 构造多模态 parts), + # 不进文本上下文——避免「二进制无法读取」与「图片已注入」矛盾提示。 + # 仍随 copy_uploads_to_project 落盘项目根(agent 可再用 i2t 处理) + _img_uploads.append((_abs, _name)) + continue _txt = _extract_text(_abs, _name) if _txt: file_ctx += f"【文件 {_name} 内容】\n{_txt}\n\n" @@ -106,8 +114,16 @@ if action == 'send_message': if file_ctx or _saved_files: _loc = '' if _saved_files: - _loc = "文件已保存到项目根目录(" + _pdir + "),可用 read_file 直接读取:\n" - _loc += "\n".join(" - " + n for n, _ in _saved_files) + "\n\n" + from pipeline_core.upload_tools import is_image as _isimg + _txt_saved = [(n, pth) for n, pth in _saved_files if not _isimg(n)] + _img_saved = [(n, pth) for n, pth in _saved_files if _isimg(n)] + if _txt_saved: + _loc = "文件已保存到项目根目录(" + _pdir + "),可用 read_file 直接读取:\n" + _loc += "\n".join(" - " + n for n, _ in _txt_saved) + "\n\n" + if _img_saved: + # 图片 read_file 读不了——多模态已注入(或超限被拒),路径仅供 i2t 等后续处理 + _loc += "图片已保存到项目根目录(read_file 不支持读图;图片内容已按多模态注入,如需再次处理可用 invoke_model i2t):\n" + _loc += "\n".join(" - " + n for n, _ in _img_saved) + "\n\n" prompt = "用户本次上传了以下文件:\n" + _loc + file_ctx + "\n用户指令:" + prompt # ── 走 gateway 统一入口(Web AgentIO 通道)── @@ -125,7 +141,7 @@ if action == 'send_message': # 运行 gateway(输出 content 流式格式,供前端 AgentIO→AgentOut 渲染)。 # pipeline_id 声明本产线:激活会话项目跨产线隔离——残留的投标/商机项目 # 不会劫持开发产线驾驶舱(否则全局兜底指向跨产线项目时整会话变投标大脑)。 - async for chunk in gateway.run_message("web", uid, prompt, model_id=model_id, session_id=session_id, pipeline_id='sdlc_general'): + async for chunk in gateway.run_message("web", uid, prompt, model_id=model_id, session_id=session_id, pipeline_id='sdlc_general', image_paths=_img_uploads or None): data = json.loads(chunk) t = data.get('type', '')