refactor: cockpit AgentIO适配gateway统一入口

This commit is contained in:
ymq 2026-08-15 10:02:54 +08:00
parent d36d5ed4f6
commit c29f676cb3

View File

@ -63,24 +63,17 @@ if action == 'send_message':
ctx['name'] = getattr(proj_recs[0], 'name', '') ctx['name'] = getattr(proj_recs[0], 'name', '')
ctx['pipeline_id'] = getattr(proj_recs[0], 'pipeline_id', '') or '' ctx['pipeline_id'] = getattr(proj_recs[0], 'pipeline_id', '') or ''
# ── 加载 v2 引擎 ── # ── 走 gateway 统一入口(Web AgentIO 通道)──
from pipeline_core.agent_config import load_agent_config from pipeline_service.gateway import get_gateway
from pipeline_service.agent_loop_v2 import AgentExecutor gateway = get_gateway()
config = await load_agent_config(pipeline_id=ctx['pipeline_id'], project_id=ctx['pid'])
executor = AgentExecutor(
config=config,
project_id=ctx['pid'],
user_id=uid,
)
async def agent_stream(): async def agent_stream():
# 项目上下文 # 项目上下文
if ctx['name']: if ctx['name']:
yield json.dumps({"reasoning_content": "项目: " + ctx['name'] + "\n"}, ensure_ascii=False) + '\n' yield json.dumps({"reasoning_content": "项目: " + ctx['name'] + "\n"}, ensure_ascii=False) + '\n'
# 运行 AgentExecutor(输出 content 流式格式,供前端 AgentIO→AgentOut 渲染) # 运行 gateway(输出 content 流式格式,供前端 AgentIO→AgentOut 渲染)
async for chunk in executor.run(prompt): async for chunk in gateway.run_message("web", uid, prompt):
data = json.loads(chunk) data = json.loads(chunk)
t = data.get('type', '') t = data.get('type', '')