freshcrate
Skin:/
Home > Frameworks > PAI-RAG

PAI-RAG

An easy-to-use framework for modular RAG

Why this rank:Strong adoptionHealthy release cadenceRelease freshness

Description

An easy-to-use framework for modular RAG

README

PAI-RAG

匀源 Agentic RAG 框架让智胜检玢像呌吞䞀样简单

GitHub StarsLicense Python

囟片理解 | 联眑搜玢 | 工具调甚 | 任务规划 | MCP 集成 | Text-to-SQL

无需 ML 䞓家5 分钟构建䌁䞚级 Agentic RAG 应甚

快速匀始 | 栞心特性 | 架构总览 | 郚眲指南 | API 文档 | 联系我们


PAI-RAG Demo

䞺什么选择 PAI-RAG

PAI-RAG 是基于阿里云 PAI 平台的匀源 Agentic RAG 框架䞓泚于䌁䞚级倍杂知识倄理䞎智胜问答场景。它䞍仅是䞀䞪 RAG 系统曎是䞀䞪融合了知识库管理、倚暡态理解、ReAct 智胜䜓、MCP 工具生态的䞀站匏解决方案。

胜力 䌠统 RAG PAI-RAG
知识库管理 单文件䞊䌠切片固定 并发䞊䌠 + 劚态切片 + 元数据过滀
文档解析 仅文本 20+ 栌匏PDF / Office / 囟片 / 视频
检玢策略 向量检玢 向量 + å…šæ–‡ + 混合检玢 + Rerank
倚暡态 䞍支持 囟片理解 + 视频解析 + 囟文混合回倍
倍杂任务 简单问答 ReAct 智胜䜓 + 任务规划 + 并行工具调甚
实时信息 静态知识库 联眑搜玢阿里云 IQS / Tavily
工具生态 有限插件 MCP 深床集成客户端 + 服务端
数据分析 䞍支持 代码沙箱 + Text-to-SQL
䌁䞚胜力 高定制成本 倚租户 + RBAC + 可观测 + 匀箱即甚

栞心特性

1. 䌁䞚级知识库管理

  • 20+ 文档栌匏PDF、DOCX、PPTX、Excel、CSV、Markdown、HTML、JSONL、囟片、视频等
  • 智胜切片策略句子级、Token 级、段萜级、Markdown 感知、版面感知等倚种策略按知识库独立配眮
  • 䞉倧检玢暡匏向量检玢、党文检玢、混合检玢向量 + BM25配合 Reranker 粟排
  • 元数据过滀支持标筟、时闎、来源等倚绎床倍合条件过滀最深 5 层嵌套
  • Chunk 级管理可视化查看、猖蟑、激掻/停甚单䞪知识片段
  • FAQ 暡匏Excel 盎接富入䞺问答对适配客服等场景
  • 匂步倄理基于 Celery + Redis 的后台任务队列倧批量文件䞊䌠䞍阻塞

2. 倚暡态内容理解

  • 文档囟片自劚提取从 PDF/DOCX/PPTX 䞭提取囟片通过倚暡态倧暡型生成描述并玢匕
  • 囟片问答盎接䞊䌠囟片到知识库或䜜䞺对话附件AI 自劚理解囟片内容
  • 视频解析支持 MP4/AVI/MOV 等视频栌匏自劚提取关键垧并生成描述
  • 囟文混合生成回答䞭自劚嵌入盞关囟片生成曎䞰富盎观的结果

3. Agentic RAG 智胜䜓

  • ReAct 框架思考-行劚-观察埪环支持并行工具调甚最倧 20 步掚理
  • 思绎铟支持原生支持 Qwen3、DeepSeek-R1 等思考暡型分犻掚理过皋䞎最终回答
  • 任务规划自劚拆解倍杂倚步骀任务劂"对比 2023 幎莢报䞎行䞚趋势"
  • 流匏蟓出SSE 实时掚送工具调甚过皋透明可见

4. MCP 生态集成

  • MCP 客户端接入任意倖郚 MCP 服务噚SSE/stdio即时扩展工具胜力
  • MCP 服务端将知识库检玢暎露䞺 MCP 工具䟛倖郚 AI Agent 调甚
  • 即插即甚通过 Web UI 或 API 劚态添加/移陀 MCP 服务噚

5. 䞰富的内眮工具

工具 诎明
知识库检玢 对配眮的知识库进行 RAG 检玢
联眑搜玢 阿里云 IQS / Tavily 实时搜玢
眑页浏览 访问并解析指定 URL 内容
代码沙箱 云端 Python 沙箱支持数据分析和囟衚生成
Text-to-SQL 自然语蚀查询 MySQL/PostgreSQL 数据库
附件解析 读取分析䞊䌠的文件附件
思考掚理 结构化的反思䞎掚理
任务规划 倍杂任务的分解䞎规划

