docs(runtime): internal/runtime/loop 44 个文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;本模块按长期分批协议(一个模块一次派工)执行。 注释行数 1329 → 1329 逐行 1:1(含中文 33 → 1304);行尾注释 5 条一并译。 校验:机械校验(非注释改动行)= 空;独立 Go AST 程序(剥注释复渲)证明 44/44 文件代码全等; 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。 gofmt:capacity_loop_test.go / flow.go 改动前即未格式化,按铁律保留原样未动。
This commit is contained in:
1 parent
355f81d04a
commit
91e8d7a029
44 files changed
+1315
-1315
No files matched your search
@@ -6,34 +6,34 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/model"
|
||||
)
|
||||
|
||||
// ImageResolver is the loop's seam to the multimodal vision layer (design/06
|
||||
// §0). It is called once at the start of Run for every message that carries an
|
||||
// image content part, and may rewrite that message so the main model can reason
|
||||
// over the image. The concrete resolver lives in the vision package and decides,
|
||||
// via the vision Router, whether to keep the image for a vision-capable main
|
||||
// model or fold it into a text description produced by the vision/OCR tool ("先
|
||||
// 看图再对话"). Nil leaves the image content untouched so it flows straight to a
|
||||
// vision-capable main model.
|
||||
// ImageResolver 是循环通向多模态视觉层的接缝(design/06
|
||||
// §0)。它在 Run 开始时对每条携带图像内容部件的消息调用一次,
|
||||
// 并可以改写该消息,使主模型能对图像进行推理。具体
|
||||
// resolver 位于 vision 包,它通过 vision Router 决定
|
||||
// 是保留图像给支持视觉的主模型,还是折叠为
|
||||
// vision/OCR 工具产出的文字描述(「先
|
||||
// 看图再对话」)。为 nil 时图像内容保持原样,直接流向
|
||||
// 支持视觉的主模型。
|
||||
type ImageResolver interface {
|
||||
// Resolve rewrites msg, which carries at least one image content part. It
|
||||
// returns the (possibly rewritten) message. An error leaves the original
|
||||
// message in place so the turn still proceeds.
|
||||
// Resolve 改写 msg,其中至少携带一个图像内容部件。它
|
||||
// 返回(可能已改写的)消息。出错时保留原始
|
||||
// 消息,使该 turn 仍能继续。
|
||||
Resolve(ctx context.Context, msg model.Message) (model.Message, error)
|
||||
}
|
||||
|
||||
// ImageResolveFunc adapts a function to the ImageResolver interface.
|
||||
// ImageResolveFunc 把一个函数适配为 ImageResolver 接口。
|
||||
type ImageResolveFunc func(ctx context.Context, msg model.Message) (model.Message, error)
|
||||
|
||||
// Resolve implements ImageResolver.
|
||||
// Resolve 实现 ImageResolver。
|
||||
func (f ImageResolveFunc) Resolve(ctx context.Context, msg model.Message) (model.Message, error) {
|
||||
return f(ctx, msg)
|
||||
}
|
||||
|
||||
// resolveImages rewrites every image-bearing message in messages using the
|
||||
// injected resolver. It returns the input slice unchanged when no resolver is
|
||||
// configured, no image is present, or a message fails to resolve (the failure is
|
||||
// logged and the original message is kept so the turn still runs). A fresh slice
|
||||
// is returned when any message changed.
|
||||
// resolveImages 用注入的 resolver 改写 messages 中每条
|
||||
// 携带图像的消息。未配置 resolver、没有图像、或某条消息
|
||||
// 解析失败(失败会被记录日志并保留原消息,使该 turn 仍能
|
||||
// 运行)时,它原样返回输入切片。任一消息发生变化时
|
||||
// 返回一个新切片。
|
||||
func (l *Loop) resolveImages(ctx context.Context, messages []model.Message) []model.Message {
|
||||
if l.imageResolver == nil {
|
||||
return messages
|
||||
@@ -60,7 +60,7 @@ func (l *Loop) resolveImages(ctx context.Context, messages []model.Message) []mo
|
||||
return out
|
||||
}
|
||||
|
||||
// messageHasImage reports whether any content part of msg is an image part.
|
||||
// messageHasImage 报告 msg 是否有任何内容部件是图像部件。
|
||||
func messageHasImage(m model.Message) bool {
|
||||
for _, part := range m.Content {
|
||||
if part.Type == model.ContentTypeImage {
|
||||
|
||||
Reference in new issue
Block a user