Skip to content

Repository files navigation

基于多智能体 + 多模态 RAG 的企业知识中台问答系统

Enterprise Knowledge Hub QA System with Multi-Agent + Multimodal RAG

面向企业内部制度文档、产品资料、运营报表、图片类说明文档等多源异构数据,构建一套基于 Qwen + LangChain/LangGraph + Milvus 的企业知识问答系统。系统融合 RAG 检索增强生成、多智能体协同、多模态文档解析、混合检索、可解释溯源与权限隔离能力,覆盖从文档接入、知识构建、检索问答到前端工作台、监控部署的完整工程链路。

This project is an enterprise knowledge QA platform built with Qwen + LangChain/LangGraph + Milvus. It targets heterogeneous enterprise data such as policy documents, product manuals, operational reports, screenshots, scanned files, and mixed text-image materials. It combines RAG, multi-agent orchestration, multimodal document parsing, hybrid retrieval, explainable citations, and permission isolation in one end-to-end system.

快速导航 | Quick Navigation

许可声明 | License Notice: 本项目为源码开放(source-available)项目,默认仅允许学习、研究与非商业用途,禁止商用。 This is a source-available project for non-commercial use only.

项目亮点 | Highlights

  • 12-Agent 闭环编排 | 12-agent looped orchestration
    • 基于 LangGraph 构建 Supervisor -> Understand -> Planning -> Decompose -> Retrieve -> Evidence Review -> Query Rewrite -> Rerank -> Answer -> Critique -> Validate -> Follow-up 工作流。
    • Built on LangGraph with explicit retrieval and answer-revision loops.
  • 多模态知识处理 | Multimodal knowledge processing
    • 支持 Markdown / PDF / 扫描件 / 图片 / 表格类文本 的统一解析与索引。
    • Supports unified parsing and indexing for Markdown / PDF / scanned files / images / table-like text.
  • 混合检索 | Hybrid retrieval
    • 融合 Embedding + BM25 + Rerank + Milvus,同时兼顾语义召回和关键词召回。
    • Combines semantic recall and keyword recall with Embedding + BM25 + Rerank + Milvus.
  • 可解释问答 | Explainable QA
    • 回答附带引用来源、文档片段、置信提示和 Agent Trace。
    • Answers include citations, supporting chunks, confidence hints, and agent traces.
  • 工程化落地 | Production-style engineering
    • 覆盖 FastAPI + React + Docker + Nginx + Prometheus + MySQL + Redis + Milvus + Ollama
    • Covers backend, frontend, vector store, cache, deployment, and observability end to end.

当前 Agent 关系图 | Current Agent Relationship Diagram

flowchart LR
    Q[Question] --> S[Supervisor]
    S --> U[Understand]
    U --> P[Planning]
    P --> D{Need Decompose?}
    D -->|Yes| DC[Decompose]
    D -->|No| R[Retrieve]
    DC --> R
    R --> ER[Evidence Review]
    ER -->|Not Enough| QR[Query Rewrite]
    QR --> R
    ER -->|Enough| RR[Rerank]
    RR --> A[Answer]
    A --> C[Critique]
    C -->|Revise| A
    C -->|Need More Evidence| QR
    C -->|Approve| V[Validate]
    V --> F[Follow-up]
    F --> O[Answer + Citation + Trace]
Loading

RL 风格反馈图 | RL-Style Feedback Diagram

当前项目使用的是在线反馈强化策略,而不是训练级 PPO / RLHF。用户评分会汇总为路由偏好,供 Supervisor Agent 后续决策参考。

The project uses online feedback optimization instead of full training-time PPO/RLHF. User feedback is aggregated into route preferences and then used by the Supervisor Agent for later routing decisions.

flowchart LR
    Q[Question] --> WF[LangGraph Workflow]
    WF --> A[Answer + Route + Trace]
    A --> FB[User Feedback]
    FB --> FS[Feedback Store]
    FS --> RP[Route Preference Summary]
    RP --> S[Supervisor Agent]
    S --> WF
Loading

