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.
Setup a MySQL database using db_setup.sql file in sql_setup folder. It should create three tables as below -
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
-
Download and install
Azure CLI- Azure Cli -
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.
-
Create a resource group to use for this project
az group create --name RG_OPENAI_TEST --location eastus2
-
Create an Azure OpenAI account, use the previously created
Resource Groupaz cognitiveservices account create --name OpenAIProject0924 \ --resource-group RG_OPENAI_TEST --kind OpenAI --sku S0 --location eastus2 -
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
-
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 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
Find sales by each month
Find sales by each month and state, then pivot result for states