Skip to content

jieying-tech/SQL-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM-Powered SQL Agent with RAG

An AI agent for natural language-to-SQL generation with RAG capabilities

About the Project

An LLM-powered AI agent that combines SQL database querying with RAG-based business rule retrieval to deliver accurate, context-aware insights through an interactive web app.

Demo

Live app: https://sql-agent-rag.streamlit.app/

Built with

Prerequisites

Setup

  1. Install the python packages:
pip install -r requirements.txt
  1. Create a .env file in the root directory of the project:
# Data Paths
DATABASE_URL="data/ecommerce.db"
BUSINESS_RULES_URL="data/business_rules.md"
BUSINESS_RULES_INDEX_URL="data/faiss_index"

# Agent Settings
MAX_CONTEXT_MESSAGES=3
RECURSION_LIMIT=25

# Model Providers
AVAILABLE_MODEL_PROVIDERS="OLLAMA,GROQ,HUGGINGFACE,OPENROUTER"
MODEL_PROVIDER="OLLAMA"

# GROQ
GROQ_API_KEY=""
GROQ_MODEL_NAME="llama-3.3-70b-versatile"

# HUGGINGFACE
HUGGINGFACEHUB_API_TOKEN=""
HUGGINGFACE_MODEL_NAME="deepseek-ai/DeepSeek-V3"
HUGGINGFACE_BASE_URL="https://router.huggingface.co/v1"

# OPENROUTER
OPENROUTER_API_KEY=""
OPENROUTER_MODEL_NAME="openai/gpt-oss-120b:free"
OPENROUTER_BASE_URL="https://openrouter.ai/api/v1"

# OLLAMA
OLLAMA_MODEL_NAME="qwen3.5:9b"
OLLAMA_BASE_URL="http://localhost:11434"

Usage

  1. Run the streamlit app:
streamlit run app.py
  1. Open the app with a browser at localhost:8501

About

An AI agent for natural language-to-SQL generation with RAG capabilities

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages