Skip to content

AI assistant to help solve analytical questions by building sq queries against the target database and execute.

License

Notifications You must be signed in to change notification settings

anupkg1985/sql-aix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL-AIX

SQL-AIX is an AI assistant to help solve analytical questions by building SQL queries against the target database and execute. Build SQL AI assistant using the power of LLM and tools.

Database Setup

Setup a MySQL database using db_setup.sql file in sql_setup folder. It should create three tables as below -

Screenshot 2024-09-02 at 1 27 59 PM

I've used the MySQL Docker image to spin up the SQL instance locally. You can find the latest Docker image here.

docker pull mysql

Azure OpenAI setup

  1. Download and install Azure CLI - Azure Cli

  2. Log in to Azure Cli using terminal

    az login

    You will be redirected to the browser to login, once logged in you will come back to terminal. Select a subscription and tenant from availbale list of subscriptions.

  3. Create a resource group to use for this project

    az group create --name RG_OPENAI_TEST --location eastus2
  4. Create an Azure OpenAI account, use the previously created Resource Group

    az cognitiveservices account create --name OpenAIProject0924 \
    --resource-group RG_OPENAI_TEST --kind OpenAI --sku S0 --location eastus2
    
  5. Create GPT-4o deployment

    az cognitiveservices account deployment create --resource-group RG_OPENAI_TEST \
    --name OpenAIProject0924 --deployment-name gpt-40 --model-version 2024-05-13 \
    --model-format OpenAI --sku-capacity 1 --sku-name Standard
  6. Find the model endpoint and keys

    az cognitiveservices account keys list \
    --resource-group RG_OPENAI_TEST --name OpenAIProject0924
    az cognitiveservices account show \
    --resource-group RG_OPENAI_TEST --name OpenAIProject0924

Replace with this endpoint and keys in the code.

Test the code

Test using simple to medium comlex question again the database. Prompt might need some more fine tunning to achive desired results. Ultimately functionality can be extended by introducing more tools and providing it to LLM.

Here are the some examples tested agianst GPT-4o model.

Find top 3 products sold

Screenshot 2024-09-02 at 11 17 31 AM

Find sales by each month

Screenshot 2024-09-02 at 11 18 36 AM

Find sales by each month and state, then pivot result for states

Screenshot 2024-09-02 at 11 18 20 AM

About

AI assistant to help solve analytical questions by building sq queries against the target database and execute.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published