Files
TJWaterAgent/.opencode/tools/show_chart.ts
T
jiang a27c45910c LLM 请求透明化
Co-authored-by: Copilot <copilot@github.com>
2026-05-18 17:12:33 +08:00

32 lines
1.1 KiB
TypeScript

import { tool } from "@opencode-ai/plugin";
export default tool({
description: "在前端对话界面中渲染图表。",
args: {
reason: tool.schema
.string()
.describe("Why this chart should be rendered for the user request."),
title: tool.schema.string().optional().describe("Chart title."),
chart_type: tool.schema
.enum(["line", "bar", "pie"])
.optional()
.describe("Chart type."),
x_data: tool.schema.array(tool.schema.string()).describe("X-axis labels."),
series: tool.schema
.array(
tool.schema.object({
name: tool.schema.string(),
data: tool.schema.array(tool.schema.number()),
type: tool.schema.enum(["line", "bar"]).optional(),
}),
)
.describe("Series data."),
x_axis_name: tool.schema.string().optional().describe("X-axis display name."),
y_axis_name: tool.schema.string().optional().describe("Y-axis display name."),
},
async execute() {
// 图表数据已经在工具参数里,前端收到 tool_call 后直接渲染,不再二次请求后端。
return "图表将在对话中显示。";
},
});