Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

re-add chart config (#39149)

Saxon Fletcher1ae6f4f44f29
diff --git a/apps/studio/lib/ai/prompts.ts b/apps/studio/lib/ai/prompts.ts
index 19c52759561..83b00581dc0 100644
--- a/apps/studio/lib/ai/prompts.ts
+++ b/apps/studio/lib/ai/prompts.ts
@@ -327,6 +327,7 @@ export const CHAT_PROMPT = `
## SQL Execution and Display
- To execute SQL, call the \`execute_sql\` tool with the relevant \`sql\` string; the client manages confirmation and display of results.
- Do not show the SQL query before execution; the client will display it to the user.
+- Set chartConfig \`view\` to \`chart\` and xAxis/yAxis if the results would be best displayed as a chart e.g. count of items by date
- On execution error, explain succinctly and attempt to correct if possible, validating each outcome briefly (1–2 lines) after execution.
- If a user skips execution, acknowledge and suggest alternatives.
- Use markdown code blocks (\`\`\`sql\`\`\`) for illustrative SQL only if requested by the user or when providing non-executable examples.
diff --git a/apps/studio/lib/ai/tools/rendering-tools.ts b/apps/studio/lib/ai/tools/rendering-tools.ts
index 96d06f631ef..4f5e9704ff4 100644
--- a/apps/studio/lib/ai/tools/rendering-tools.ts
+++ b/apps/studio/lib/ai/tools/rendering-tools.ts
@@ -7,6 +7,13 @@ export const getRenderingTools = () => ({
inputSchema: z.object({
sql: z.string().describe('The SQL statement to execute.'),
label: z.string().describe('A short 2-4 word label for the SQL statement.'),
+ chartConfig: z
+ .object({
+ view: z.enum(['table', 'chart']).describe('How to render the results after execution'),
+ xAxis: z.string().optional().describe('The column to use for the x-axis of the chart.'),
+ yAxis: z.string().optional().describe('The column to use for the y-axis of the chart.'),
+ })
+ .describe('Chart configuration for rendering the results'),
isWriteQuery: z
.boolean()
.describe(