feat:新增物料

This commit is contained in:
2026-10-13 04:16:00 -07:00
parent b117f21e3a
commit a80727b7a0
15 changed files with 174 additions and 54 deletions
+15 -10
View File
@@ -15,20 +15,24 @@ def request_summary(context: InputContext) -> JsonObject:
"""用户输入、澄清记录、编辑上下文、附件、数据文件和大屏摘要"""
nodes: list[JsonObject] = []
for node in context.screen.nodes:
# 图表标题帮助判断用户指的是哪个组件;没有 option 或标题格式不符时按无标题处理
# 画面上的标题帮助判断用户指的是哪个组件:图表在 option.title,指标卡在 props.title;
# 格式不符时按无标题处理
option = node.props.get("option")
title = option.get("title") if isinstance(option, dict) else None
titles = title if isinstance(title, list) else [title]
texts = [
item["text"]
for item in titles
if isinstance(item, dict) and isinstance(item.get("text"), str)
]
if isinstance(node.props.get("title"), str) and node.props["title"]:
texts.append(node.props["title"])
nodes.append(
{
"id": node.id,
"type": node.type,
"name": node.name,
"titles": [
item["text"]
for item in titles
if isinstance(item, dict) and isinstance(item.get("text"), str)
],
"titles": texts,
"layout": node.layout.model_dump(mode="json", exclude_unset=True),
}
)
@@ -38,10 +42,11 @@ def request_summary(context: InputContext) -> JsonObject:
"clarification_history": context.clarification_history,
"context": context.context.model_dump(mode="json", exclude_unset=True),
"screen_summary": {
"canvas": {
"width": context.screen.canvas.width,
"height": context.screen.canvas.height,
},
"canvas": context.screen.canvas.model_dump(
mode="json",
include={"width", "height", "theme", "backgroundColor"},
exclude_none=True,
),
"nodes": nodes,
# 数据源只保留标识、名称和类型
"data_sources": [