Giter Club home page Giter Club logo

gpt-db-integration's Introduction

GPT <-> Database Q&A

Overview

This repository hosts a proof of concept for integrating OpenAI's ChatGPT with an Azure SQL Database to facilitate answering questions using data within the database. The integration aims to provide a seamless natural language querying interface.

Demo

Demo.mp4

Security and Credentials

As part of our commitment to security best practices, the server credentials and API key used during the development of this POC have been permanently deleted and are no longer available. You should create your SQL Database and have your own Open AI api key.

Workflow

The process flow of the integration is detailed in the workflow diagram included in the repository. Each step in the workflow is implemented as a function in src/gpt_db_assistant.py, with comments in the code that correspond to the description in the workflow boxes.

plot

Detailed Workflow Steps:

  1. User makes a question (Actor): The interaction begins with the user's natural language question.
  2. GPT receives the question: ChatGPT processes the question and gathers necessary information from the database tables.
  3. GPT returns a query: ChatGPT formulates a SQL query to retrieve the answer from the database.
  4. The query is executed: The SQL query is run against the Azure SQL Database.
  5. Query Execution Feedback Loop:
    • If the query is successful, the result is submitted back to GPT to check if it answers the user's question.
    • If the query fails, ChatGPT attempts to generate a new query. This error handling loop continues for a maximum of three attempts before concluding to restart the process.
  6. Answering the User's Question:
    • If the query result is satisfactory, ChatGPT returns the final answer to the user.
    • If after three attempts the result is still not satisfactory, the process concludes and a restart is suggested.

Repository Structure

  • notebooks: Contains Jupyter notebooks for exploratory purposes and initial testing.
  • src: Includes the main Python code.

How to Use

  1. Set up an Azure SQL Database with the necessary data.
  2. Obtain an API key from OpenAI for accessing ChatGPT.
  3. Clone this repository to your local machine.
  4. Update the src/config.ini file
  5. Install the dependencies listed in requirements.txt.
  6. streamlit run src/main.py

gpt-db-integration's People

Contributors

matheuscoradinimf avatar

Stargazers

 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.