feat(agent): 开发产线多会话 TabPanel + 新建会话按钮
This commit is contained in:
parent
6826d49f01
commit
03745f38e9
@ -8,7 +8,19 @@
|
||||
"subwidgets": [
|
||||
{"widgettype": "Title2", "options": {"text": "智能助手"}},
|
||||
{"widgettype": "Text", "options": {"text": "通用 AI 对话能力", "cfontsize": 0.9, "color": "#94a3b8"}},
|
||||
{"widgettype": "Filler"}
|
||||
{"widgettype": "Filler"},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
"id": "new_session_btn",
|
||||
"options": {"label": "+ 新建会话", "css": "small"},
|
||||
"binds": [{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var tp=bricks.getWidgetById('session_tabs',bricks.app);if(!tp)return;var sid='s'+Date.now()+'_'+Math.floor(Math.random()*100000);var n=tp.opts.items.length+1;tp.open_tab({name:'session_'+sid,label:'会话 '+n,removable:true,content:{widgettype:'AgentIO',options:{css:'filler',url:'/pipeline_core/api/agent_chat.dspy?session_id='+sid,model_dataurl:'/pipeline_core/api/agent_model_options.dspy',model_cwidth:14,placeholder:'输入你的需求...'}}});"
|
||||
}]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -17,14 +29,30 @@
|
||||
"options": {"url": "{{entire_url('/pipeline_core/api/agent_menus.dspy')}}", "method": "GET"}
|
||||
},
|
||||
{
|
||||
"widgettype": "AgentIO",
|
||||
"id": "chat_io",
|
||||
"widgettype": "TabPanel",
|
||||
"id": "session_tabs",
|
||||
"options": {
|
||||
"css": "filler",
|
||||
"url": "/pipeline_core/api/agent_chat.dspy",
|
||||
"model_dataurl": "/pipeline_core/api/agent_model_options.dspy",
|
||||
"model_cwidth": 14,
|
||||
"placeholder": "输入你的需求..."
|
||||
"width": "100%",
|
||||
"height": "100%",
|
||||
"tab_pos": "top",
|
||||
"items": [
|
||||
{
|
||||
"name": "session_default",
|
||||
"label": "会话 1",
|
||||
"removable": false,
|
||||
"content": {
|
||||
"widgettype": "AgentIO",
|
||||
"options": {
|
||||
"css": "filler",
|
||||
"url": "/pipeline_core/api/agent_chat.dspy?session_id=default",
|
||||
"model_dataurl": "/pipeline_core/api/agent_model_options.dspy",
|
||||
"model_cwidth": 14,
|
||||
"placeholder": "输入你的需求..."
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -74,13 +74,16 @@ if action == 'send_message':
|
||||
if not uid:
|
||||
uid = 'user-01' # 测试兼容
|
||||
|
||||
# ── 会话内唯一标识(web 多 tab 独立会话):前端每个 tab 传独立 session_id ──
|
||||
session_id = (params_kw or {}).get('session_id', '') or ''
|
||||
|
||||
# ── 走 gateway 统一入口(Web AgentIO 通道)──
|
||||
from pipeline_service.gateway import get_gateway
|
||||
gateway = get_gateway()
|
||||
|
||||
async def agent_stream():
|
||||
_base = entire_url("/")
|
||||
async for chunk in gateway.run_message("web", uid, prompt, base_url=_base):
|
||||
async for chunk in gateway.run_message("web", uid, prompt, base_url=_base, session_id=session_id):
|
||||
data = json.loads(chunk)
|
||||
t = data.get('type', '')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user