u/Bigdrums

Query Builder for Agents

Query Builder for Agents

Just wanted to share a little Laravel package I've been working on: https://github.com/J-T-McC/ai-query-builder

The idea is to let AI query your Laravel data securely without giving it direct access to SQL. You define the schema, relationships, allowed operations, etc, then the AI generates a structured query that gets validated and turned into an Eloquent query.

It can also be easily added to the Laravel AI SDK as a tool.

The schema can be adjusted programmatically for each user based on what they're permitted to access, and you can also define hard scoping conditions that always apply to the query, like limiting results to the current user's data.

Some use cases I've been playing with are letting users search their calendar in plain English, building custom reports, or just asking questions about their data in your app.

Still pretty early, but I've been having fun with it and figured I'd share it here. I'm curious what other tools or packages people have been using for this kind of thing.

u/Bigdrums — 8 days ago