技术栈 | Tech Stack

  • 后端 | Backend: Python, FastAPI, LangChain, LangGraph
  • 模型接入 | Model access: Qwen, OpenAI Compatible API, Ollama
  • 检索与存储 | Retrieval & storage: Milvus, MySQL, Redis
  • 文档处理 | Document processing: PyMuPDF, pdfplumber, unstructured
  • 前端 | Frontend: React, Vite, Ant Design
  • 部署运维 | Deployment & ops: Docker, Docker Compose, Nginx, Prometheus

核心能力 | Core Capabilities

  • 文档上传、解析、清洗、分块、嵌入、索引
  • Document upload, parsing, cleaning, chunking, embedding, and indexing
  • 多模态资料接入,支持图文混排和扫描件
  • Multimodal ingestion for image-rich and scanned materials
  • 基于私有知识库的企业级 RAG 主链路问答
  • Enterprise RAG QA over private knowledge bases
  • 12-Agent 协同问答与多轮会话
  • 12-agent collaborative QA with multi-turn conversations
  • Milvus + BM25 + Rerank 混合检索
  • Hybrid retrieval with Milvus + BM25 + Rerank
  • 引用溯源、置信度、风险提示、推荐追问
  • Explainable output with citations, confidence, risk hints, and follow-up suggestions
  • 知识库管理、文档预览、检索实验台、Agent 可视化
  • Knowledge management, document preview, search workbench, and agent visualization

页面总览 | UI Overview

  • 智能问答工作台 | Conversational QA workspace
  • Agent Trace Studio | Per-turn runtime trace viewer
  • Ops Cockpit | Swimlane view, retrieval funnel, session trend
  • Knowledge Library | Status tag, chunk count, indexed time, rebuild embeddings, upload progress
  • Search Workbench | Standalone retrieval validation panel
  • Agent Catalog | 12-agent metadata and responsibilities

版本说明 | Versioning

版本 定位 说明
v1.0.0 旧版稳定基线 首个完整可运行版本,适合回退与对照
v1.1.0 里程碑增强版 新增 12-Agent 闭环、前端懒加载工作台、可视化大屏与强化反馈面板
v1.2.0 当前增强版 新增运行时配置中心、实时执行进度回传、文档重切分能力与更健壮的检索配置
Version Purpose Notes
v1.0.0 Stable baseline First complete runnable version, suitable for rollback
v1.1.0 Current enhanced version Adds 12-agent loops, lazy-loaded workbench, dashboard visuals, and feedback optimization

项目结构 | Project Structure

.
├── backend
│   ├── app
│   │   ├── agents
│   │   ├── api
│   │   ├── core
│   │   ├── repositories
│   │   ├── schemas
│   │   ├── services
│   │   └── utils
│   ├── requirements.txt
│   └── tests
├── frontend
│   ├── src
│   ├── package.json
│   └── Dockerfile
├── data
│   ├── index
│   ├── samples
│   └── uploads
├── deploy
│   ├── nginx
│   └── prometheus
├── docs
│   ├── api.md
│   ├── architecture.md
│   ├── development.md
│   └── releases
├── .env.example
├── docker-compose.yml
└── README.md

快速开始 | Quick Start

方式一:Docker Compose 全量模式 | Full stack with Docker Compose

cp .env.example .env
docker compose up -d --build

访问地址 | Endpoints:

  • 前端工作台 | Frontend: http://localhost:5173
  • 后端接口文档 | Swagger: http://localhost:8000/docs
  • 网关 | Gateway: http://localhost
  • Prometheus: http://localhost:9090
  • Ollama: http://localhost:11434

方式二:本地开发 | Local development

后端 | Backend:

cd backend
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

前端 | Frontend:

cd frontend
npm install
npm run dev

方式三:本地 Ollama 模式 | Local Ollama mode

ollama pull qwen3:1.7b
ollama pull qwen3-embedding:0.6b
ollama pull qwen2.5vl:3b

然后配置 .env | Then configure .env:

