Giter VIP home page Giter VIP logo

azure-openai-sql's Introduction

SQL Query Generator with GPT-4 and Streamlit

This project showcases the capabilities of combining OpenAI's GPT-4 with Streamlit to generate SQL queries based on natural language input. Users can enter a message describing the data they want to query from an SQLite database, and the application will display the generated SQL query as well as the results from the database.

Table of Contents

Features

  • Natural Language to SQL: Uses GPT-4 to transform user's natural language input into an SQL query.
  • Streamlit Interface: Provides a simple and intuitive interface for users to input their queries.
  • SQLite Backend: Uses SQLite as the database backend to store and query the financial data.

Prerequisites

  • Python 3.6 or above
  • Virtual Environment (recommended)

Installation

  1. Clone the Repository:

    git clone https://github.com/NikhilSehgal123/Azure-OpenAI-SQL.git
  2. Set up a Virtual Environment (optional but recommended):

    python -m venv .venv
    source .venv/bin/activate  # On Windows, use: .venv\Scripts\activate
  3. Install the Dependencies:

    pip install -r requirements.txt
  4. Set up Environment Variables:

    If you're using any external services like Azure or APIs, make sure you have the credentials set up as environment variables or stored safely.

Usage

  1. Run the Streamlit App:

    streamlit run main_app.py
  2. Open the displayed URL in your browser, usually http://localhost:8501.

  3. Type in your natural language query into the input box, like "Show me all expenses greater than 1000".

  4. View the generated SQL query and the results from the database.

How It Works

  1. SQLite Database:

    The app uses SQLite to create a table representing a company's finances. It holds fields like revenue, expenses, and profit.

  2. Schema Retrieval:

    Before generating a query, the system retrieves the schema of the table from SQLite to understand its structure.

  3. GPT-4 Model:

    The main functionality relies on the GPT-4 model to convert a user's natural language input into an SQL query. The app sends a formatted message containing the table's schema to GPT-4, which then returns an appropriate SQL query.

  4. Query Execution:

    The app then executes the generated SQL query on the SQLite database and retrieves the results.

Contributing

Feel free to fork this repository, create a feature branch, and submit a pull request if you have improvements or fixes you'd like to share.

License

This project is open source, under the MIT license.

azure-openai-sql's People

Contributors

nikhilsehgal123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.