feat: 第四轮大版本更新 — 修复4个严重Bug、2个UI Bug,实现自主思考重构与主-子会话架构
## 🐛 Bug 修复 - 修复前端对话无响应:消除 ChatContainer 中的双重 WebSocket 连接,优化 sendMessage 失败提示 - 修复 Memory-Service 数据库迁移失败:ai-core 和 memory-service 均添加 ALTER TABLE ADD COLUMN IF NOT EXISTS 模式演化 - 修复语音/STT 不可用:添加 MediaRecorder API 降级方案,修复 whisper-cli 输出文件名错误 - 修复仪表盘数据库按钮失效:补充按钮 ID 属性,重写 controlDB() 控制逻辑 ## 🎨 UI 修复 - 修正用户消息头像位置:从 flex-row-reverse 改为 justify-end - 移除空聊天列表的 emoji 占位图标 ## ✨ 新功能 - devtools 新增 STT 处理日志面板(环形缓冲区 + WebSocket 广播 + 可视化表格) - 新增 ADMIN_NICKNAME 环境变量,支持自定义管理员昵称 ## 🔧 改进 - 注册流程增加昵称必填字段(前后端同步) ## 🏗️ 架构重构 - 重构自主思考逻辑:从定时器轮询改为事件驱动(对话后触发 + 静默检测),优化提示词使其更自然人性化 - 实现主-子会话架构:新增 4 种子会话类型(general/memory/iot/knowledge),意图分析 → 并行分发 → 结果合成流程 ## 📄 新增文档 - docs/architecture/main-session-sub-session-design.md — 子会话架构设计文档
This commit is contained in:
@@ -95,6 +95,7 @@ type BuildParams struct {
|
||||
HistoryLimit int
|
||||
DeviceContext string // 注入的设备状态文本
|
||||
PendingThoughts []string // 待注入的后台思考
|
||||
Nickname string // 用户昵称 (昔涟对用户的称呼)
|
||||
}
|
||||
|
||||
// Build 构建发送给LLM的完整消息列表
|
||||
@@ -102,8 +103,13 @@ func (b *Builder) Build(ctx context.Context, params BuildParams) ([]model.LLMMes
|
||||
messages := []model.LLMMessage{}
|
||||
|
||||
// 1. 系统消息 —— 昔涟的人格Prompt
|
||||
// 使用传入的昵称,如果为空则回退到 userID
|
||||
userName := params.Nickname
|
||||
if userName == "" {
|
||||
userName = params.UserID
|
||||
}
|
||||
systemPrompt := params.Persona.BuildSystemPrompt(
|
||||
params.UserID,
|
||||
userName,
|
||||
1,
|
||||
)
|
||||
|
||||
@@ -222,13 +228,21 @@ func (b *Builder) loadHistory(_ context.Context, sessionID string, limit int) ([
|
||||
|
||||
// CacheMessage 缓存消息到会话历史(供chat handler在回复后调用)
|
||||
func (b *Builder) CacheMessage(sessionID string, role model.Role, content string) {
|
||||
if b.convStore == nil {
|
||||
return
|
||||
}
|
||||
b.convStore.AddMessage(sessionID, model.LLMMessage{
|
||||
Role: role,
|
||||
Content: content,
|
||||
})
|
||||
if b.convStore == nil {
|
||||
return
|
||||
}
|
||||
b.convStore.AddMessage(sessionID, model.LLMMessage{
|
||||
Role: role,
|
||||
Content: content,
|
||||
})
|
||||
}
|
||||
|
||||
// GetHistory 获取会话历史(供 Orchestrator 使用)
|
||||
func (b *Builder) GetHistory(sessionID string, limit int) []model.LLMMessage {
|
||||
if b.convStore == nil {
|
||||
return nil
|
||||
}
|
||||
return b.convStore.GetHistory(sessionID, limit)
|
||||
}
|
||||
|
||||
// InjectDeviceContext 将设备状态格式化为简洁的文本注入系统上下文
|
||||
|
||||
Reference in New Issue
Block a user