feat:意图识别优化

This commit is contained in:
2026-09-30 06:49:32 -07:00
parent 16212d7138
commit c06053634f
18 changed files with 211 additions and 47 deletions
+6 -8
View File
@@ -14,7 +14,9 @@ from app.schemas.actions import (
UpdateAction,
UpdateCanvasAction,
)
from app.schemas.capabilities import DATA_BINDING_ERROR, DATA_BINDING_SUPPORTED
from app.schemas.component_resource import ComponentDefinition
from app.schemas.operations import PLAN_ADJUST_OPERATIONS, is_canvas_operation
from app.schemas.screen import Screen, ScreenNode
from app.schemas.screen_plan import PlanComponent
@@ -71,7 +73,7 @@ def plan_block_reason(state: QueryState) -> str | None:
return "当前不支持更换已有组件类型"
# 已有目标的修改诉求不能通过 keep 或遗漏目标绕过
supported_operations = {"move", "resize", "update", "restyle", "reflow", "layout"}
supported_operations = set(PLAN_ADJUST_OPERATIONS)
changes = state["requirement"].changes
# 删除必须逐个目标获得明确授权,整体布局调整不隐含删除权限
@@ -89,11 +91,7 @@ def plan_block_reason(state: QueryState) -> str | None:
# 逐项核对需求是否被规划覆盖,任一不支持的需求都会阻止整批生成
for change in changes:
# 画布更新需求必须对应非空的画布变更规划
if change.target_scope == "canvas" and change.operation in {
"update",
"resize",
"update_canvas",
}:
if is_canvas_operation(change.target_scope, change.operation):
if not plan.canvas_changes:
return "规划遗漏画布修改需求"
elif change.target_scope == "screen" and change.operation == "add":
@@ -294,8 +292,8 @@ def _validate_add_action(
return "示例数据标记与物料不一致"
# 当前没有数据绑定能力,拒绝新增节点携带非空的扩展 dataId
if action.node.model_extra.get("dataId"):
return "当前尚未接入数据绑定,不能生成 dataId"
if not DATA_BINDING_SUPPORTED and action.node.model_extra.get("dataId"):
return DATA_BINDING_ERROR
return None