LLM_PROVIDER=ollama
OPENAI_API_KEY=ollama
OPENAI_BASE_URL=http://127.0.0.1:11434/v1
LLM_MODEL=qwen3:1.7b
VISION_MODEL=qwen2.5vl:3b
EMBEDDING_MODEL=qwen3-embedding:0.6b
EMBEDDING_DIMENSIONS=0
EMBEDDING_BATCH_SIZE=16
EMBEDDING_NORMALIZE=true
EMBEDDING_ENCODING_FORMAT=float
RETRIEVAL_CANDIDATE_MULTIPLIER=4
RETRIEVAL_VECTOR_WEIGHT=0.7
RETRIEVAL_KEYWORD_WEIGHT=0.3
MILVUS_METRIC_TYPE=IP

可调参数说明 | Tunable embedding parameters:

  • EMBEDDING_MODEL
    • 指定 embedding 模型名称
    • Selects the embedding model name
  • EMBEDDING_DIMENSIONS
    • 当模型支持时可手动指定向量维度,0 表示使用模型默认维度
    • When supported by the provider, overrides output dimensions; 0 keeps provider defaults
  • EMBEDDING_BATCH_SIZE
    • 控制文档入库和重建向量时的批量大小
    • Controls batching for indexing and rebuilding embeddings
  • EMBEDDING_NORMALIZE
    • 是否对向量做归一化,建议和 Milvus 相似度度量一起调
    • Enables vector normalization, useful with similarity metric tuning
  • EMBEDDING_ENCODING_FORMAT
    • OpenAI 兼容接口的编码格式参数,默认 float
    • Encoding format for OpenAI-compatible embedding APIs
  • RETRIEVAL_VECTOR_WEIGHT / RETRIEVAL_KEYWORD_WEIGHT
    • 控制语义召回和关键词召回的融合权重
    • Controls hybrid retrieval score weights
  • RETRIEVAL_CANDIDATE_MULTIPLIER
    • 控制 Milvus 初始候选召回倍数
    • Controls the initial candidate pool size
  • MILVUS_METRIC_TYPE
    • 可选 IP / COSINE / L2,需和 embedding 归一化策略一起考虑
    • Supports IP / COSINE / L2, should be tuned together with vector normalization

主要接口 | Main APIs

  • GET /api/v1/health
  • GET /api/v1/system/overview
  • GET /api/v1/system/agents
  • GET /api/v1/system/policy
  • POST /api/v1/knowledge/upload
  • GET /api/v1/knowledge/documents
  • POST /api/v1/knowledge/rebuild-embeddings
  • POST /api/v1/knowledge/search
  • POST /api/v1/chat/sessions
  • POST /api/v1/chat/query
  • POST /api/v1/chat/feedback

发布策略 | Release Policy

  • 当前仓库采用手动发布策略

  • 标签和 GitHub Release 只在明确要求时创建

  • 不配置自动发版流程

  • The repository follows a manual release policy

  • Tags and GitHub releases are created only on explicit request

  • No automatic release workflow is configured

开源协作 | Open Source Collaboration

  • 许可证 | License: Non-Commercial Source License (NCSL)(见 LICENSE
  • 贡献指南 | Contributing Guide: CONTRIBUTING.md
  • 行为准则 | Code of Conduct: CODE_OF_CONDUCT.md
  • 安全策略 | Security Policy: SECURITY.md
  • 变更日志 | Changelog: CHANGELOG.md

商业使用说明 | Commercial use policy:

  • 默认不授权任何商业使用行为
  • 如需商用授权,请联系维护者获取单独商业许可

发布步骤 | Release Steps

  1. 更新 CHANGELOG.mddocs/releases/vX.Y.Z.md
  2. 提交代码并合并到主分支
  3. 打标签:git tag -a vX.Y.Z -m "release: vX.Y.Z"
  4. 推送标签:git push origin vX.Y.Z
  5. 在 GitHub Releases 里使用对应标签发布版本说明

About

基于多智能体 + 多模态 RAG 的企业知识中台问答系统,支持 LangGraph 闭环 Agent、Milvus 混合检索、Qwen/Ollama、本地可视化工作台。

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages