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)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- 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:
AskaEth committed 2026-10-04 12:44:52 +08:00
1 parent 63e5b70e3d
commit fa33c79e11
24 files changed
+1941 -122

No files matched your search

+17 -4
View File
@@ -44,6 +44,19 @@ func (c *Chain) WithTokenBudget(groupMaxTokens, fallbackMaxTokens int) *Chain {
return c
}
// stepModel picks the model name for step idx of the chain. The primary step
// prefers the request's routed model — the per-persona / per-request decision the
// Router produced — over the group's configured model, so a routing decision is
// never silently discarded. Every fallback step pins its own configured model, so
// a degradation never re-sends the primary model name to a different endpoint
// (裁决 03.4.1: per-persona 路由必须真的落到请求上).
func stepModel(req Request, idx int, configured string) string {
if idx == 0 && req.Model != "" {
return req.Model
}
return configured
}
// applyBudget resolves the effective MaxTokens for step idx, honoring the
// precedence: an explicit Request.MaxTokens > the group's MaxTokens > the
// last-resort LLM_FALLBACK_MAX_TOKENS > the adapter default. The last-resort
@@ -85,8 +98,8 @@ func (c *Chain) Chat(ctx context.Context, req Request, opts Options) (Response,
var lastErr error
for i, s := range c.steps {
stepReq := c.applyBudget(req, i)
if s.Model != "" {
stepReq.Model = s.Model
if m := stepModel(req, i, s.Model); m != "" {
stepReq.Model = m
}
resp, err := s.Adapter.Chat(ctx, stepReq, opts)
if err == nil {
@@ -108,8 +121,8 @@ func (c *Chain) ChatStream(ctx context.Context, req Request, onEvent func(Stream
var lastErr error
for i, s := range c.steps {
stepReq := c.applyBudget(req, i)
if s.Model != "" {
stepReq.Model = s.Model
if m := stepModel(req, i, s.Model); m != "" {
stepReq.Model = m
}
delivered := false
wrapped := func(ev StreamEvent) {