feat:意图识别优化
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
from typing import Literal, Self
|
||||
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
|
||||
from .base import ExtensibleModel, JsonObject, NonBlankString
|
||||
from .operations import OPERATION_GUIDE, normalize_operation
|
||||
|
||||
Intent = Literal["create_screen", "modify_screen", "qa", "unclear"]
|
||||
TargetScope = Literal["nodes", "canvas", "screen", "unresolved"]
|
||||
@@ -22,14 +23,18 @@ class RequirementChange(ExtensibleModel):
|
||||
target_description: NonBlankString | None = Field(
|
||||
default=None, description="目标的自然语言描述,例如右侧区域、用户所说的那个图"
|
||||
)
|
||||
operation: NonBlankString = Field(
|
||||
description="需求操作,例如 move、resize、add、delete、restyle;允许后续扩展"
|
||||
)
|
||||
operation: NonBlankString = Field(description=f"需求操作。{OPERATION_GUIDE}")
|
||||
parameters: JsonObject = Field(
|
||||
default_factory=dict,
|
||||
description="需求参数,例如 delta_x=50;保留用户要求的单位与相对变化语义",
|
||||
)
|
||||
|
||||
@field_validator("operation")
|
||||
@classmethod
|
||||
def normalize_operation_name(cls, value: str) -> str:
|
||||
# 在协议层统一同义操作名,模型输出、测试构造和检查点恢复都经过这里
|
||||
return normalize_operation(value)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_target(self) -> Self:
|
||||
if len(self.target_ids) != len(set(self.target_ids)):
|
||||
|
||||
Reference in New Issue
Block a user