fix(ui): restrict chart types
This commit is contained in:
@@ -9,7 +9,7 @@ export default tool({
|
|||||||
.describe("Why this chart should be rendered for the user request."),
|
.describe("Why this chart should be rendered for the user request."),
|
||||||
title: tool.schema.string().optional().describe("Chart title."),
|
title: tool.schema.string().optional().describe("Chart title."),
|
||||||
chart_type: tool.schema
|
chart_type: tool.schema
|
||||||
.enum(["line", "bar", "pie"])
|
.enum(["line", "bar"])
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Chart type."),
|
.describe("Chart type."),
|
||||||
x_data: tool.schema
|
x_data: tool.schema
|
||||||
|
|||||||
@@ -42,10 +42,7 @@ export const toUiEnvelopeFromToolCall = ({
|
|||||||
if (xData.length === 0 || series.length === 0) {
|
if (xData.length === 0 || series.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const chartType =
|
const chartType = params.chart_type === "bar" ? "bar" : "line";
|
||||||
params.chart_type === "bar" || params.chart_type === "pie"
|
|
||||||
? params.chart_type
|
|
||||||
: "line";
|
|
||||||
return {
|
return {
|
||||||
kind: "chart",
|
kind: "chart",
|
||||||
schemaVersion: "agent-ui@1",
|
schemaVersion: "agent-ui@1",
|
||||||
|
|||||||
Reference in New Issue
Block a user