6. 䌁䞚级胜力

  • 倚租户架构所有资源按 tenant_id 隔犻适合 SaaS 倚租户郚眲
  • RBAC 权限控制甚户-角色-文档䞉级权限粟确到 Chunk 级别的访问控制
  • 内容安党集成阿里云内容安党Green自劚审查蟓入蟓出
  • 可观测性OpenTelemetry 党铟路远螪支持 OTLP/HTTP 和 OTLP/gRPC
  • OpenAI 兌容 API/v1/chat/completions 标准接口可盎接对接现有应甚

架构总览

┌──────────────────────────────────────────────────────────┐
│                    Web UI (Next.js)                       │
├───────────────────────────────────────────────────────────
│                  FastAPI Backend                          │
│  ┌─────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐  │
│  │Chat API │  │ RAG API  │  │Config API│  │ MCP API  │  │
│  │(OpenAI) │  │(Retrieval│  │(管理接口)│  │(工具服务)│  │
│  └────┬────┘  └────┬─────┘  └──────────┘  └──────────┘  │
│       │            │                                      │
│  ┌────▌────────────▌─────────────────────────────────┐   │
│  │              ReAct Agent Engine                     │   │
│  │  ┌────┐ ┌────┐ ┌────┐ ┌─────┐ ┌───┐ ┌──────────┐ │   │
│  │  │ KB │ │搜玢│ │代码│ │T2SQL│ │MCP│ │附件/倚暡态│ │   │
│  │  └──┬─┘ └──┬─┘ └──┬─┘ └──┬──┘ └─┬─┘ └────┬─────┘ │   │
│  └─────┌──────┌──────┌─────┌─────┌────────┌─────────┘   │
├────────┌──────┌──────┌─────┌─────┌────────┌──────────────
│  ┌─────▌──┐ ┌─▌──┐ ┌▌───┐ ┌▌──┐ ┌▌────┐ ┌▌────────┐   │
│  │VectorDB│ │IQS/│ │云沙│ │DB │ │倖郚  │ │文件存傚  │   │
│  │7种后端 │ │搜玢│ │ ç®± │ │   │ │MCP  │ │Local/OSS│   │
│  └────────┘ └────┘ └────┘ └───┘ └─────┘ └─────────┘   │
└──────────────────────────────────────────────────────────┘

支持的向量数据库

后端 类型 向量检玢 党文检玢 混合检玢
Chroma (本地) 嵌入匏 ✅ ❌ ❌
Milvus 云/自建 ✅ ✅ ✅
Elasticsearch 云/自建 ✅ ✅ ✅
PostgreSQL (pgvector) 云/自建 ✅ ✅ ✅
Hologres 阿里云 ✅ ❌ ❌
OpenSearch 阿里云 ✅ ❌ ❌
Tablestore 阿里云 ✅ ❌ ❌

支持的 LLM

通过 OpenAI 兌容接口支持接入任意倧语蚀暡型

  • 通义千问DashScopeQwen-Max / Qwen-Plus / Qwen-Turbo / Qwen-VL 等
  • OpenAIGPT-4o / GPT-4 / GPT-3.5 等
  • 匀源自郚眲通过 vLLM / Ollama 等郚眲的任意暡型
  • 思考暡型原生支持 Qwen3、DeepSeek-R1 等思绎铟暡型

快速匀始

Docker 郚眲掚荐

git clone https://github.com/aigc-apps/PAI-RAG.git
cd PAI-RAG/docker
cp .env.example .env
# 猖蟑 .env 配眮䜠的参数
docker compose up -d

启劚后访问 http://localhost:8680 即可䜿甚。

本地匀发

# 创建 Python 3.11 环境
conda create -n pai-rag python=3.11 && conda activate pai-rag

# 安装䟝赖
pip install poetry && poetry install

# 配眮环境变量
cp .env.example .env

# 启劚服务需芁先启劚 Redis
./scripts/start.sh --dev

阿里云 EAS 郚眲

参考 EAS 郚眲指南䞀键郚眲到阿里云 PAI-EAS。


环境变量配眮

变量 诎明 默讀倌
DB_TYPE 元数据库类型sqlite / postgresql / mysql sqlite
FILE_STORE_TYPE 文件存傚local / oss local
VECTOR_DB_TYPE 向量库local / milvus / elasticsearch / postgresql / hologres / opensearch / tablestore local
REDIS_HOST Redis 地址 localhost
USE_CUDA 是吊启甚 GPU 加速 false
MAX_RECURSION_STEPS Agent 最倧掚理步数 20
ENABLE_MINERU 启甚 MinerU 高级 PDF 解析 false

完敎配眮请参考 环境变量文档。


API 文档

PAI-RAG 提䟛 OpenAI 兌容的标准 API

# Chat Completions流匏
curl http://localhost:8682/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model",
    "messages": [{"role": "user", "content": "䜠奜"}],
    "stream": true
  }'
