Draft
Conversation
c5c8f6e to
34a41da
Compare
34a41da to
a21712c
Compare
cpsievert
commented
Mar 3, 2026
a21712c to
05687d5
Compare
05687d5 to
8f33d70
Compare
8f33d70 to
a3bdcbd
Compare
a3bdcbd to
3e15610
Compare
3e15610 to
ac299be
Compare
1450755 to
a711326
Compare
a711326 to
8696fca
Compare
8696fca to
db264dd
Compare
db264dd to
5a7e9de
Compare
5a7e9de to
9160e24
Compare
f1aef08 to
1c3c8e3
Compare
0d1fc4d to
3998d6a
Compare
cpsievert
commented
Mar 19, 2026
8aaab35 to
98c097f
Compare
108b063 to
d2e5c7e
Compare
Add ggsql-powered visualization support including: - Visualization tool with inline chart rendering via Altair/ipywidgets - ggsql prompt, syntax reference, and filter-awareness guidance - Visualization tests and example app - UI components (CSS/JS) for chart display, save, and query toggle Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add unit tests for extract_visualise_table() covering bare/quoted identifiers, no-FROM, DRAW-level FROM false positive, CTE names, and case insensitivity - Add integration test for the VISUALISE FROM code path - Document upstream gaps in ggsql Python bindings - Stop re-exporting VisualizeQueryData from tools.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d2e5c7e to
8478082
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
visualize_querytool to querychat's Python package, enabling LLM-generated data visualizations via ggsql. When enabled, the LLM can write ggsql queries (SQL +VISUALISEclause) that are executed and rendered as interactive Altair charts inline in the chat.Usage
Install
This installs the optional dependencies:
ggsql,altair, andshinywidgets.Example app
The
visualize_querytool is opt-in — include it in thetoolstuple alongside"query"and/or"update"to enable it.What it looks like
Charts render inline in the chat with a collapsible footer showing the ggsql query (with syntax highlighting), a copy button, and save options:
Key changes
visualize_querytool (opt-in viatools=("query", "visualize_query")): The LLM writes a full ggsql query, which is executed against the data source and rendered as an Altair chart._viz_ggsql.py): Uses DataSource for SQL execution (preserving database pushdown), then feeds results into ggsql for VISUALISE processing → Altair chart._viz_altair_widget.py): CustomAltairWidgetfor rendering charts directly in the chat stream, with JS/CSS assets for interactive display.tool-visualize-query.md): Detailed tool prompt with ggsql syntax guidance, plus filter-awareness instructions added to the query tool prompt._ServerValuessubclass.pkg-r/inst/prompts/prompt.mdandtool-query.mdfor filter-awareness guidance (keeping prompts in sync).Test coverage
test_ggsql.py— ggsql execution pipeline, spec-to-Altair conversion, title extraction, validationtest_viz_tools.py— Tool creation, rendering, error handlingtest_viz_footer.py— Footer HTML structure, icons, JS invariantsplaywright/test_10_viz_inline.py— Inline chart Playwright testsplaywright/test_11_viz_footer.py— Footer interaction Playwright testsBefore Merging
🤖 Generated with Claude Code