feat(pkg-py): Add ggsql visualization integration #201
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
This PR integrates ggsql with querychat to enable LLM-generated SQL visualization queries that render as Altair charts. Two new tools (
visualize_dashboard,visualize_query) extend the existing tool system across all framework integrations.New Features
Two visualization tools:
visualize_dashboard: Creates persistent charts that update when filters changevisualize_query: Creates one-off charts from specific SQL queries with VISUALISE clauseNew accessor methods across all frameworks:
ggvis(source)- Returns Altair Chart objectggsql(source)- Returns ggsql specification stringggtitle(source)- Returns visualization titleTabbed UI: All framework
app()methods now display Data / Filter Plot / Query Plot tabsAuto re-rendering: Filter visualization automatically updates when filtered data changes (Shiny)
System prompt: ggsql syntax reference included when visualization tools are enabled
Implementation Details
qc.ggvis()(reactive)output_widgetqc.ggvis()(session state)st.altair_chart()qc.ggvis(state)(state dict)gr.Plot()qc.ggvis(state)(state dict)html.IframewithsrcDocFiles Changed (Key)
pkg-py/src/querychat/_ggsql.py- New ggsql helper modulepkg-py/src/querychat/tools.py- Visualization toolspkg-py/src/querychat/prompts/tool-visualize-*.md- Tool documentationpkg-py/src/querychat/prompts/prompt.md- System prompt with ggsql syntaxpkg-py/src/querychat/_querychat_base.py- Base class accessor methodspkg-py/src/querychat/_querychat_core.py- State management with viz fieldspkg-py/src/querychat/_shiny*.py- Shiny implementationpkg-py/src/querychat/_streamlit.py- Streamlit implementationpkg-py/src/querychat/_gradio.py- Gradio implementationpkg-py/src/querychat/_dash*.py- Dash implementationTest Coverage
test_ggsql.py- ggsql helper unit teststest_viz_tools.py- Tool function teststest_ggsql_integration.py- Integration tests1. ggsql Dependency
The
ggsqlpackage is currently referenced as a local path dependency:"ggsql @ {root:uri}/../ggsql/ggsql-python"Action needed: Update to PyPI reference once ggsql is published, or determine alternative distribution strategy.
2. Manual Testing
3. Documentation
4. Review Considerations
🤖 Generated with Claude Code