接口 诎明 文档
POST /v1/chat/completions 对话补党OpenAI 兌容 Chat API
POST /v1/retrieval 知识库检玢Dify 兌容 Retrieval API
POST /v1/embeddings 文本向量化 -
GET/POST /v1/knowledgebases 知识库管理 KB API
POST /v1/mcp/* MCP 工具服务 -

深入䜿甚

项目郚眲

暡型配眮

功胜指南

API 参考


项目结构

PAI-RAG/
├── backend/                 # FastAPI 后端
│   ├── api/v1/              # REST API 路由
│   ├── agent/               # ReAct 智胜䜓匕擎
│   ├── tools/               # 内眮工具检玢/搜玢/代码/SQL/附件等
│   ├── rag/                 # RAG 管线切片/向量化/重排序
│   ├── common/              # 通甚组件LLM 客户端/向量库连接噚
│   ├── service/             # 䞚务逻蟑层
│   ├── evaluation/          # RAG 评䌰框架
│   └── extensions/          # 扩展内容安党/铟路远螪
├── frontend/                # Next.js Web UI
├── integrations/
│   └── pairag-file/         # 文件解析库20+ 栌匏
├── docker/                  # Docker Compose 郚眲
├── docs/                    # 文档
└── alembic/                 # 数据库迁移

联系我们

PAI-RAG 官方钉钉矀号27370042974

DingTalk Group

Release History

VersionChangesUrgencyDate
v0.4.3## What's Changed * Support English ui * Add simple react agent * Support streamable http mcp server **Full Changelog**: https://github.com/aigc-apps/PAI-RAG/compare/v0.4.2-20260128...v0.4.3Low2/11/2026
v0.4.2-20260128## What's Changed * Add rag trace by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/803 * Add rerank span operation name by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/804 * Fix mcp contract and request-id by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/806 * Fix kb mcp api by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/807 * Refine rag trace span name by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/808 * add file parsing and FAQ by @CeceliachenLow1/28/2026
v0.4.2-202512301. Refine knowledgebases: metadata filtering, add knowledgebase mcp server 2. Upgrade code tool ## What's Changed * Update new docker version by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/756 * add DashScope reranker by @Ceceliachenen in https://github.com/aigc-apps/PAI-RAG/pull/758 * fix code tool by @Ceceliachenen in https://github.com/aigc-apps/PAI-RAG/pull/757 * Add new pdf parser by @moria97 in https://github.com/aigc-apps/PAI-RAG/pull/760 * add retrieval reranker configLow12/30/2025
v0.4.1-20251107## ✹ New Feature Code Tool Added: Enables data analysis directly on spreadsheet files (e.g., .xlsx, .csv), empowering users to explore and process structured data programmatically. ## 🛠 Improvements Enhanced QA for Attachments: Improved accuracy and responsiveness when performing question-answering over uploaded documents (e.g., images, excel). ## 🐞 Bug Fixes Fixed a hang issue in evaluation jobs, improving system reliability. Resolved special unicode character handling when persistLow11/7/2025
v0.4.0-20251024🚀 Introducing Agentic RAG! We’re excited to announce the release of Agentic RAG — a next-generation, autonomous RAG system designed to tackle complex reasoning tasks while ensuring enterprise-grade control and extensibility. ✹ Key Highlights: 🧠 Agentic Task Planning Dynamically decompose and execute multi-step reasoning workflows to handle complex, real-world queries. 📁 Advanced Knowledge Base Management Fine-grained file-level access control, secure permissioning, and full lifecyLow10/27/2025
v0.3.5-20251024Bugfixes on v0.3.4 - Fix multimodal file parsing error - Fix internal image link error - Add streaming canceled error handling - Add correlation-id in logLow10/27/2025
v0.3.4-202506121. Separate prompts for websearch/ knowledgebase 2. UI refinement.Low6/16/2025
v0.3.2-202504101. Fix excel upload error 2. Fix knowledge base limit 3. Fix elastic search timeoutLow4/10/2025
r-v0.2.0-2-20250219# 曎新抂述 以䞋䞺本次版本曎新的䞻芁内容包括每项功胜和修倍的抂述感谢所有莡献者的蟛勀工䜜。 # 䞻芁曎改 - 压猩问题描述添加了对䞭文提瀺的支持提升了问题描述的简掁性。 - 修倍 Poetry 配眮䌘化了项目的 Poetry 配眮。 - 支持 Web 怜玢意囟增区了对 Web 搜玢的意囟支持。 - 新增阿里云搜玢功胜集成了阿里云搜玢服务。 - 䌘化历史记圕功胜对历史记圕的管理进行了䌘化。 - 䌘化提瀺暡板改进了提瀺暡板的结构和内容。 - 修倍倚项问题进行了䞀系列问题修倍提升皳定性。 - 修倍查询变换及意囟检测问题解决了查询蜬换䞭的问题并移陀了意囟检测功胜。 - 修倍 V1 聊倩系统提瀺曎新和修正了聊倩功胜的系统提瀺。 - 升级阿里云访问密钥及响应解析改进了阿里云的访问密钥管理和响应解析。 - 䌘化聊倩记圕存傚改进了聊倩记圕的存傚机制。由 @moria97 提亀。 - 修倍 Markdown 树结构问题解决了 Markdown 树的匹出问题。 - 将蜬换后的查询添加到查询字笊䞲增加了将蜬换后的查询附加到查询字笊䞲的功Low2/19/2025
v0.2.0-20250212## 新功胜 - 文档倄理增区 - 增加了 PDF 和囟像的 OCR 选项提升了对䞍同文档类型的支持。 - 添加了 Markdown 树解析噚䌘化了文档的结构化倄理。 - 向量存傚扩展 - 匕入了 Tablestore 和 Dashvector 向量存傚增区了数据检玢和管理胜力。 - 搜玢功胜升级 - 支持 Deepseek 和 Quark 搜玢扩倧了搜玢的芆盖范囎和粟确床。 - 倚语蚀支持 - 添加了英文版的提瀺暡板提升了倚语蚀甚户的䜿甚䜓验。 ## 䞻芁改进 - 架构䞎性胜䌘化 - 将 Ray 任务替换䞺 actors提高了系统的并发倄理胜力和性胜。 - 对 Personal/xi/nl2sql 暡块进行了暡块化重构增区了代码的可绎技性和扩展性。 - 甚户界面䌘化 - 䌘化了参考文献的展瀺界面提升了甚户的浏览䜓验。 - 改进了聊倩页面的功胜修倍了盞关的星瀺䞎亀互问题。 - 解析噚曎新 - 曎新了 SQL 解析噚和 Markdown 解析噚增区了对倍杂语法的支持和解析准确性。 #Low2/12/2025
v1.0.0-20241206🎉 New features: - 📞 Multi-Modal QA: Experience enhanced image processing and inference capabilities. Our platform now supports responses with images for a more engaging user experience. - 🀖 Agentic RAG: Enjoy seamless function-calling and intelligent query routing, optimizing the processing and retrieval of information. - 🗃 Database Chat: Effortlessly analyze your data using our advanced text-to-SQL interface, making it easier to derive insights from your database. - 📄 Enhanced DLow12/6/2024
v0.1.0-20240802- Add OpenSearch, PostgreSQL vector db. - Add function-call support - Add ```.jsonl``` file support - Bug fixesLow8/5/2024

Dependencies & License Audit

Loading dependencies...

Similar Packages

SploitGPT🛠 Automate penetration testing with SploitGPT, an AI agent using Kali Linux tools for efficient security assessments and minimal user input.main@2026-06-07
agent-resources🛠 Install, manage, and share Claude Code skills effortlessly with one command, streamlining your workflow and enhancing team collaboration.main@2026-06-07
planning-with-files📄 Transform your workflow with persistent markdown files for planning, tracking progress, and storing knowledge like a pro.master@2026-06-07
cadwynProduction-ready community-driven modern Stripe-like API versioning in FastAPI7.0.0
aitoolmanControllable and Transparent LLM Application Frameworkmain@2026-06-06

More in Frameworks

spec_driven_developSpec-Driven Develop is a platform-agnostic AI agent skill that automates the pre-development workflow for large-scale complex tasks. It is not a framework, not a runtime, not a package manager — it is
deer-flowAn open-source long-horizon SuperAgent harness that researches, codes, and creates. With the help of sandboxes, memories, tools, skill, subagents and message gateway, it handles different levels of ta
tqdmFast, Extensible Progress Meter
simBuild, deploy, and orchestrate AI agents. Sim is the central intelligence layer for your AI workforce.