fix:处理模型错误添加大量文本的bug
This commit is contained in:
@@ -15,12 +15,12 @@ class AddAction(ActionModel):
|
||||
node: ScreenNode = Field(
|
||||
description="新组件。id、type、layout 必填,其余只写需要覆盖物料默认配置的字段;"
|
||||
"后端按 type 找到物料,用默认配置补全:对象逐层覆盖,数组整体替换,null 明确覆盖。"
|
||||
"写出的字段和 update 一样按字段定义检查类型和取值(跟随主题的颜色可以写 null)。"
|
||||
"id 不能与当前大屏上的组件重复(包括之前提交里新增的),先 delete 的 ID 可以再用;type 用 list_components 返回的 type。"
|
||||
'任何字段值都可以写成 {"$query": "SELECT ..."},后端替换成上传数据的查询结果:写入单个值的字段时结果要一行一列,取那个值;写入数字、文字数组的字段时结果要只有一列;其余是对象数组,键是结果的列名'
|
||||
)
|
||||
sample_data: bool = Field(
|
||||
default=False,
|
||||
description="true 表示组件显示的不是真实业务数据(物料示例数据,或自己编写的数据)。不写时按物料设置;"
|
||||
"只有展示的数据全部来自大屏上已有的组件或上传的数据文件时写 false,例如更换类型时迁移了原组件的数据;"
|
||||
"node 里用了 $query 时不写也会设为 false",
|
||||
description="true 表示组件展示的是自己编写的数据(不是来自上传的文件或大屏上已有的组件),交付时标为示例数据。"
|
||||
"组件上留着物料示例数据时后端会自动标为示例数据,不用写",
|
||||
)
|
||||
|
||||
@@ -22,4 +22,6 @@ class AgentResult(BaseModel):
|
||||
status: Literal["completed", "waiting_for_input", "failed", "cancelled"]
|
||||
actions: list[Action] = Field(default_factory=list)
|
||||
answer: str | None = None # 回答,或失败时由模型总结的原因说明
|
||||
# 可以一键发送的后续请求,前端显示成按钮,点了就作为下一条消息发出;目前只有问答查了数据后的"放到大屏上"
|
||||
suggestions: list[str] = Field(default_factory=list)
|
||||
clarification: Clarification | None = None
|
||||
|
||||
@@ -50,9 +50,6 @@ class ComponentDefinition(ExtensibleModel):
|
||||
"前端属性面板的 setters 由它派生,不单独保存",
|
||||
)
|
||||
eventOptions: list[JsonObject] = Field(default_factory=list)
|
||||
sample_data: bool = Field(
|
||||
default=False, description="默认配置是否含示例数据,不能视为真实业务数据"
|
||||
)
|
||||
usage_notes: list[NonBlankString] = Field(
|
||||
default_factory=list, description="配置、数据绑定及使用限制说明"
|
||||
)
|
||||
@@ -82,6 +79,8 @@ def _default_problem(field, template: JsonObject) -> str | None:
|
||||
return "的路径与默认配置结构冲突"
|
||||
if field.themed:
|
||||
return None if current is MISSING else "跟随主题,默认配置里不能写死颜色"
|
||||
if field.example and current is MISSING:
|
||||
return "标为示例内容,默认配置里要有这个值"
|
||||
if current is MISSING:
|
||||
if field.default is None:
|
||||
return "在默认配置中不存在,需要声明 default"
|
||||
|
||||
@@ -106,6 +106,15 @@ class MaterialField(ExtensibleModel):
|
||||
default=False,
|
||||
description="颜色跟随画布主题:默认配置里不写值,由前端按画布主题(亮 / 暗)取色;写入 null 恢复跟随",
|
||||
)
|
||||
example: Literal["data", "label"] | None = Field(
|
||||
default=None,
|
||||
description="默认配置里的值是演示内容,不是结构默认值:data 是示例数据(图表数据、指标值),"
|
||||
"label 是示例文字(标题、系列名)。新增组件沿用了它们时告诉 agent;沿用示例数据的组件交付时标为示例数据",
|
||||
)
|
||||
identifies: bool = Field(
|
||||
default=False,
|
||||
description="这个字段的文字是组件在画面上的名字或内容(图表标题、指标名、文本),大屏摘要用它帮助认出用户说的组件",
|
||||
)
|
||||
editable: bool = Field(default=True, description="是否允许修改")
|
||||
panel: bool = Field(default=True, description="是否显示在前端属性面板")
|
||||
span: int | None = Field(default=None, description="属性面板栅格宽度,24 为整行")
|
||||
@@ -122,6 +131,10 @@ class MaterialField(ExtensibleModel):
|
||||
raise ValueError(f"{self.value_type} 字段没有属性面板控件,panel 必须为 false: {self.path}")
|
||||
if self.themed and (self.value_type != "color" or self.default is not None):
|
||||
raise ValueError(f"只有 color 字段可以跟随主题,且不能声明 default: {self.path}")
|
||||
if self.example and (self.themed or self.default is not None):
|
||||
raise ValueError(f"示例内容要写在默认配置里,不能跟随主题或声明 default: {self.path}")
|
||||
if self.identifies and self.value_type != "string":
|
||||
raise ValueError(f"只有 string 字段可以用来识别组件: {self.path}")
|
||||
return self
|
||||
|
||||
def value_error(self, value: JsonValue) -> str | None:
|
||||
|
||||
Reference in New Issue
Block a user