fix(canvas): Agent 识图 - 交付真实图片字节并纠正视觉状态
This commit is contained in:
1 parent
b667605902
commit
58bf197156
10 files changed
+530
-131
No files matched your search
@@ -25,27 +25,16 @@ type cloudAgentReferenceAnchor struct {
|
||||
ReferenceReady bool `json:"referenceReady"`
|
||||
VisualIdentity string `json:"visualIdentity"`
|
||||
RequiresVisualInspection bool `json:"requiresVisualInspection"`
|
||||
// VisualNote 是模型看过这张图之后自己写下的一句观察。锚点会跨轮继承,
|
||||
// 因此下一轮不必重复看图也能拿到文字观察(推理内容不会回灌上下文)。
|
||||
// 旧检查点可能含有未经确认的正文摘录,不再自动写入或跨轮继承。
|
||||
VisualNote string `json:"visualNote,omitempty"`
|
||||
Width any `json:"width,omitempty"`
|
||||
Height any `json:"height,omitempty"`
|
||||
}
|
||||
|
||||
// cloudAgentCreativeAnchorForCanvas 按当前画布重建候选素材锚点。
|
||||
// inherited 是上一轮的锚点:只继承"视觉事实"——已经看过的画面和模型自己写下的观察;
|
||||
// 用户目标、权限和旧计划都不继承(用户消息才是本轮目标,候选素材按当前画布重建,
|
||||
// 避免把过期素材带进新轮)。
|
||||
func cloudAgentCreativeAnchorForCanvas(repo *repository.Repository, userID string, canvas *model.CanvasProject, prompt string, inherited *cloudAgentCreativeAnchor) (cloudAgentCreativeAnchor, error) {
|
||||
// 不继承旧视觉标记:工具成功和下一段正文都不是识别成功的可靠证据,节点也可能换图。
|
||||
func cloudAgentCreativeAnchorForCanvas(repo *repository.Repository, userID string, canvas *model.CanvasProject, prompt string, _ *cloudAgentCreativeAnchor) (cloudAgentCreativeAnchor, error) {
|
||||
anchor := cloudAgentCreativeAnchor{Version: 2, UserPrompt: prompt}
|
||||
inspected := map[string]cloudAgentReferenceAnchor{}
|
||||
if inherited != nil {
|
||||
for _, asset := range inherited.ReferenceAssets {
|
||||
if asset.VisualIdentity == "inspected" {
|
||||
inspected[asset.NodeID] = asset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doc, err := creationDocument(canvas.PayloadJSON)
|
||||
if err != nil {
|
||||
@@ -99,12 +88,6 @@ func cloudAgentCreativeAnchorForCanvas(repo *repository.Repository, userID strin
|
||||
item.Width, item.Height = ref["width"], ref["height"]
|
||||
}
|
||||
}
|
||||
if viewed, ok := inspected[item.NodeID]; ok {
|
||||
// 这一轮之前已经看过画面:直接继承模型自己写下的观察,不重复看图。
|
||||
item.VisualIdentity = "inspected"
|
||||
item.RequiresVisualInspection = false
|
||||
item.VisualNote = viewed.VisualNote
|
||||
}
|
||||
anchor.ReferenceNodeIDs = append(anchor.ReferenceNodeIDs, item.NodeID)
|
||||
anchor.ReferenceAssets = append(anchor.ReferenceAssets, item)
|
||||
if len(anchor.ReferenceAssets) == 16 {
|
||||
|
||||
Reference in new issue
Block a user