Skip to content

ankushseal/SQL-chatbot-Using-LLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Chat with your database using Generative AI

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.

Prerequisites

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

Configuration

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.

Usage

  1. Clone the repository:
git clone https://github.com/your-username/sql-query-generation.git
cd SQL-chatbot-Using-LLM
  1. Update the script with your OpenAI API key and database URI.

  2. Run the Python script main.py:

python main.py

Description

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.

Input

  • User prompts/questions.

Output

  • Syntactically correct SQL queries generated by the GPT model.
  • Results of executing the generated SQL queries on the PostgreSQL database.

Screenshot

IMG-20230701-WA0000

IMG-20230701-WA0001

IMG-20230701-WA0002

IMG-20230701-WA0003

IMG-20230701-WA0004

IMG-20230701-WA0005

Contributing

Contributions are welcome! If you have suggestions, feature requests, or bug fixes, please feel free to open an issue or create a pull request.

Acknowledgements

  • langchain - Python library for chaining together language models and databases.
  • environ - Python library for handling environment variables.
  • OpenAI - Python library for accessing OpenAI's GPT models.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages