This repository contains a Python script for interactive SQL query generation using OpenAI's GPT models and executing the generated queries on a PostgreSQL database using SQLDatabaseChain.
Before running the script, ensure you have the following dependencies installed:
- Python 3.x
langchain
environ
- PostgreSQL (with appropriate credentials)
- OpenAI API key
You can install the dependencies via pip:
pip install langchain environ
Make sure to update the following information in the script:
API_KEY
: Provide your OpenAI API key.- Database URI: Update the database URI to connect to your PostgreSQL database.
- Clone the repository:
git clone https://github.com/your-username/sql-query-generation.git
cd SQL-chatbot-Using-LLM
-
Update the script with your OpenAI API key and database URI.
-
Run the Python script
main.py
:
python main.py
This script allows users to interactively input prompts/questions. The script then utilizes OpenAI's GPT model to generate syntactically correct PostgreSQL queries based on the input prompts. These generated queries are executed on a PostgreSQL database, and the results are displayed back to the user.
- User prompts/questions.
- Syntactically correct SQL queries generated by the GPT model.
- Results of executing the generated SQL queries on the PostgreSQL database.
Contributions are welcome! If you have suggestions, feature requests, or bug fixes, please feel free to open an issue or create a pull request.