Live preview
FlueOutput will stream here when you run the agent.
Summary
The Chat with Database Agent answers questions about your data in plain English. It introspects the schema, writes the SQL, runs it read-only, and explains the results. Reach for it to give non-SQL users a safe way to query a database, or to prototype analytics without hand-writing queries.
Install
$ pnpm dlx shadcn@latest add https://agentcn.vercel.app/r/flue/text-to-sql.json
Composition
agents/
└── text-to-sql.ts # Agent with the two database tools
tools/
├── introspect-schema.ts # Lists tables and columns
└── run-query.ts # Runs a read-only SELECT
lib/
└── db.ts # Database client (SQLite by default)Customization
- Swap the database. Replace the client in
lib/db.tswith Postgres or MySQL. - Allow writes (carefully).
run-query.tsblocks non-SELECTSQL by default. - Add a workflow. Wrap introspect + query in a workflow with a typed result.
- Swap the model. Change the
modelfield on the agent.