feat(model,capacity,vision,io): per-persona 路由 + 本地三级(默认关) + L3 分类 + OCR 独立模型 + image-crop 工具(裁决 03.4.1/03.4.3/14.4.1/14.4.4/14.4.5)
- 03.4.1:per-persona 路由载体选 models.json(组内新增 personaModels/personaProviders + 校验 + PersonaRoute()), Router/RuntimeLLM 快照绑定、loop 流式路径按该 turn 的 persona 路由;主步用路由结果、降级步钉自己的模型 - 03.4.3:本地第三级降级链(LLM_LOCAL_*,Configured() 含 Enabled ⇒ **默认关**),warn 标注来源 - 14.4.4:capacity 接入 L3(分类器接口 + TTL 缓存 + 严格 JSON 解析),CAPACITY_L3_ENABLED **默认 false** - 14.4.1:语义修正 —— group.multimodal 才是「主模型能否收图」(env 路径不再臆断),LLM_VISION_MODEL 只配视觉工具; vision/OCR 可各用不同模型;runtime 不再因有图抢路由(vision.Router 是唯一分层权威) - 14.4.5:新增 image-crop 工具(工具数 5→6,策略默认 owner-only),schema 支持按区域裁切 - 组合根:wire_runtime 读 group.Multimodal;capacity 装配拆出 wire_capacity.go(守 500 行) - 复核:`go build`/`go vet`/各包 `go test -count=1` 全绿;**6 条变异反证**先红后还原(含作者自查出的 2 条假阳性变异) - 未落:按 provider 的 thinking 开关(需 openai_encode.go/openai.go 文件面)、persona awakening(需 loader 文件面)
This commit is contained in:
1 parent
63e5b70e3d
commit
fa33c79e11
24 files changed
+1941
-122
No files matched your search
@@ -1,6 +1,11 @@
|
||||
// signals.go holds the intent layer vocabulary and the L1/L2/L3 layers; the
|
||||
// package doc lives in capacity.go.
|
||||
package capacity
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// defaultQuietTools is the companion-safe face (design §1): terminal + file edit
|
||||
// + memory/emotion companion. It is a function building the slice fresh so no
|
||||
@@ -16,12 +21,13 @@ func defaultAwakeTools() []string {
|
||||
}
|
||||
|
||||
// intent classifies the round. It runs L1 on the current turn, falls to L2 on
|
||||
// the recent context trend, and folds in the L4 learned-habit verdict (design §2.2)
|
||||
// at each layer: L4 may correct a decided result (boost / quiet→awake) or fill in
|
||||
// when L1/L2 are undecided. With no matching habit L4 is silent, so a turn with no
|
||||
// recall behaves exactly as before; otherwise the result stays conservative (低置信
|
||||
// still rests via applyAwakening).
|
||||
func (d *Decider) intent(in Input) (State, float64, string) {
|
||||
// the recent context trend, then to the model-assisted L3 layer when it is
|
||||
// enabled, and folds in the L4 learned-habit verdict (design §2.2) at each layer:
|
||||
// L4 may correct a decided result (boost / quiet→awake) or fill in when L1/L2/L3
|
||||
// are undecided. With no matching habit L4 is silent, so a turn with no recall
|
||||
// behaves exactly as before; otherwise the result stays conservative (低置信 still
|
||||
// rests via applyAwakening).
|
||||
func (d *Decider) intent(ctx context.Context, in Input) (State, float64, string) {
|
||||
if len(in.Messages) == 0 {
|
||||
return "", 0, ""
|
||||
}
|
||||
@@ -33,12 +39,44 @@ func (d *Decider) intent(in Input) (State, float64, string) {
|
||||
if s, c, t, ok := l2(in.Messages); ok {
|
||||
return d.mergeL4(s, c, t, l4s, l4c, l4t, l4ok)
|
||||
}
|
||||
if s, c, t, ok := d.l3(ctx, current); ok {
|
||||
return d.mergeL4(s, c, t, l4s, l4c, l4t, l4ok)
|
||||
}
|
||||
if l4ok {
|
||||
return l4s, l4c, l4t
|
||||
}
|
||||
return "", 0.3, "" // 拿不准 → conservative fallback
|
||||
}
|
||||
|
||||
// l3 runs the model-assisted intent layer (design/14 §2.2 L3; 裁决 14.4.4): the
|
||||
// configured classifier judges the current turn and its verdict is trusted only
|
||||
// at or above the wake threshold — a low-confidence verdict is treated as
|
||||
// undecided, so a hesitant model can never wake tools on its own. A classifier
|
||||
// error is reported and treated the same way. With the layer off this returns
|
||||
// ok=false immediately, leaving L1/L2/L4 behavior byte-identical.
|
||||
func (d *Decider) l3(ctx context.Context, current string) (State, float64, string, bool) {
|
||||
if d.l3cache == nil {
|
||||
return "", 0, "", false
|
||||
}
|
||||
j, err := d.l3cache.classify(ctx, current)
|
||||
if err != nil {
|
||||
d.log.Warn("capacity L3 classifier unavailable, keeping the conservative default", "error", err)
|
||||
return "", 0, "", false
|
||||
}
|
||||
if j.Confidence < d.cfg.MinConfidence {
|
||||
d.log.Debug("capacity L3 verdict below threshold, treated as undecided",
|
||||
"confidence", j.Confidence, "threshold", d.cfg.MinConfidence, "is_task", j.IsTask)
|
||||
return "", 0, "", false
|
||||
}
|
||||
if !j.IsTask {
|
||||
return StateQuiet, j.Confidence, "", true
|
||||
}
|
||||
if j.TaskKind == taskKindComplex {
|
||||
return StateFull, j.Confidence, inferTool(current), true
|
||||
}
|
||||
return StateAwake, j.Confidence, inferTool(current), true
|
||||
}
|
||||
|
||||
// l1 is the fast heuristic on the current turn (design §2.2 L1): a strong
|
||||
// action signal wakes (awake, or full for complex work); a clear companion
|
||||
// signal (weak + no task object) stays quiet; otherwise it is undecided and the
|
||||
|
||||
Reference in new issue
Block a user