File size: 3,274 Bytes
f639c56 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# Chatbot Agent with SQL and Gemini Integration
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://gradio.app/)
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:
```bash
git clone https://github.com/yourusername/chatbot-agent-sql-gemini.git
cd chatbot-agent-sql-gemini
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Create a `.env` file in the project root with your configuration:
```env
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:
```bash
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](LICENSE) file for details.
## π Acknowledgments
- [Gradio](https://gradio.app/) for the web interface
- [Google Gemini](https://ai.google.dev/) for the language model
- [LangChain](https://www.langchain.com/) for the agent framework
|