https://github.com/user-attachments/assets/0260ee61-50da-41ba-aead-e9197d4b5947
Natural language querying allows users to interact with databases more intuitively and efficiently. By leveraging the power of LangChain, SQL Agents, and OpenAI’s Large Language Models (LLMs) like ChatGPT, we have created an application that enables users to query databases using NLP. All it needs a SQL-based schema, and it can perform any read and write action to that schema.
This is an experimental app to test the abilities of LLMs to query SQL databases using SQL Agents provided by Langchain. To use it, you should have an OPENAI_API_KEY.
After cloning the repo, change the directory to nest_api, and add a .env file.
OPENAI_API_KEY=sk-xxx
# Docker environment variables
DB_TYPE=postgres
PG_HOST=postgres
PG_USER=postgres
PG_PASSWORD=postgres
PG_DB=postgres
PG_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
PGADMIN_DEFAULT_EMAIL=admin@pgadmin.com
PGADMIN_DEFAULT_PASSWORD=admin
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=pass12345
MONGO_URL=mongodb://root:pass12345@mongodb:27017/chatwithdb?authSource=admin
PORT=5000
Build the image using
docker-compose build --no-cache
Run Container with the build image
docker-compose up
Open PgAdmin to upload your Database (I will use *.tar file to upload the whole database, you could use any method, and just remember to name the database as mentioned in .env. In my case it is postgres)
On localhost:5050
, login to PgAdmin
Create a server group
Then register server
Now restore the database to upload the file
After restoring, all the tables will be shown
Run the frontend after changing the directory to the client and then using npm run dev
, available at localhost:3000
Register and then Sign-in, the application will be redirected towards /chat
URL
According to your schema write any prompt to generate an SQL query and the results database contains
Contributions to this project are highly encouraged and appreciated. To help us maintain a high level of quality, please follow these contribution guidelines:
Please follow the contribution guidelines outlined in the Contributing.md file in this repository, to make sure that your contributions align with the project standards.
This project is licensed under the MIT License.