An intelligent, conversational data agent capable of querying a local SQL database to answer business questions about customers, orders, and deliveries.
Built with Python, LangGraph, Groq (Llama 3), and Streamlit.
- Natural Language to SQL: Translates plain English questions into secure SQL queries.
- Dynamic Schema Awareness: The agent reads the database structure in real-time instantly adapting if the tables change.
- Read-Only Safety: Uses strictly read-only connections to prevent accidental data modification.
- Dual Interface:
- Web UI: A user-friendly chat interface built with Streamlit.
- CLI: A terminal-based mode for developer testing.
- Memory: Retains conversation context to answer follow-up questions.
-
LLM: Llama 3.3 (via Groq API)
-
Orchestration: LangGraph & LangChain
-
Database: SQLite
-
Frontend: Streamlit
-
Environment: Python 3.9+
git clone <your-repo-url>
cd Conversational-Text-to-SQL-Agent- For MacOS/Linux.
python -m venv venv
source venv/bin/activatepip install -r requirements.txt- Rename .env.local -> .env.
- Fill with your API Keys as requested in the .env file.
python3 ingest.py- For the app:
streamlit run app.py- For the CLI:
python3 main.py.
├── agent/ # The Agent
│ ├── graph.py # LangGraph workflow definition
│ ├── prompt.py # System prompts and rules
│ ├── state.py # AgentState definition
│ └── tools.py # SQL execution tools
├── data/ # The data
│ ├── data.csv
│ └── ...
├── database/ # Data storage
│ └── database.sqlite # The SQLite file
├── .env # API Keys (GitIgnored)
├── app.py # Streamlit App
├── ingest.py # Data loading script
├── main.py # CLI App
└── requirements.txt # Python dependencies