feat:接入mcp,为模型提供图表信息
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""精确更新组件 props 或 style 下的一个字段"""
|
||||
"""精确更新组件名称,或 props / style 下的一个字段"""
|
||||
|
||||
from typing import Annotated, Literal
|
||||
from typing import Annotated, Literal, Self
|
||||
|
||||
from pydantic import Field, JsonValue
|
||||
from pydantic import Field, JsonValue, model_validator
|
||||
|
||||
from app.schemas.base import NonBlankString
|
||||
|
||||
@@ -13,10 +13,21 @@ PathSegment = NonBlankString | Annotated[int, Field(ge=0)]
|
||||
|
||||
class UpdateAction(BaseAction):
|
||||
type: Literal["update"] = "update"
|
||||
section: Literal["props", "style"] = Field(description="允许更新的组件属性区域")
|
||||
section: Literal["name", "props", "style"] = Field(
|
||||
description="字段路径的第一段:name 为组件名称,props / style 为组件属性区域"
|
||||
)
|
||||
path: list[PathSegment] = Field(
|
||||
min_length=1, description="区域内的字段路径,字符串为对象键,整数为数组下标"
|
||||
)
|
||||
value: JsonValue = Field(
|
||||
description="替换该路径的值,支持任意 JSON;null 是赋值,不表示删除"
|
||||
description="字段路径第一段之后的各段,字符串为对象键,整数为数组下标;name 没有后续路径,传空列表"
|
||||
)
|
||||
value: JsonValue = Field(description="替换该字段的值,必须符合字段定义的类型和取值")
|
||||
|
||||
@model_validator(mode="after")
|
||||
def path_matches_section(self) -> Self:
|
||||
if (self.section == "name") != (not self.path):
|
||||
raise ValueError("section 为 name 时 path 为空,props / style 至少一段路径")
|
||||
return self
|
||||
|
||||
@property
|
||||
def field_path(self) -> str:
|
||||
"""与物料字段定义一致的点路径,例如 props.option.title.text"""
|
||||
return ".".join([self.section, *map(str, self.path)])
|
||||
|
||||
Reference in New Issue
Block a user