How yverma-datamax/sql-rag-agent- works
This is a notebook-driven, local SQL RAG agent for querying a seeded e-commerce SQLite database in natural language. Its principal workflow retrieves schema context, generates SQL with Ollama, executes it with correction retries, then presents results; the README also documents visualization and RAG-versus-baseline evaluation. The notebook is documented as the entry point, but its source was not sampled, so its internal wiring is shown only at the capability level.
Main entry points: rag_utils.py SQL RAG agent · sql_rag_agent.ipynb Agent notebook · seed_db.py Database seeder
Components 11
Query workflow
- Agent notebook
notebooks/sql_rag_agent.ipynb - SQL RAG agent
src/rag_utils.py - Schema retriever
src/rag_utils.py - SQL generator
src/rag_utils.py - Query executor
src/rag_utils.py
Data layer
- Database seeder
src/seed_db.py - E-commerce SQLite
Notebook outputs
- Charts and results
notebooks/sql_rag_agent.ipynb - RAG evaluation
notebooks/sql_rag_agent.ipynb
Local model
- Ollama
Other components
- Questioner
Connections 14
- Questioner → Agent notebook: asks
- Agent notebook → SQL RAG agent: calls
- SQL RAG agent → Schema retriever: retrieves schemas
- SQL RAG agent → SQL generator: generates SQL
- SQL RAG agent → Query executor: executes SQL
- SQL RAG agent → SQL generator: requests correction
- Schema retriever → E-commerce SQLite: reads schema
- Schema retriever → Ollama: requests embeddings
- SQL generator → Ollama: requests SQL
- Query executor → E-commerce SQLite: runs query
- Database seeder → E-commerce SQLite: creates and populates
- Agent notebook → Charts and results: presents results
- Agent notebook → RAG evaluation: compares SQL success
- SQL RAG agent → Agent notebook: returns rows and SQL