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:
@@ -0,0 +1,51 @@
|
||||
package subsession
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/yourname/cyrene-ai/ai-core/internal/llm"
|
||||
"github.com/yourname/cyrene-ai/ai-core/internal/model"
|
||||
"github.com/yourname/cyrene-ai/ai-core/internal/persona"
|
||||
)
|
||||
|
||||
// Provider 子会话提供者接口
|
||||
// 每种子会话类型实现此接口
|
||||
type Provider interface {
|
||||
// Type 返回子会话类型标识
|
||||
Type() model.SubSessionType
|
||||
|
||||
// CanHandle 判断是否需要为此消息创建子会话
|
||||
CanHandle(ctx context.Context, intent *model.IntentResult, userMessage string) bool
|
||||
|
||||
// Priority 返回优先级 (数字越小优先级越高)
|
||||
Priority() int
|
||||
|
||||
// CreateContext 创建子会话的 LLM 上下文
|
||||
// 不包含对话历史(历史由 Orchestrator 统一管理)
|
||||
CreateContext(ctx context.Context, params CreateContextParams) ([]model.LLMMessage, error)
|
||||
|
||||
// Timeout 返回此子会话的超时时间
|
||||
Timeout() time.Duration
|
||||
|
||||
// Execute 执行子会话逻辑,返回结果
|
||||
// 子会话可以调用 LLM、执行工具调用等
|
||||
Execute(ctx context.Context, subCtx []model.LLMMessage) (*model.SubSessionResult, error)
|
||||
}
|
||||
|
||||
// CreateContextParams 创建上下文参数
|
||||
type CreateContextParams struct {
|
||||
UserID string
|
||||
SessionID string
|
||||
UserMessage string
|
||||
PersonaConfig *persona.PersonaConfig
|
||||
DeviceContext string // IoT 设备状态文本
|
||||
Intent *model.IntentResult
|
||||
Nickname string // 用户昵称
|
||||
}
|
||||
|
||||
// LLMClient LLM 调用接口(避免循环依赖)
|
||||
type LLMClient interface {
|
||||
Chat(ctx context.Context, messages []model.LLMMessage) (*model.LLMResponse, error)
|
||||
ChatWithTools(ctx context.Context, messages []model.LLMMessage, tools []llm.OpenAITool) (*model.LLMResponse, error)
|
||||
}
|
||||
Reference in New Issue
Block a user