优化渲染节点功能,使用 ref 文件渲染大量节点
This commit is contained in:
@@ -268,12 +268,7 @@ function getToolDescription(toolCall: ToolCall): string {
|
||||
return (params.title as string | undefined) ?? "数据图表";
|
||||
}
|
||||
case "render_junctions": {
|
||||
const nodeAreaMap =
|
||||
params.node_area_map && typeof params.node_area_map === "object"
|
||||
? (params.node_area_map as Record<string, unknown>)
|
||||
: {};
|
||||
const areaIds = Array.isArray(params.area_ids) ? params.area_ids : [];
|
||||
return `${Object.keys(nodeAreaMap).length} 个节点 · ${areaIds.length || new Set(Object.values(nodeAreaMap).map(String)).size} 个分区`;
|
||||
return (params.render_ref as string | undefined) ?? "渲染引用";
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
@@ -398,28 +393,14 @@ function buildAction(toolCall: ToolCall): ChatToolAction | null {
|
||||
yAxisName: params.y_axis_name as string | undefined,
|
||||
};
|
||||
case "render_junctions": {
|
||||
const nodeAreaMap =
|
||||
params.node_area_map && typeof params.node_area_map === "object"
|
||||
? Object.fromEntries(
|
||||
Object.entries(params.node_area_map as Record<string, unknown>)
|
||||
.map(([key, value]) => [String(key), String(value ?? "")])
|
||||
.filter(([, value]) => value.trim().length > 0),
|
||||
)
|
||||
: {};
|
||||
const renderRef =
|
||||
typeof params.render_ref === "string" ? params.render_ref.trim() : "";
|
||||
if (!renderRef) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
type: "render_junctions",
|
||||
nodeAreaMap,
|
||||
areaIds: Array.isArray(params.area_ids)
|
||||
? params.area_ids.map((item) => String(item).trim()).filter(Boolean)
|
||||
: [],
|
||||
areaColors:
|
||||
params.area_colors && typeof params.area_colors === "object"
|
||||
? Object.fromEntries(
|
||||
Object.entries(params.area_colors as Record<string, unknown>)
|
||||
.map(([key, value]) => [String(key), String(value ?? "")])
|
||||
.filter(([, value]) => value.trim().length > 0),
|
||||
)
|
||||
: {},
|
||||
renderRef,
|
||||
};
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user