diff --git a/server/corpus-agent/server.py b/server/corpus-agent/server.py index fe27dc9..912c8be 100644 --- a/server/corpus-agent/server.py +++ b/server/corpus-agent/server.py @@ -592,8 +592,8 @@ async def chat_with_agent(req: ChatRequest, token: str = Query(...)): if event_type == SSE_TYPE_PERSONA: yield f"data: {json.dumps({'type': SSE_TYPE_PERSONA, 'persona': data.get('persona', ''), 'fromDB': data.get('fromDB', False)})}\n\n" - # 转发 token 事件 - elif event_type == SSE_TYPE_TOKEN: + # 转发 token 事件(兼容Portal原始格式:{"token":"铸"} 无type字段) + if event_type == SSE_TYPE_TOKEN or (not event_type and "token" in data): token_text = data.get("token", "") full_response += token_text yield f"data: {json.dumps({'type': SSE_TYPE_TOKEN, 'token': token_text})}\n\n"