后端: 1. AIHub 模型分级从 Worker/Strategist 两级重构为 Lite/Pro/Max 三级 - AIHub 结构体从 Worker + Strategist 改为 Lite + Pro + Max,分别对应轻量(标题生成)、标准(Chat 路由/闲聊/交付总结)、高能力(Plan 规划/Execute ReAct)三个能力层级 - config.example.yaml 新增 liteModel / proModel / maxModel 三个模型配置项,替代原 workerModel / strategistModel - 启动层 InitEino 改为创建三个独立模型实例,抽取公共 baseURL 和 apiKey 减少重复 - pickChatModel 统一返回 Pro 模型,旧 strategist 参数不再生效;pickTitleModel 从 Worker 切到 Lite - runNewAgentGraph 按 Plan/Execute→Max、Chat/Deliver→Pro 分级注入;Graph 出错回退也切到 Pro - Memory 模块初始化从 Worker 改为 Pro 2. Plan 节点从"两阶段评估"简化为"单轮深度规划",thinking 开关改为全配置化 - 移除 Phase 1(快速评估 1600 token)+ Phase 2(深度规划 3200 token)的两轮调用逻辑,改为单轮不限 token 深度规划 - PlanDecision 移除 need_thinking 字段,prompt 规则和 JSON contract 同步删除该字段 - 各节点(Plan / Execute / Deliver)thinking 开关从硬编码改为从 AgentGraphDeps 读取,由 config.yaml 的 agent.thinking 段按节点注入 - 新增 agent.thinking 配置段(plan / execute / deliver / memory 四个独立布尔开关),config.example.yaml 补齐默认值 - 新增 resolveThinkingMode 公共函数,plan / execute / deliver 和 memory 决策/抽取链路统一使用 3. Memory 模块 LLM 调用支持 thinking 开关 - Config 新增 LLMThinking 字段,config_loader 从 agent.thinking.memory 读取 - LLMDecisionOrchestrator.Compare 和 LLMWriteOrchestrator.ExtractFacts 的 thinking 模式从硬编码 Disabled 改为读取配置 前端: 1. 移除助手输入区模型选择器及全部偏好持久化逻辑 - 删除 ModelType 类型、selectedModel ref、MODEL_PREFERENCE_STORAGE_KEY 常量 - 删除 isModelType / loadModelPreferenceMap / persistModelPreferenceMap / savePreferredModel / resolvePreferredModel / applyPreferredModelForConversation 六个函数及 modelPreferenceMap ref - 删除 selectedModel watch 监听、发送消息时的 savePreferredModel 调用、切会话时的 applyPreferredModelForConversation 调用、会话迁移时的模型偏好迁移 - fetchChatStream 的 model 参数硬编码为 'worker' - 删除模板中"模型"下拉选择器(标准/策略)及对应的全局样式 .assistant-model-select-panel 2. 上下文窗口指示器简化为仅显示总占用 - ContextWindowMeter 移除 msg0~msg3 四段彩色分段逻辑(ContextSegment 接口、segments computed、v-for 渲染) - 进度条改为单一蓝色条,按 total/budget 比例填充;超预算时变红 - Tooltip 简化为仅显示"总计 X / 预算 Y(Z%)" 仓库:无
144 lines
4.6 KiB
Go
144 lines
4.6 KiB
Go
package model
|
||
|
||
import (
|
||
"strings"
|
||
"time"
|
||
)
|
||
|
||
const (
|
||
// MemoryReadModeLegacy 表示读取侧沿用“RAG 优先,失败再走 legacy”旧链路。
|
||
MemoryReadModeLegacy = "legacy"
|
||
// MemoryReadModeHybrid 表示读取侧走“结构化强约束 + 语义候选”混合链路。
|
||
MemoryReadModeHybrid = "hybrid"
|
||
|
||
// MemoryInjectRenderModeFlat 表示沿用扁平列表渲染。
|
||
MemoryInjectRenderModeFlat = "flat"
|
||
// MemoryInjectRenderModeTypedV2 表示按记忆类型分段渲染。
|
||
MemoryInjectRenderModeTypedV2 = "typed_v2"
|
||
|
||
// DefaultReadConstraintLimit 是 constraint 默认预算上限。
|
||
DefaultReadConstraintLimit = 5
|
||
// DefaultReadPreferenceLimit 是 preference 默认预算上限。
|
||
DefaultReadPreferenceLimit = 5
|
||
// DefaultReadFactLimit 是 fact 默认预算上限。
|
||
DefaultReadFactLimit = 5
|
||
// DefaultReadTodoHintLimit 是 todo_hint 默认预算上限。
|
||
DefaultReadTodoHintLimit = 3
|
||
)
|
||
|
||
// Config 是记忆模块配置对象(Day1 首版)。
|
||
//
|
||
// 职责边界:
|
||
// 1. 只承载模块运行参数,不承载业务状态;
|
||
// 2. 允许启动期统一注入,避免业务层直接依赖配置中心。
|
||
type Config struct {
|
||
Enabled bool
|
||
RAGEnabled bool
|
||
|
||
ReadMode string
|
||
ReadConstraintLimit int
|
||
ReadPreferenceLimit int
|
||
ReadFactLimit int
|
||
ReadTodoHintLimit int
|
||
InjectRenderMode string
|
||
|
||
ExtractPrompt string
|
||
DecisionPrompt string
|
||
|
||
Threshold float64
|
||
EnableReranker bool
|
||
|
||
LLMTemperature float64
|
||
LLMTopP float64
|
||
|
||
JobMaxRetry int
|
||
WorkerPollEvery time.Duration
|
||
WorkerClaimBatch int
|
||
|
||
// 决策层配置。
|
||
// 说明:
|
||
// 1. DecisionEnabled 控制是否启用"召回→比对→汇总"决策流程;
|
||
// 2. 默认关闭,旧路径完全保留,回滚无风险;
|
||
// 3. DecisionFallbackMode 仅在决策流程整体报错时生效,不影响单条 LLM 比对失败(单条失败视为 unrelated)。
|
||
DecisionEnabled bool
|
||
DecisionCandidateTopK int // Milvus 语义召回候选数上限
|
||
DecisionCandidateMinScore float64 // Milvus 语义召回最低相似度
|
||
DecisionFallbackMode string // "legacy_add"(退回旧路径直接新增)/ "drop"(丢弃)
|
||
WriteMode string // "legacy"(旧路径)/ "decision"(决策流程),仅 DecisionEnabled=true 时生效
|
||
|
||
// 写入置信度阈值。
|
||
// 说明:
|
||
// 1. 抽取结果 confidence 低于此值直接丢弃,不做入库;
|
||
// 2. 默认 0.5,与"守门员"prompt 的 confidence>=0.5 输出规则配合;
|
||
// 3. fallback 路径 confidence 设为 0.45,低于默认阈值,LLM 不可用时不写入。
|
||
WriteMinConfidence float64
|
||
|
||
// 记忆模块 LLM 调用是否开启 thinking,由 config.yaml 的 agent.thinking.memory 注入。
|
||
LLMThinking bool
|
||
}
|
||
|
||
// NormalizeReadMode 统一读取模式字符串。
|
||
func NormalizeReadMode(mode string) string {
|
||
switch strings.ToLower(strings.TrimSpace(mode)) {
|
||
case MemoryReadModeHybrid:
|
||
return MemoryReadModeHybrid
|
||
default:
|
||
return MemoryReadModeLegacy
|
||
}
|
||
}
|
||
|
||
// NormalizeInjectRenderMode 统一注入渲染模式字符串。
|
||
func NormalizeInjectRenderMode(mode string) string {
|
||
switch strings.ToLower(strings.TrimSpace(mode)) {
|
||
case MemoryInjectRenderModeTypedV2:
|
||
return MemoryInjectRenderModeTypedV2
|
||
default:
|
||
return MemoryInjectRenderModeFlat
|
||
}
|
||
}
|
||
|
||
// EffectiveReadConstraintLimit 返回 constraint 生效预算。
|
||
func (c Config) EffectiveReadConstraintLimit() int {
|
||
return normalizePositiveLimit(c.ReadConstraintLimit, DefaultReadConstraintLimit)
|
||
}
|
||
|
||
// EffectiveReadPreferenceLimit 返回 preference 生效预算。
|
||
func (c Config) EffectiveReadPreferenceLimit() int {
|
||
return normalizePositiveLimit(c.ReadPreferenceLimit, DefaultReadPreferenceLimit)
|
||
}
|
||
|
||
// EffectiveReadFactLimit 返回 fact 生效预算。
|
||
func (c Config) EffectiveReadFactLimit() int {
|
||
return normalizePositiveLimit(c.ReadFactLimit, DefaultReadFactLimit)
|
||
}
|
||
|
||
// EffectiveReadTodoHintLimit 返回 todo_hint 生效预算。
|
||
func (c Config) EffectiveReadTodoHintLimit() int {
|
||
return normalizePositiveLimit(c.ReadTodoHintLimit, DefaultReadTodoHintLimit)
|
||
}
|
||
|
||
// EffectiveReadMode 返回生效读取模式。
|
||
func (c Config) EffectiveReadMode() string {
|
||
return NormalizeReadMode(c.ReadMode)
|
||
}
|
||
|
||
// EffectiveInjectRenderMode 返回生效渲染模式。
|
||
func (c Config) EffectiveInjectRenderMode() string {
|
||
return NormalizeInjectRenderMode(c.InjectRenderMode)
|
||
}
|
||
|
||
// TotalReadBudget 返回四类记忆的总预算上限。
|
||
func (c Config) TotalReadBudget() int {
|
||
return c.EffectiveReadConstraintLimit() +
|
||
c.EffectiveReadPreferenceLimit() +
|
||
c.EffectiveReadFactLimit() +
|
||
c.EffectiveReadTodoHintLimit()
|
||
}
|
||
|
||
func normalizePositiveLimit(value int, defaultValue int) int {
|
||
if value <= 0 {
|
||
return defaultValue
|
||
}
|
||
return value
|
||
}
|