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
@@ -110,6 +110,17 @@ type Config struct {
|
||||
// Awakening carries the persona-level override (design §3). Zero = no
|
||||
// override.
|
||||
Awakening Awakening
|
||||
// L3Enabled turns on the model-assisted intent layer (design/14 §2.2 L3;
|
||||
// 裁决 14.4.4). It is off by default: the layer costs one model call per
|
||||
// undecided turn, so it must be asked for explicitly. When false the
|
||||
// classifier is never consulted, whatever L3Classifier holds.
|
||||
L3Enabled bool
|
||||
// L3Classifier is the model-assisted classifier the L3 layer consults when
|
||||
// L3Enabled is true. Nil keeps the layer silent.
|
||||
L3Classifier IntentClassifier
|
||||
// L3CacheTTL is how long a verdict for identical turn text is reused (裁决
|
||||
// 14.4.4 的 L3 输出缓存). Zero or negative disables reuse.
|
||||
L3CacheTTL time.Duration
|
||||
}
|
||||
|
||||
// Input is everything Decide needs to classify one round (design §4).
|
||||
@@ -140,10 +151,13 @@ type Input struct {
|
||||
type Option func(*Decider)
|
||||
|
||||
// Decider is the awakened-capacity decision engine. It is immutable after New
|
||||
// and safe for concurrent Decide calls.
|
||||
// and safe for concurrent Decide calls (the L3 cache is mutex-guarded).
|
||||
type Decider struct {
|
||||
cfg Config
|
||||
log *slog.Logger
|
||||
// l3cache is the model-assisted intent layer's classifier + verdict cache.
|
||||
// Nil when the layer is off, which is the default (裁决 14.4.4).
|
||||
l3cache *l3Cache
|
||||
}
|
||||
|
||||
// sourcedLog returns a logger tagged with the module source (project rule §10),
|
||||
@@ -175,6 +189,9 @@ func New(cfg Config, opts ...Option) *Decider {
|
||||
}
|
||||
d := &Decider{cfg: cfg}
|
||||
d.log = sourcedLog(nil)
|
||||
if cfg.L3Enabled {
|
||||
d.l3cache = newL3Cache(cfg.L3Classifier, cfg.L3CacheTTL)
|
||||
}
|
||||
for _, opt := range opts {
|
||||
if opt != nil {
|
||||
opt(d)
|
||||
@@ -196,7 +213,7 @@ func (d *Decider) Decide(ctx context.Context, in Input) Decision {
|
||||
if !d.cfg.Enabled {
|
||||
return Decision{State: in.CurrentState, AllowedTools: append([]string(nil), in.AllToolNames...)}
|
||||
}
|
||||
state, conf, tool := d.intent(in)
|
||||
state, conf, tool := d.intent(ctx, in)
|
||||
j := judgmentFor(in, state, conf, tool)
|
||||
state, conf = d.applyAwakening(state, conf, in)
|
||||
allowed := d.allowedTools(state, in.AllToolNames)
|
||||
|
||||
Reference in new issue
Block a user