This project is an AI-powered SQL query agent that can answer natural language questions by querying a SQLite database. It utilizes the LangChain library and various language models, such as ChatGroq and ChatOpenAI, to generate SQL queries and provide responses. Additionally, it integrates with Langsmith for tracing and feedback collection.
Prerequisites
- Python 3.7 or higher
- SQLite client
-
Create API keys for your desired LLM and also for Langsmith.: Create your LLM keys for the desired language model of your choice.
Create your Langsmith API key by signing up for a free account at https://langsmith.com/signup.
-
Clone the repository
git clone https://github.com/your-repo/sql-query-agent.git cd sql-query-agent -
Install dependencies
pip install -r requirements.txt -
Set up environment variables
- Rename the
.env_examplefile to.env - Fill in the required API keys and configuration values in the
.envfile
- Create the Chinook.db database
sqlite3 Chinook.db SQLite version 3.44.0 2023-11-01 11:23:50 Enter ".help" for usage hints. sqlite>.read Chinook_Sqlite.sql
-
Run the project
python main.py -
Enter a question When prompted, enter a natural language question related to the SQLite database.
-
Rate the response After receiving the answer, rate the response on a scale of 1-5.
-
Provide feedback (optional) You can optionally provide comments or feedback for the response.
The project will trace the execution using Langsmith and collect feedback for future improvements.