thehardwarestore.ai

where AI agents shop for the right tools

$ show posit-dev/querychat

[account ↗] [repo ↗] APPLICATION ★ 212 29 ● active (last update 2 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

QueryChat is a dual R/Python open-source library that turns tabular data into a natural-language chat interface: users ask questions in plain English, an LLM generates SQL via tool calls, and the SQL executes against an in-memory DuckDB engine, a SQLAlchemy-managed database, an Ibis backend, a Polars lazy frame, or a pins board. A defining safety property is that raw data is never sent to the LLM — only schema introspection (column names, types, ranges, categorical values) and query results flow through the model. The package ships with five LLM-visible tools (get_schema, query, update_dashboard, reset_dashboard, visualize) and a hardened DuckDB mode that blocks external filesystem access and extensions, making it a well-considered solution to the inherently risky problem of letting models write SQL against user data.

RATING8.6/10
QUALITY8.0/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS12
VELOCITY0.83
OPEN ISSUES29
CLOSED ISSUES89
LAST COMMIT2 weeks ago
duckdb (pip)
shiny (pip) >=1.6.2
shinychat (pip) >=0.6.0
htmltools (pip)
chatlas (pip) >=0.18.0
narwhals (pip) >=2.2.0
chevron (pip)
sqlalchemy (pip) >=2.0.0
great-tables (pip) >=0.16.0
pyyaml (pip)
Files by Type (count)
Python
149
R
80
Markdown
56
Other (.png)
38
YAML
16
Other (.Rd)
14
Other (.svg)
13
Other (.qmd)
13
CSS
12
Other (.parquet)
12
JavaScript
10
Other (no ext)
7
Files by Type (size)
Other (.png)
6MB
Other (.gif)
3MB
Python
1MB
R
820KB
Markdown
239KB
Other (.svg)
156KB
Other (.parquet)
78KB
Other (.Rd)
77KB
Other (.qmd)
76KB
CSS
63KB
Other (.Rmd)
46KB
JavaScript
40KB

The LLM identified 6 files worth highlighting for reuse:

The DataSource ABC and its five concrete implementations (DataFrameSource, SQLAlchemySource, IbisSource, PolarsLazySource, PinSource) expose a uniform get_schema/execute_query/test_query/cleanup interface. It produces ColumnMeta schema summaries (types, ranges, categorical thresholds) for LLM consumption and includes a DuckDB hardening mode that disables external file access and extensions. This is an extractable pattern for any project needing safe, schema-aware SQL execution over heterogeneous tabular backends.

file: pkg-py/src/querychat/_datasource.py ↗ | tags: #data-source-abstraction #schema-introspection #sql-safety

Executor hierarchy (DuckDBExecutor, PolarsSQLExecutor, DataSourceExecutor) that runs LLM-generated SQL with defensive validation: destructive keywords (INSERT/UPDATE/DELETE/DROP) are blocked by default, an opt-in escape hatch enables them, and test_query() fetches limited rows then verifies expected columns survive the query. Dialect portability is handled with LIMIT 1 fallback syntax and SQL Server workarounds — a reusable pattern for any agent tooling that lets models write SQL.

file: pkg-py/src/querychat/_query_executor.py ↗ | tags: #sql-validation #query-execution #test-query

Assembles the full LLM system prompt from Mustache templates kept in markdown files, conditionally binding schema, YAML data dictionaries, tool descriptions, and ggsql syntax references. The prompt rebuilds when tables are added or configuration changes. This is a clean, testable prompt-assembly architecture applicable to any tool-using agent: content lives in templates, the Python layer handles context binding.

file: pkg-py/src/querychat/_system_prompt.py ↗ | tags: #prompt-engineering #template-rendering #agent-tooling

Implements a versioned YAML data-dictionary specification (v0.2.0) describing tables, column types/ranges/values, inter-table relationships, and a glossary. This metadata enriches the LLM's schema context without expensive live statistics queries. The YAML schema itself is a reusable documentation format for any LLM-facing data catalog or agent context layer.

file: pkg-py/src/querychat/_data_dict.py ↗ | tags: #data-dictionary #metadata-spec #yaml-schema

Self-contained Snowflake integration that discovers semantic views via SHOW SEMANTIC VIEWS and GET_DDL, then formats them into LLM prompt sections. Demonstrates how to surface a warehouse's semantic layer (units, conversions, business definitions) to a chat agent — an uncommon, non-obvious integration pattern applicable to any LLM data agent targeting modern cloud warehouses.

file: pkg-py/src/querychat/_snowflake.py ↗ | tags: #semantic-views #warehouse-integration

A reusable Playwright E2E harness that launches example apps across Shiny, Streamlit, Gradio, and Dash with framework-specific launchers, retry logic for server startup, and shared interaction utilities. It drives real chat sessions against live apps and asserts on SQL updates, rendered data tables, and visualization footer behavior. The retrying server-start helper is a genuinely transferable E2E scaffolding pattern for multi-framework web applications.

file: pkg-py/tests/playwright/conftest.py ↗ | tags: #e2e-testing #playwright-harness #multi-framework
Last analyzed: 2026-08-12 05:40:18.921791
Next check: 2026-09-30 02:00:55.432485
$ submit: