-
Notifications
You must be signed in to change notification settings - Fork 151
feat: embedded visualizations in chat #8122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
|
|
||
| // Check if this property is a field config object | ||
| if (isFieldConfig(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g., maybe here's an opportunity for a guard clause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFieldConfig has a type guard clause built in
| timeZone: chartSpec.time_range.time_zone || "UTC", | ||
| } | ||
| : { | ||
| start: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(), // Default to last 30 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: comment says 30 days but the code says 7
| spec: CartesianChartSpec & TimeRange; | ||
| } | ||
| | { chart_type: "donut_chart"; spec: CircularChartSpec & TimeRange } | ||
| | { chart_type: "pie_chart"; spec: CircularChartSpec & TimeRange } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't see pie_chart in the backend prompts. Should it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
donut_chart and pie_chart are the same. We moved from pie_chart keyword in favor of donut. We still keep pie_chart for backward compatibility.
| toolResult && | ||
| !toolResult.isError && | ||
| block.toolCall.name === "create_chart" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe bake these checks into isChartToolResult? Else this conditional is a bit hard-to-read.
| } | ||
| // Group tool calls with their results within this message | ||
| function groupToolCallsWithResults(content: any[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is now more complex, it's further motivation to move this data processing into the Conversation class. I suppose it doesn't need to happen in this PR, but calling it out. For this PR, could you try to reduce the layers of nesting? Any efforts to make this function a bit easier to follow would be appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with comments. Great to see this come together!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $: timeAndFilterStore = readable({ | ||
| timeRange: timeRange, | ||
| comparisonTimeRange: undefined, | ||
| showTimeComparison: false, | ||
| where: chartSpec.where || { | ||
| cond: { | ||
| op: "OPERATION_AND", | ||
| exprs: [], | ||
| }, | ||
| }, | ||
| timeGrain: chartSpec.time_grain || "TIME_GRAIN_DAY", | ||
| timeRangeState: undefined, | ||
| comparisonTimeRangeState: undefined, | ||
| hasTimeSeries: true, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to explain this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's tailored for time series charts. What about charts without a time series?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeAndFilterStore is a object representation of our time picker and filter bar UI.
It is required for all charts as well as all other components that we offer. The component make their own queries. As such, they need a time range and filter expression for filtering down the data.
There are some properties which are only relevant to time series which is timeGrain. Otherwise, most of it is used across components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I was thrown by hasTimeSeries: true. Does that need to be a derivative of the chart spec?
* Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]>
* refac: pull out metric view selectors from canvas spec * lint fix * separate out chart component from canvas * move chart utils, methods, config to feature/component * move chart specs and builder * move canvas chart components * move timeAndFilter * ChartSpec name refactor * update conflict var names * remove dev route * remove comments * add tool to AI chat * add go to explore button, update prompt * viz improvements * improve prompt * add chart schema * update prompt * add where and time_grain to gen * move to basic schema validation * remove temp file * remove old validation code * lint fix * review * Disable the `create_chart` tool in external MCP connections (#8143) * review comments * Adds `chat_charts` feature flag for the `create_chart` tool (#8159) * Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]> --------- Co-authored-by: Benjamin Egelund-Müller <[email protected]>
* refac: pull out metric view selectors from canvas spec * lint fix * separate out chart component from canvas * move chart utils, methods, config to feature/component * move chart specs and builder * move canvas chart components * move timeAndFilter * ChartSpec name refactor * update conflict var names * remove dev route * remove comments * add tool to AI chat * add go to explore button, update prompt * viz improvements * improve prompt * add chart schema * update prompt * add where and time_grain to gen * move to basic schema validation * remove temp file * remove old validation code * lint fix * review * Disable the `create_chart` tool in external MCP connections (#8143) * review comments * Adds `chat_charts` feature flag for the `create_chart` tool (#8159) * Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]> --------- Co-authored-by: Benjamin Egelund-Müller <[email protected]>
* refac: pull out metric view selectors from canvas spec * lint fix * separate out chart component from canvas * move chart utils, methods, config to feature/component * move chart specs and builder * move canvas chart components * move timeAndFilter * ChartSpec name refactor * update conflict var names * remove dev route * remove comments * add tool to AI chat * add go to explore button, update prompt * viz improvements * improve prompt * add chart schema * update prompt * add where and time_grain to gen * move to basic schema validation * remove temp file * remove old validation code * lint fix * review * Disable the `create_chart` tool in external MCP connections (#8143) * review comments * Adds `chat_charts` feature flag for the `create_chart` tool (#8159) * Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]> --------- Co-authored-by: Benjamin Egelund-Müller <[email protected]>
* refac: pull out metric view selectors from canvas spec * lint fix * separate out chart component from canvas * move chart utils, methods, config to feature/component * move chart specs and builder * move canvas chart components * move timeAndFilter * ChartSpec name refactor * update conflict var names * remove dev route * remove comments * add tool to AI chat * add go to explore button, update prompt * viz improvements * improve prompt * add chart schema * update prompt * add where and time_grain to gen * move to basic schema validation * remove temp file * remove old validation code * lint fix * review * Disable the `create_chart` tool in external MCP connections (#8143) * review comments * Adds `chat_charts` feature flag for the `create_chart` tool (#8159) * Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]> --------- Co-authored-by: Benjamin Egelund-Müller <[email protected]>
- Update AI chat documentation to reflect new chart visualization capabilities - Document chatCharts feature flag in project configuration - Add details about automatic chart type selection and when charts are generated - Include examples of enabling chat with visualizations - List all available chart types (line, area, bar, stacked bar, donut, combo, heatmap) Related to PR #8122 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
* refac: pull out metric view selectors from canvas spec * lint fix * separate out chart component from canvas * move chart utils, methods, config to feature/component * move chart specs and builder * move canvas chart components * move timeAndFilter * ChartSpec name refactor * update conflict var names * remove dev route * remove comments * add tool to AI chat * add go to explore button, update prompt * viz improvements * improve prompt * add chart schema * update prompt * add where and time_grain to gen * move to basic schema validation * remove temp file * remove old validation code * lint fix * review * Disable the `create_chart` tool in external MCP connections (#8143) * review comments * Adds `chat_charts` feature flag for the `create_chart` tool (#8159) * Adds `chat_charts` feature flag for the `create_chart` tool * Propagate feature flags to the prompts * Fix test * Fix test * QA * add feature flag to base system prompt --------- Co-authored-by: Dhiraj Kumar <[email protected]> --------- Co-authored-by: Benjamin Egelund-Müller <[email protected]>



Adds tool
create_chartfor embedding charts into AI chat.Further -
features/exploresChartContainerTODO
create_chartfor external MCP clientsChecklist: