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:
@@ -28,6 +28,24 @@ func (h *Handler) loadVoiceConfig(ctx context.Context) voice.Config {
|
||||
return c.DecryptFromStore()
|
||||
}
|
||||
|
||||
// resolveJarvis 解析某用户**有效**的 JARVIS 设定:火山配置 + 助手名 + 人设。
|
||||
// - 火山配置:用户自带豆包齐全(Enabled)→ 用用户的;否则回落系统配置(voice_config)。
|
||||
// - 名字/人设:来自用户的 UserJarvis 记录(可空,空则代码里再兜默认);与火山配置相互独立
|
||||
// (常见情形:多数用户不配自己的豆包、只改名字和人设)。
|
||||
func (h *Handler) resolveJarvis(ctx context.Context, uid string) (cfg voice.Config, name, persona string) {
|
||||
cfg = h.loadVoiceConfig(ctx) // 系统兜底
|
||||
j := h.db.GetUserJarvis(ctx, uid)
|
||||
if j == nil {
|
||||
return cfg, "", ""
|
||||
}
|
||||
name, persona = j.Name, j.Persona
|
||||
user := voice.Config{APIKey: j.APIKey, ASRResourceID: j.ASRResourceID, TTSResourceID: j.TTSResourceID, TTSVoiceType: j.TTSVoiceType}.DecryptFromStore()
|
||||
if user.Enabled() { // 用户自带豆包齐全 → 整套用用户的(key 与 resource-id 必须同账号,不混用)
|
||||
cfg = user
|
||||
}
|
||||
return cfg, name, persona
|
||||
}
|
||||
|
||||
// AdminGetVoiceConfig: GET /api/v1/admin/voice —— 回显语音配置(api_key 明文,RequireAdmin 已拦)。
|
||||
func (h *Handler) AdminGetVoiceConfig(c *gin.Context) {
|
||||
cfg := h.loadVoiceConfig(c.Request.Context())
|
||||
|
||||
Reference in New Issue
Block a user