boluo2077/deep-rag
Acerca de
๐ Deep RAG: Advanced Retrieval-Augmented Generation system that goes beyond vector search. Enables AI to perform multi-hop reasoning, negation queries, numerical comparisons & global aggregation on your knowledge base. Supports OpenAI, Anthropic, Google Gemini. Python FastAPI + React UI
Desarrollo web y de aplicacionesWhat you can do
- Negation Queries ("except", "besides") - โ - โ
- Numerical Comparison ("greater than", "less than") - โ - โ
- Finding Extremes ("maximum", "minimum") - โ - โ
- Cross-document Comparison - โ - โ
Crecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +2
- in 1 month
- Recopilando historial
Cambios netos en perรญodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interรฉs, no calidad.
README.md
Original๐ Deep RAG: Teaching AI to Truly "Understand" Your Knowledge Base
[ English | ไธญๆ ]
Features โข Quick Start โข How It Works โข Architecture โข Configuration

๐ธ Click to see more example images

๐ Why Deep RAG?
The Problem with Traditional RAG
Traditional RAG systems:
- โ Split documents into fragments, losing structure
- โ Can only "find similar" content, not "find opposite"
- โ Struggle with numerical comparisons and negation logic
- โ Cannot perform multi-hop reasoning across documents
- โ Lack global understanding for aggregation queries
The Deep RAG Solution
Traditional RAG: Fragment documents โ Retrieve chunks โ Feed to model
Deep RAG: Preserve structure โ Give model a "map" โ Let model navigate
Deep RAG provides:
- โ File Summary as Knowledge Map: LLM sees the entire structure
- โ Active Navigation: Model retrieves what it needs, when it needs it
- โ Multi-round Retrieval: Supports complex multi-hop reasoning
- โ Complete Context: Retrieves full files/directories, not fragments
Want to learn more about
Deep RAG? Welcome to read the intuitive and easy-to-understand article: ๐ Deep RAG: Teaching AI to Truly "Understand" Your Knowledge Base
๐ฏ Features
Core Capabilities
| Capability | Traditional RAG | Deep RAG |
|---|---|---|
| Negation Queries ("except", "besides") | โ | โ |
| Numerical Comparison ("greater than", "less than") | โ | โ |
| Finding Extremes ("maximum", "minimum") | โ | โ |
| Cross-document Comparison | โ | โ |
| Temporal Reasoning ("last year", "previous") | โ | โ |
| Multi-turn Memory | โ | โ |
| Multi-hop Reasoning | โ | โ |
| Global Aggregation | โ | โ |
Technical Features
- ๐ Universal LLM Support: OpenAI, Anthropic, Google Gemini, or any OpenAI-compatible API
- ๐ ๏ธ Dual Tool Calling Modes: Function Calling + ReAct
- ๐จ Modern Web UI: Built with React + TypeScript + Vite
- โก Streaming Responses: Real-time response streaming
- ๐ง Easy Configuration: Web-based .env editor
- ๐ Tool Call Visualization: See what the AI is doing
๐ Quick Start
Prerequisites
- Python 3.8+
- Node.js 16+
- An LLM API Key (OpenAI, Google Gemini, Anthropic, or compatible)
Installation
- Clone the repository
git clone https://github.com/boluo2077/deep-rag.git
cd deep-rag
- Configure environment variables
cp .env.example .env
# Edit .env with your API keys
- Start the application
./start.sh
Quick start (skip dependency checks):
./start.sh --fast
The script will:
- โ Create Python virtual environment
- โ Install backend dependencies
- โ Install frontend dependencies
- โ Start backend server (http://localhost:8000)
- โ Start frontend dev server (http://localhost:5173)
- โ Open browser automatically
Manual Start (Alternative)
Backend:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn backend.main:app --host 0.0.0.0 --port 8000
Frontend:
cd frontend
npm install
npm run dev
Stop/Restart
./stop.sh
./restart.sh
./restart.sh --full
๐ก How It Works
1. Knowledge Base Structure
Instead of splitting documents into chunks, Deep RAG preserves your file structure:
Knowledge-Base/
โโ Product-Line-A-Smartwatch-Series/
โ โโ SW-2100-Flagship.md
โ โโ SW-1800-Business.md
โ โโ SW-1500-Sport.md
โโ 2023-Market-Layout/
โ โโ East-China-Region.md
โ โโ South-China-Region.md
โโ Supplier-Partnership-Records/
โโ Display-Supplier-CrystalVision.md
2. File Summary Generation
Generate a structured summary of your knowledge base:
cd Knowledge-Base-File-Summary
python generate.py
This creates a "knowledge map" that looks like:
Product-Line-A-Smartwatch-Series/
โโ SW-2100-Flagship.md: 2.1" AMOLED, 72h battery, IP68, $2999
โโ SW-1800-Business.md: 1.8" LCD, 48h battery, IP67, $1899
โโ SW-1500-Sport.md: 1.5" TFT, 36h battery, IP68, $999
3. System Prompt Integration
The file summary is injected into the system prompt, giving the LLM:
- ๐ Overview of all available knowledge
- ๐บ๏ธ File paths for targeted retrieval
- ๐ฏ Ability to plan multi-step queries
4. Active Retrieval
When answering questions, the LLM can:
retrieve_files([
"Product-Line-A-Smartwatch-Series/SW-2100-Flagship.md", # Specific file
"2023-Market-Layout/", # Entire directory
"/" # All files
])
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (React) โ
โ โข Chat Interface โข Config Panel โข System Prompt Viewer โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/SSE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend (FastAPI) โ
โ โข LLM Provider Abstraction โข Tool Calling Handler โ
โ โข Knowledge Base Manager โข ReAct Mode Support โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโดโโโโโ โโโโโดโโโโ โโโโโดโโโโ
โKnowledgeโ โ LLM โ โ Tools โ
โ Base โ โ API โ โ(Func/ โ
โ Files โ โ โ โReAct) โ
โโโโโโโโโโโ โโโโโโโโโ โโโโโโโโโ
Project Structure
deep-rag/
โโโ backend/ # FastAPI backend
โ โโโ main.py # API endpoints
โ โโโ config.py # Configuration management
โ โโโ llm_provider.py # LLM provider abstraction
โ โโโ knowledge_base.py # Knowledge base operations
โ โโโ prompts.py # System prompts & tools
โ โโโ react_handler.py # ReAct mode handler
โ โโโ models.py # Pydantic models
โโโ frontend/ # React frontend
โ โโโ src/
โ โ โโโ App.tsx # Main app component
โ โ โโโ components/ # React components
โ โ โโโ api.ts # API client
โ โโโ package.json
โโโ Knowledge-Base/ # Your documents
โโโ Knowledge-Base-Chunks/ # Chunked documents (optional)
โโโ Knowledge-Base-File-Summary/
โ โโโ generate.py # Summary generator
โ โโโ summary.txt # Generated summary
โโโ .env.example # Environment config template
โโโ requirements.txt # Python dependencies
โโโ start.sh # Start script
โโโ stop.sh # Stop script
โโโ restart.sh # Restart script
โ๏ธ Configuration
Environment Variables
Edit .env to configure:
# LLM Provider (openai, google, anthropic, custom)
API_PROVIDER=google
# Tool Calling Mode (function, react)
TOOL_CALLING_MODE=function
# Model Parameters
TEMPERATURE=0
MAX_TOKENS=8192
# Knowledge Base Paths
KNOWLEDGE_BASE_PATH=./Knowledge-Base
KNOWLEDGE_BASE_FILE_SUMMARY=./Knowledge-Base-File-Summary/summary.txt
# Google Gemini
GOOGLE_API_KEY=your_google_key
GOOGLE_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai
GOOGLE_MODEL=gemini-2.5-flash-lite
# OpenAI
OPENAI_API_KEY=your_openai_key
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4.1-mini
# Anthropic Claude
ANTHROPIC_API_KEY=your_anthropic_key
ANTHROPIC_BASE_URL=https://api.anthropic.com/v1
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
# Custom Provider (any OpenAI-compatible API)
CUSTOM_API_KEY=your_api_key
CUSTOM_BASE_URL=https://your-api.com/v1/chat/completions
CUSTOM_MODEL=your-model
Adding New LLM Providers
No code changes needed! Just add to .env:
PROVIDER_NAME_API_KEY=your_key
PROVIDER_NAME_BASE_URL=https://api.provider.com/v1
PROVIDER_NAME_MODEL=model-name
API_PROVIDER=provider_name
Tool Calling Modes
Function Calling Mode (Recommended)
- For models with native function calling support
- Examples: GPT-4+, Gemini 1.5+, Claude 3.5+
- More reliable and structured
ReAct Mode
- For models without function calling
- Uses prompt-based reasoning and action
- Compatible with any text-completion model
Explorar proyectos relacionados
Cargandoโฆ