feat: 定义 SessionManager 接口 + SessionConfigPatch 模型

This commit is contained in:
hhs
2026-06-13 15:24:07 +08:00
parent 688e13a491
commit 6b8bd3c554
2 changed files with 69 additions and 0 deletions

View File

@@ -21,6 +21,26 @@ func DefaultConfig() SessionConfig {
return SessionConfig{TTSEnabled: true, DetailLevel: "low", Language: "zh-CN"}
}
// SessionConfigPatch 会话配置增量更新(指针字段表示"未传则不更新")。
type SessionConfigPatch struct {
TTSEnabled *bool `json:"tts_enabled,omitempty"`
DetailLevel *string `json:"detail_level,omitempty"`
Language *string `json:"language,omitempty"`
}
// Apply 将 patch 中的非 nil 字段覆盖到 cfg。
func (p SessionConfigPatch) Apply(cfg *SessionConfig) {
if p.TTSEnabled != nil {
cfg.TTSEnabled = *p.TTSEnabled
}
if p.DetailLevel != nil {
cfg.DetailLevel = *p.DetailLevel
}
if p.Language != nil {
cfg.Language = *p.Language
}
}
// Message 对话消息。
type Message struct {
Role string `json:"role"` // "user" | "assistant"