Local SQL Agent with LLM Feedback
A robust AI agent designed to bridge the gap between non-technical users and relational databases. The system translates plain English questions into complex SQL queries using local LLMs (Llama 3). It features a unique 'self-healing' loop: if a generated query fails, the agent captures the database error, analyzes it, and iteratively refines the SQL code until a successful execution is achieved.
Key Features
- Natural Language to SQL translation for relational database querying
- Self-healing execution loop with automated error feedback and query refinement
- Schema-aware prompting with support for complex JOINs and aggregations
- Privacy-focused local LLM integration using Ollama and LangChain
- Automated database initialization and mock data management for testing
- Robust response parsing to ensure clean, executable code generation
Tech Stack
PythonLangChainOllama (Llama 3)SQLite3SQLPrompt Engineering
Screenshots
