feat(voice): 每用户 JARVIS——自定义名字/人设 + 自带豆包配置回落 + 语音不串主记忆
把 JARVIS 做成每用户独立:名字(你叫JARVIS别人叫星期五)、人设(与主偏好记忆分开)、 可自带豆包配置(齐全则用用户的,否则回落系统)。 - store/user_jarvis.go: sundynix_user_jarvis(user_id唯一;name/persona/火山creds,APIKey密文) + Get/Save(upsert) + AutoMigrate 注册 - voice_config.go resolveJarvis(uid): 火山配置用户优先系统兜底 + 取名字/人设 - voice_task.go: voiceSystemPrompt(name,persona)——简短是硬基线,名字/语气由用户定; buildVoiceGraph 带 name+persona;voice.go 会话升级时按用户解析 - dispatcher compose_compiler: 语音任务(useVoice)不拉主偏好记忆,改用用户 persona(保留短期历史) - jarvis.go + 路由: GET/PUT /api/v1/me/jarvis(用户级,api_key 脱敏/留空沿用) 真机验证:设 name=星期五+干净人设→语音答"我是星期五…"(自称新名、无糙话、4.4s), has_own_voice=false 用系统豆包。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
// buildVoiceGraph 的产物必须是 dsl.ParseAndAssemble 能吃下的合法图,且带上转写文本。
|
||||
func TestBuildVoiceGraph_Valid(t *testing.T) {
|
||||
const q = "帮我查一下明天上海的天气"
|
||||
raw := buildVoiceGraph(q)
|
||||
raw := buildVoiceGraph(q, "", "")
|
||||
|
||||
// 1) 能通过 DSL 解析与拓扑校验(与 HTTP SubmitTask 同一条解析)。
|
||||
task, err := dsl.ParseAndAssemble(raw)
|
||||
@@ -65,8 +65,39 @@ func TestBuildVoiceGraph_Valid(t *testing.T) {
|
||||
|
||||
// 空转写不该组图触发(提交侧兜底:submitVoiceTask 空转写返错)——这里只校验组图函数对空串仍产出结构。
|
||||
func TestBuildVoiceGraph_EmptyStillStructured(t *testing.T) {
|
||||
raw := buildVoiceGraph("")
|
||||
raw := buildVoiceGraph("", "", "")
|
||||
if _, err := dsl.ParseAndAssemble(raw); err != nil {
|
||||
t.Fatalf("空转写图仍应结构合法: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 用户自定义名字 + 人设应注入到 agent 节点的 system 里(名字替 JARVIS、人设附上)。
|
||||
func TestBuildVoiceGraph_NamePersonaInjected(t *testing.T) {
|
||||
raw := buildVoiceGraph("你好", "星期五", "简洁专业不说脏话")
|
||||
var g struct {
|
||||
Nodes []struct {
|
||||
Kind string `json:"kind"`
|
||||
Config map[string]any `json:"config"`
|
||||
} `json:"nodes"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &g); err != nil {
|
||||
t.Fatalf("反解失败: %v", err)
|
||||
}
|
||||
for _, n := range g.Nodes {
|
||||
if n.Kind != "agent" {
|
||||
continue
|
||||
}
|
||||
sys, _ := n.Config["system"].(string)
|
||||
if !strings.Contains(sys, "星期五") {
|
||||
t.Errorf("system 未含自定义名字「星期五」: %q", sys)
|
||||
}
|
||||
if strings.Contains(sys, "JARVIS") {
|
||||
t.Errorf("有自定义名字时不应再出现 JARVIS: %q", sys)
|
||||
}
|
||||
if !strings.Contains(sys, "简洁专业不说脏话") {
|
||||
t.Errorf("system 未含用户人设: %q", sys)
|
||||
}
|
||||
return
|
||||
}
|
||||
t.Fatal("没找到 agent 节点")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user