Spaces:
Sleeping
Sleeping
File size: 3,707 Bytes
f9ad313 a00009c f9ad313 a00009c f9ad313 |
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 106 107 108 109 110 111 112 |
---
title: OnceDataBot
emoji: π€
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
app_port: 7860
---
# π€ OnceDataBot
A production-grade, **schema-agnostic chatbot** that connects to **any** database (MySQL, PostgreSQL, or SQLite) and provides intelligent querying through **RAG** (Retrieval-Augmented Generation) and **Text-to-SQL**.
**π Powered by Groq for FREE LLM inference!**
## π Features
- **Multi-Database Support**: Works with **MySQL**, **PostgreSQL**, and **SQLite**
- **Schema-Agnostic**: Works with ANY database schema - no hardcoding required
- **Dynamic Introspection**: Automatically discovers tables, columns, and relationships
- **Hybrid Query Routing**: Intelligently routes queries to RAG or SQL based on intent
- **Semantic Search (RAG)**: FAISS-based vector search for text content
- **Text-to-SQL**: LLM-powered SQL generation with dialect-specific syntax
- **Security First**: Read-only queries, SQL validation, table whitelisting
- **FREE LLM**: Uses Groq API (free tier) with Llama 3.3, Mixtral, and Gemma models
## π Getting Started
### 1. Configure Secrets
This Space requires the following secrets to be set in your Hugging Face Space settings:
**Required:**
| Secret Name | Description |
|------------|-------------|
| `GROQ_API_KEY` | Your Groq API key ([Get FREE key](https://console.groq.com)) |
**Database Configuration (choose one):**
#### For MySQL:
| Secret Name | Description |
|------------|-------------|
| `DB_TYPE` | Set to `mysql` |
| `DB_HOST` | MySQL server hostname |
| `DB_PORT` | MySQL port (default: 3306) |
| `DB_DATABASE` | Database name |
| `DB_USERNAME` | Database username |
| `DB_PASSWORD` | Database password |
#### For PostgreSQL:
| Secret Name | Description |
|------------|-------------|
| `DB_TYPE` | Set to `postgresql` |
| `DB_HOST` | PostgreSQL server hostname |
| `DB_PORT` | PostgreSQL port (default: 5432) |
| `DB_DATABASE` | Database name |
| `DB_USERNAME` | Database username |
| `DB_PASSWORD` | Database password |
#### For SQLite:
| Secret Name | Description |
|------------|-------------|
| `DB_TYPE` | Set to `sqlite` |
| `SQLITE_PATH` | Path to SQLite database file |
**Optional:**
| Secret Name | Description | Default |
|------------|-------------|---------|
| `GROQ_MODEL` | Groq model to use | `llama-3.3-70b-versatile` |
| `DB_SSL_CA` | Path to SSL CA certificate | None |
### 2. Connect & Use
1. Click **"Connect & Initialize"** in the sidebar
2. Click **"Index Text Data"** to enable semantic search
3. Start asking questions about your data!
## π¬ Example Queries
**Semantic Search (RAG):**
- "What products are related to electronics?"
- "Tell me about customer feedback on shipping"
**Structured Queries (SQL):**
- "How many orders were placed last month?"
- "Show me the top 10 customers by revenue"
**Hybrid:**
- "Find customers who complained about delivery and show their order count"
## π Security
- **Read-Only Transactions**: All queries run in read-only mode
- **SQL Validation**: Only SELECT statements allowed
- **Forbidden Keywords**: INSERT, UPDATE, DELETE, DROP, etc. are blocked
- **Table Whitelisting**: Only discovered tables are queryable
- **Automatic LIMIT**: All queries have LIMIT clauses enforced
## π Why Groq?
[Groq](https://console.groq.com) provides **FREE API access** with incredibly fast inference:
- **Llama 3.3 70B** - Best quality, state-of-the-art
- **Llama 3.1 8B Instant** - Fastest responses
- **Mixtral 8x7B** - Great for code and SQL
- **Gemma 2 9B** - Google's efficient model
## π License
MIT License
|