Skip to content

gaurav-patil-git/08_SQL_AI_Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– SQL AI Agent | Consumer Goods

Engineer user interface equipped SQL AI Agent with MySQL Workbench integration to generate complex queries. This agent will empower Business/Data Analysts to answer important business questions and facilitate decision making.

πŸ“Œ Table of Contents


Overview

This project aims to design and develop user interface equipped SQL AI Agents with an integration of MySQL Workbench to generate complex SQL statements. This user-friendly and time efficient program will help Business/Data Analysts to answer ad-hoc requests and facilitate decision making.

  • Design the entire workflow and Use CrewAI to develop SQL Agent
  • Integrate the agent with MySQL workbench
  • Develop a low design user interface (UI) using Tkinter

πŸ› οΈ Tools & Technologies

Tool/Platform Purpose
Google AI Studio API Key
CrewAI Develop AI Agents
Tkinkter User Interface
ChatGPT & Copilot Code Assistance
Power BI Visualization
Gamma AI Presentation

πŸ€– Engineering AI Agents

Defining Workflow

workflow

Developing Agents

Step 1: Generate API Key

generate-api-key

Step 2: Prepare and Test LLM

from crewai import LLM
llm = LLM(
    model= "gemini/gemini-2.0-flash",
    temperature= 0.1,
    api_key= GEMINI_API_KEY
)
llm.call("What is the full name of APJ Abdul Kalam")

Step 3: Engineer SQL AI Agent

agent = Agent(
    llm= llm,
    role="MySQL Query Generator",
    goal= "Generate MySQL queries based on user input.",
    backstory= "You are an SQL expert who writes efficient MySQL queries based on user requirements."
)

task = Task(
    description= f"""Generate an MySQL query based on the following user input:
    '''{user_input}'''
    """,
    agent= agent,
    expected_output= "A valid MySQL query that completes the task described in the user input"
)

crew = Crew(
    agents= [agent],
    tasks= [task]
)
result = str(crew.kickoff().raw).replace("```sql", "").replace("```", "").strip()
result

Step 4: Connecting SQL Agent with MySQL Workbench

  • Used Prompt 1 to generate code and connect MySQL Workbench

Step 5: Developing Interface

  • Used Prompt 2 to integrate agent and develop a Tkinter GUI.

gui-interface

πŸ“ˆ Business Questions & Key Findings

Define business question:

  • Business question: Leadership wants to know the total number of newly launched products accross segments and their contribution in revenue.
  • Input prompt:
Generate a query to compute the increae in unique product counts in each segments in F.Y. 2021 and
how much revenue the new products contributed in whole of each segment.
Output:
segment | unique_products_2020 | unique_products_2021 | new_unique_products | total_revenue_2021 | revenue_by_new_products | pct_of_total_revenue | rest_revenue

Designing presentation using Gamma AI

  • Used Prompt 3 to design presentation slide

gamma-draft-ppt

  • Modified and Changed the final formatting with company standard

presentation-slide

πŸ“ Author & Contact

Gaurav Patil (Data Analyst)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published