Jeremy Live
template
f639c56
|
raw
history blame
3.27 kB

Chatbot Agent with SQL and Gemini Integration

License: MIT Python 3.8+ Gradio

A powerful chatbot agent that integrates Google's Gemini language model with SQL database connectivity, enabling natural language to SQL query conversion and data visualization.

🌟 Features

  • Natural Language to SQL: Convert natural language questions into SQL queries
  • Database Integration: Connect to MySQL databases seamlessly
  • Interactive Chat Interface: User-friendly Gradio-based web interface
  • Data Visualization: Generate visualizations from query results
  • Environment Configuration: Easy setup with environment variables

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • MySQL database (or compatible database)
  • Google API key for Gemini

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/chatbot-agent-sql-gemini.git
    cd chatbot-agent-sql-gemini
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file in the project root with your configuration:

    DB_USER=your_db_username
    DB_PASSWORD=your_db_password
    DB_HOST=your_db_host
    DB_NAME=your_database_name
    GOOGLE_API_KEY=your_google_api_key
    

Running the Application

  1. Start the application:

    python app.py
    
  2. Open your web browser and navigate to http://localhost:7860

πŸ› οΈ Configuration

The application can be configured using the following environment variables:

Variable Description Required
DB_USER Database username βœ…
DB_PASSWORD Database password βœ…
DB_HOST Database host βœ…
DB_NAME Database name βœ…
GOOGLE_API_KEY Google API key for Gemini βœ…

πŸ“¦ Dependencies

  • gradio >= 3.0.0
  • langchain >= 0.1.0
  • langchain-community >= 0.0.10
  • langchain-google-genai >= 0.1.0
  • langgraph >= 0.0.0
  • matplotlib >= 3.7.0
  • pandas >= 2.0.0
  • sqlalchemy >= 2.0.0
  • python-dotenv >= 1.0.0

πŸ€– How It Works

  1. The application connects to your SQL database using the provided credentials
  2. Users input natural language questions through the Gradio interface
  3. The Gemini model converts these questions into SQL queries
  4. Queries are executed against the database
  5. Results are formatted and displayed to the user
  6. For appropriate data, visualizations are automatically generated

πŸ“ Example Queries

  • "Show me the top 10 customers by total purchases"
  • "What were our total sales last month?"
  • "List all products with stock below minimum levels"
  • "Generate a bar chart of monthly sales for the past year"

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments