mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
feat: webui chat 接口支持设备身份(device_id/device_name)
- handleChat body 增加 device_id/device_name 可选字段
- 来源编码: 带设备时 webui/{device_id}(agent 可见来源), 无设备保持 webui(兼容)
- injectSourceContext: 检测 device_id 时注入「当前输入来自设备[名](id)」上下文
- 验证: 带 device_id=gui-pc-002 消息 agent 正确回答来源客厅电脑; 无 device_id 兼容
This commit is contained in:
@ -70,6 +70,14 @@ func (a *Agent) injectSourceContext(stageCtx *sdk.StageContext, evt *agentIO.Inp
|
||||
channel = source
|
||||
}
|
||||
content := fmt.Sprintf("当前输入来源: %s;默认输出通道: %s。", source, channel)
|
||||
// 来源含设备身份(webui/{device_id})时补充设备名,便于 agent 区分多设备输入
|
||||
if devID, _ := evt.Payload["device_id"].(string); devID != "" {
|
||||
devName, _ := evt.Payload["device_name"].(string)
|
||||
if devName == "" {
|
||||
devName = devID
|
||||
}
|
||||
content = fmt.Sprintf("当前输入来自设备[%s](%s);默认输出通道: %s。", devName, devID, channel)
|
||||
}
|
||||
if flag, _ := evt.Payload["interrupt"].(bool); flag {
|
||||
content = fmt.Sprintf("这是一条打断输入。来源: %s;默认输出通道: %s。", source, channel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user