面向企业内部制度文档、产品资料、运营报表、图片类说明文档等多源异构数据,构建一套基于 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.
许可声明 | License Notice: 本项目为源码开放(source-available)项目,默认仅允许学习、研究与非商业用途,禁止商用。 This is a source-available project for non-commercial use only.
- 当前增强版 | Current enhanced version:
v1.2.0 - 旧版稳定回退 | Stable rollback version:
v1.0.0 - 旧版维护分支 | Legacy maintenance branch:
release/v1.0.0 - 架构文档 | Architecture: docs/architecture.md
- 开发文档 | Development: docs/development.md
- API 文档 | API: docs/api.md
- 当前版本说明 | Current release note: docs/releases/v1.2.0.md
12-Agent 闭环编排 | 12-agent looped orchestration- 基于
LangGraph构建Supervisor -> Understand -> Planning -> Decompose -> Retrieve -> Evidence Review -> Query Rewrite -> Rerank -> Answer -> Critique -> Validate -> Follow-up工作流。 - Built on
LangGraphwith 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.
- 覆盖
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]
当前项目使用的是在线反馈强化策略,而不是训练级 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
- 后端 | 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
- 文档上传、解析、清洗、分块、嵌入、索引
- Document upload, parsing, cleaning, chunking, embedding, and indexing
- 多模态资料接入,支持图文混排和扫描件
- Multimodal ingestion for image-rich and scanned materials
- 基于私有知识库的企业级
RAG主链路问答 - Enterprise
RAGQA 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
- 智能问答工作台 | 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
| 版本 | 定位 | 说明 |
|---|---|---|
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 |
.
├── 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
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
后端 | 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 devollama 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;
0keeps 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
- OpenAI 兼容接口的编码格式参数,默认
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
- 可选
GET /api/v1/healthGET /api/v1/system/overviewGET /api/v1/system/agentsGET /api/v1/system/policyPOST /api/v1/knowledge/uploadGET /api/v1/knowledge/documentsPOST /api/v1/knowledge/rebuild-embeddingsPOST /api/v1/knowledge/searchPOST /api/v1/chat/sessionsPOST /api/v1/chat/queryPOST /api/v1/chat/feedback
-
当前仓库采用手动发布策略
-
标签和 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
- 许可证 | 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:
- 默认不授权任何商业使用行为
- 如需商用授权,请联系维护者获取单独商业许可
- 更新
CHANGELOG.md与docs/releases/vX.Y.Z.md - 提交代码并合并到主分支
- 打标签:
git tag -a vX.Y.Z -m "release: vX.Y.Z" - 推送标签:
git push origin vX.Y.Z - 在 GitHub Releases 里使用对应标签发布版本说明