feat: 接通 Planner → Action → Validator
This commit is contained in:
@@ -2,10 +2,19 @@
|
||||
|
||||
from typing import Literal, Self
|
||||
|
||||
from pydantic import ConfigDict, Field, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from app.schemas.base import ExtensibleModel, JsonObject, NonBlankString
|
||||
from app.schemas.screen import Layout
|
||||
from app.schemas.screen import Layout, PositiveNumber
|
||||
|
||||
|
||||
class ComponentSummary(BaseModel):
|
||||
key: NonBlankString # 目录编号
|
||||
type: NonBlankString # 前端实际组件类型
|
||||
name: NonBlankString # 组件名称
|
||||
description: NonBlankString # 组件用途
|
||||
default_width: PositiveNumber # 默认宽度,单位 px
|
||||
default_height: PositiveNumber # 默认高度,单位 px
|
||||
|
||||
|
||||
class MaterialTemplate(ExtensibleModel):
|
||||
@@ -99,3 +108,23 @@ class ComponentResult(ExtensibleModel):
|
||||
catalog_version: NonBlankString | None = None
|
||||
source: NonBlankString | None = None
|
||||
message: NonBlankString
|
||||
|
||||
def to_planner_context(self) -> JsonObject:
|
||||
# 显式提取摘要,避免默认数据、事件和扩展字段进入规划提示词
|
||||
return {
|
||||
"status": self.status,
|
||||
"catalog_version": self.catalog_version,
|
||||
"source": self.source,
|
||||
"message": self.message,
|
||||
"components": [
|
||||
ComponentSummary(
|
||||
key=component.key,
|
||||
type=component.type,
|
||||
name=component.name,
|
||||
description=component.description,
|
||||
default_width=component.schema_.layout.width,
|
||||
default_height=component.schema_.layout.height,
|
||||
).model_dump(mode="json")
|
||||
for component in self.components
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user