Skip to content

Commit cf56d36

Browse files
committed
feat(query-generation): add better prompts for visualization
1 parent 16e055d commit cf56d36

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/components/db-query/nodes/generate-description.node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ Return a short bulleted list where each bullet is one condition, filter, or piec
8484
if (token) {
8585
output += token;
8686
config.writer?.({
87-
type: LLMStreamEventType.Message,
88-
data: {message: token},
87+
type: LLMStreamEventType.ToolStatus,
88+
data: {thinkingToken: token},
8989
});
9090
}
9191
}

src/components/db-query/tools/get-data-as-dataset.tool.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ export class GetDataAsDatasetTool implements IGraphTool {
5353
}) as AnyObject[string];
5454
return graph.asTool({
5555
name: this.key,
56-
description: `Query tool for generating SQL queries for a users request. Use it to find data from the database based on the user's request.
57-
Note that it does not return the query, instead only a dataset ID that is not relevant to the user.
56+
description: `Query tool for generating SQL queries for a users request. Use it only when the user needs raw tabular data from the database.
57+
Do not use this tool if the user's request involves trends, growth, decline, comparisons, distributions, patterns, or any form of analytical insight — use the 'generate-visualization' tool instead.
58+
Note that it does not return the query, instead only a dataset ID that is not relevant to the user.
5859
It internally fires an event that renders a grid for the dataset on the UI for the user to see.`,
5960
schema,
6061
});

src/components/visualization/tools/generate-visualization.tool.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export class GenerateVisualizationTool implements IGraphTool {
5151
),
5252
datasetId: z
5353
.string()
54+
.optional()
5455
.describe(
55-
`ID of the dataset that needs to be visualized. Use the dataset ID from 'get-data-as-dataset' or 'improve-dataset' tool`,
56+
`ID of the dataset that needs to be visualized. Use the dataset ID from 'get-data-as-dataset' or 'improve-dataset' tool if available. If not provided, the tool will internally fetch the data.`,
5657
),
5758
type: z
5859
.string()
@@ -63,12 +64,11 @@ export class GenerateVisualizationTool implements IGraphTool {
6364
}) as AnyObject[string];
6465
return graph.asTool({
6566
name: this.key,
66-
description: `
67-
It takes in a prompt and an optional dataset ID that needs to be visualized.
68-
Must use this over 'get-data-as-dataset' tool if the user request would be better served with a visualization rather than a tabular representation of the data, even if the user does not explicitly ask for it.
69-
No need to call 'get-data-as-dataset' tool before this, if the dataset ID is not provided, the tool will internally fetch the data to be visualized.
67+
description: `Generates a visualization for the user's request. It takes in a prompt and an optional dataset ID.
68+
If the user's request involves trends, growth, decline, comparisons, distributions, patterns, correlations, or any analytical insight, ALWAYS use this tool instead of 'get-data-as-dataset'.
69+
No need to call 'get-data-as-dataset' tool before this — if the dataset ID is not provided, this tool will internally fetch the data to be visualized.
7070
It does not return anything, instead it fires an event internally that renders the visualization on the UI for the user to see.
71-
It supports followings types of visualizations: ${visualizations.map(v => v.name).join(', ')}.`,
71+
It supports the following types of visualizations: ${visualizations.map(v => v.name).join(', ')}.`,
7272
schema,
7373
});
7474
}

src/components/visualization/visualizers/line.visualizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You are an expert data visualization assistant. Your task is to create a line ch
5757
}) as z.AnyZodObject;
5858

5959
constructor(
60-
@inject(AiIntegrationBindings.CheapLLM)
60+
@inject(AiIntegrationBindings.SmartNonThinkingLLM)
6161
private readonly llm: LLMProvider,
6262
) {}
6363

0 commit comments

Comments
 (0)