feat: Agent 记忆系统替代预设功能,全功能协调运作
核心改造: - 取消 Agent 预设(保留兼容),新增 AI Agent 记忆系统 - 自动提取 → 存储 → 检索 → 注入上下文的完整记忆闭环 - 记忆类型:事实/偏好/规则/事件,支持重要性评分和标签 新增文件: - services/memory-manager.ts: 记忆管理核心 - 关键词+标签+重要性加权检索 - 会话结束自动提取(LLM 驱动) - 去重检测、使用频率追踪 - components/memory-panel.ts: 记忆管理面板 UI 修改文件: - types.d.ts: 新增 MemoryEntry/MemorySearchResult 类型 - db/chat-db.ts: 升级 v2,新增 memories 存储 - input-area.ts: 对话流集成记忆检索+自动提取 - agent-engine.ts: Agent Loop 注入记忆上下文 - settings-modal.ts: 记忆开关设置 - main.ts: 记忆系统初始化 - index.html: 记忆设置面板 HTML - style.css: 记忆面板完整样式 功能协调: - 对话流: 记忆检索 → RAG 检索 → 系统提示词组合 → 流式对话 - Agent Loop: 记忆检索 → 系统提示词注入 → 工具调用循环 - 会话结束: 自动提取关键信息 → 存入记忆库 - 跨会话: 记忆持久化 IndexedDB,新对话自动召回相关记忆
This commit is contained in:
Vendored
+35
-2
@@ -116,7 +116,7 @@ export interface ChatSession {
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
// ── 预设类型 ──
|
||||
// ── 预设类型(v3.0 废弃,保留用于兼容)──
|
||||
|
||||
export interface Preset {
|
||||
id: string;
|
||||
@@ -131,6 +131,37 @@ export interface Preset {
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
// ── Agent 记忆系统类型 ──
|
||||
|
||||
export type MemoryType = 'fact' | 'preference' | 'rule' | 'episode';
|
||||
|
||||
export interface MemoryEntry {
|
||||
id: string;
|
||||
type: MemoryType;
|
||||
content: string;
|
||||
importance: number; // 1-10,越高越重要
|
||||
tags: string[]; // 用于快速匹配
|
||||
source?: string; // 来源描述(如会话标题)
|
||||
sessionId?: string; // 关联的会话 ID
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
lastUsedAt: number; // 最后一次被回忆的时间
|
||||
useCount: number; // 被回忆的次数
|
||||
}
|
||||
|
||||
export interface MemorySearchResult extends MemoryEntry {
|
||||
score: number; // 相关性得分
|
||||
}
|
||||
|
||||
export interface MemoryExtractionResult {
|
||||
entries: Array<{
|
||||
type: MemoryType;
|
||||
content: string;
|
||||
importance: number;
|
||||
tags: string[];
|
||||
}>;
|
||||
}
|
||||
|
||||
// ── 知识库类型 ──
|
||||
|
||||
export interface VectorCollection {
|
||||
@@ -250,7 +281,9 @@ export type StateKey =
|
||||
| 'presets'
|
||||
| 'activePresetId'
|
||||
| 'toolCallingEnabled'
|
||||
| 'runCommandEnabled';
|
||||
| 'runCommandEnabled'
|
||||
| 'memoryEnabled'
|
||||
| 'memoryEntries';
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
// Tool Calling 类型
|
||||
|
||||
Reference in New Issue
Block a user