增加渲染节点功能,优化工具操作和样式
This commit is contained in:
@@ -131,6 +131,12 @@ const TOOL_META: Record<string, ToolMeta> = {
|
||||
actionLabel: "显示",
|
||||
color: "#73c0de",
|
||||
},
|
||||
render_junctions: {
|
||||
label: "渲染节点",
|
||||
icon: <LocationOnRounded sx={{ fontSize: 18 }} />,
|
||||
actionLabel: "应用渲染",
|
||||
color: "#3b82f6",
|
||||
},
|
||||
};
|
||||
|
||||
/* ---------- helpers ---------- */
|
||||
@@ -261,6 +267,14 @@ function getToolDescription(toolCall: ToolCall): string {
|
||||
case "show_chart": {
|
||||
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} 个分区`;
|
||||
}
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -383,6 +397,31 @@ function buildAction(toolCall: ToolCall): ChatToolAction | null {
|
||||
xAxisName: params.x_axis_name as string | undefined,
|
||||
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),
|
||||
)
|
||||
: {};
|
||||
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),
|
||||
)
|
||||
: {},
|
||||
};
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user