Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
154ed4e
功能:增强知识库访问控制和共享配置 #480
xerrors Jan 19, 2026
252924b
feat(auth): 添加超级管理员用户切换功能和相关日志记录
xerrors Jan 20, 2026
02dbd68
feat(知识库): 重构知识库元数据存储为PostgreSQL数据库
xerrors Jan 21, 2026
a446ba3
refactor: 重构数据库访问层,用户/对话/消息都统一迁移至PostgreSQL并添加业务模型支持
xerrors Jan 21, 2026
5b4ef74
refactor(storage): 重构对话数据库模型与存储管理
xerrors Jan 21, 2026
22a62dd
refactor: 移除基于 SQLite 的遗留问题
xerrors Jan 21, 2026
16dc128
refactor(task): 重构任务服务并迁移到postgres 数据库
xerrors Jan 21, 2026
5b80dbe
fix(knowledge-tool): 修复使用的 ID 而不是知识库的 bug
xerrors Jan 21, 2026
aae08ce
format: 清理代码中的空行和优化导入顺序
xerrors Jan 21, 2026
6bfe6bb
refactor(agents): 移除graph缓存并优化连接和检查点缓存
xerrors Jan 21, 2026
7d3c9bd
feat(agent): 实现多部门智能体配置管理功能
xerrors Jan 21, 2026
79e6697
refactor(agents): 实现统一工具加载逻辑并使用中间件动态配置
xerrors Jan 21, 2026
af15efe
fix(chat): 修复知识库权限过滤逻辑
xerrors Jan 22, 2026
daf9769
feat(web/config): 重构配置侧边栏为通用选择组件
xerrors Jan 22, 2026
cec60d9
feat(config): 在前端添加基于权限的知识库展示设计
xerrors Jan 22, 2026
4de95fe
chore(database): 优化镜像配置与部分 SQLite 残留
xerrors Jan 22, 2026
4aed527
fix: 将MD5哈希算法替换为更安全的SHA256算法
xerrors Jan 22, 2026
1844c91
docs: 优化文档说明
xerrors Jan 23, 2026
aa20d5c
fix(context): 修复 deep_agent 的 Prompt 无法正确解析的问题
xerrors Jan 23, 2026
aa081f3
fix: 修复由于过滤逻辑导致的过滤问题,优化多选配置项验证逻辑,确保选项数组不为空
xerrors Jan 23, 2026
759c3a6
docs: 更新指引描述
xerrors Jan 23, 2026
cc3c8f9
chore: 重构迁移脚本
xerrors Jan 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Don't create helpers, utilities, or abstractions for one-time operations. Don't
- Icon 应该从 @ant-design/icons-vue 或者 lucide-vue-next (推荐,但是需要注意尺寸)
- Vue 中的样式使用 less,非必要情况必须使用[base.css](web/src/assets/css/base.css) 中的颜色变量。
- UI风格要简洁,同时要保持一致性,不要悬停位移,不要过度使用阴影以及渐变色。
- 开发完成后,可以在 docker 的 web 文件夹下,运行 npm run format 格式化代码


### 后端开发规范
Expand All @@ -40,12 +39,11 @@ docker compose exec api uv run python test/your_script.py # 放在 test 文件
```

注意:

- Python 代码要符合 Python 的规范,符合 pythonic 风格
- 尽量使用较新的语法,避免使用旧版本的语法(版本兼容到 3.12+)
- 修改完成后使用 YUXI_SUPER_ADMIN_NAME / YUXI_SUPER_ADMIN_PASSWORD 环境变量调试接口(读取 .env 文件)

**其他**:

- 使用 YUXI_SUPER_ADMIN_NAME / YUXI_SUPER_ADMIN_PASSWORD 调试接口
- 如果需要新建说明文档(仅开发者可见,非必要不创建),则保存在 `docs/vibe` 文件夹下面
- 代码更新后要检查文档部分是否有需要更新的地方,文档的目录定义在 `docs/.vitepress/config.mts` 中。文档应该更新最新版(`docs/latest`)
22 changes: 22 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
- .env.prod
environment:
- HOST_IP=${HOST_IP:-}
- POSTGRES_URL=${POSTGRES_URL:-postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-yuxi_know}}
- NEO4J_URI=${NEO4J_URI:-bolt://graph:7687}
- NEO4J_USERNAME=${NEO4J_USERNAME:-neo4j}
- NEO4J_PASSWORD=${NEO4J_PASSWORD:-0123456789}
Expand Down Expand Up @@ -150,6 +151,27 @@ services:
- app-network
restart: unless-stopped

postgres:
image: postgres:16
container_name: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_DB=${POSTGRES_DB:-yuxi_know}
- TZ=${TZ:-Asia/Shanghai}
volumes:
- ./docker/volumes/postgresql:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-yuxi_know} || exit 1"]
interval: 5s
timeout: 3s
retries: 30
networks:
- app-network
restart: unless-stopped

mineru-vllm-server:
build:
context: .
Expand Down
29 changes: 20 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
# region api_envs
environment:
- HOST_IP=${HOST_IP:-}
- POSTGRES_URL=${POSTGRES_URL:-postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-yuxi_know}}
- NEO4J_URI=${NEO4J_URI:-bolt://graph:7687}
- NEO4J_USERNAME=${NEO4J_USERNAME:-neo4j}
- NEO4J_PASSWORD=${NEO4J_PASSWORD:-0123456789}
Expand All @@ -51,8 +52,8 @@ services:
retries: 8
start_period: 180s
depends_on:
# postgres:
# condition: service_healthy
postgres:
condition: service_healthy
milvus:
condition: service_healthy
minio:
Expand Down Expand Up @@ -181,15 +182,25 @@ services:
- app-network
restart: unless-stopped

sqlite-web:
image: coleifer/sqlite-web:latest
container_name: sqlite-web
volumes:
- ./saves/database:/data
postgres:
image: postgres:16
container_name: postgres
ports:
- "9092:8080"
- "5432:5432"
environment:
SQLITE_DATABASE: server.db
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_DB=${POSTGRES_DB:-yuxi_know}
- TZ=${TZ:-Asia/Shanghai}
volumes:
- ./docker/volumes/postgresql:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-yuxi_know} || exit 1"]
interval: 5s
timeout: 3s
retries: 30
networks:
- app-network
restart: unless-stopped

# lastest version: wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/compose.yaml
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/advanced/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
| **7474/7687** | Neo4j | graph | 图数据库 |
| **9000/9001** | MinIO | milvus-minio | 对象存储 |
| **19530/9091** | Milvus | milvus | 向量数据库 |
| **5432** | postgres | postgres | PostgreSQL 数据库 |
| **30000** | MinerU | mineru | PDF 解析(可选)|
| **8080** | PP-StructureV3 | paddlex-ocr | OCR 服务(可选)|
| **8081** | vLLM | - | 本地推理(可选)|
| **9092** | SQLite Web UI | sqlite-web | SQLite 数据库管理界面(可选)|

::: tip 端口访问
- Web 界面: `http://localhost:5173`
Expand Down
108 changes: 108 additions & 0 deletions docs/latest/changelog/migrate_to_v0-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# v0.5 数据迁移指南

v0.5 版本将数据存储从 SQLite + JSON 文件迁移到 PostgreSQL。本指南帮助你完成数据迁移。

::: tip warning
迁移脚本可能会存在问题,不建议在生产环境下尝试,生产环境下,请新建或仔细检查迁移脚本,慎重迁移。
:::

## 迁移内容

| 数据类型 | 源 | 目标 | 存储内容 |
|---------|-----|------|---------|
| 业务数据 | SQLite (`saves/database/server.db`) | PostgreSQL | 用户、部门、对话、消息、工具调用、MCP 服务器等 |
| 知识库元数据 | JSON 文件 (`saves/knowledge_base_data/`) | PostgreSQL | 知识库配置、文件信息、评估数据 |
| Tasker 任务记录 | JSON 文件 (`saves/tasks/tasks.json`) | PostgreSQL | 后台任务状态、进度、结果(独立存储) |

## 迁移前准备

### 1. 启动服务

```bash
docker compose up -d --build
```

### 2. 备份数据

**重要:** 迁移前必须备份数据!

```bash
# 备份 saves 目录(包含 SQLite 数据库和知识库元数据)
cp -r saves saves_backup_$(date +%Y%m%d)

# 如果使用外部数据库,也请备份 PostgreSQL
pg_dump -U postgres -d yuxi_know > pg_backup_$(date +%Y%m%d).sql
```

### 3. 确保 PostgreSQL 已启动

```bash
docker compose up -d postgres
# 等待健康检查通过
```

## 执行迁移

### 方式一:使用统一迁移脚本(推荐)

```bash
# 1. 预览迁移(不执行)
docker compose exec api python scripts/migrate_all.py --dry-run

# 2. 执行迁移
docker compose exec api python scripts/migrate_all.py --execute

# 3. 验证迁移结果
docker compose exec api python scripts/migrate_all.py --verify
```

### 方式二:分阶段迁移

```bash
# 只迁移业务数据
docker compose exec api python scripts/migrate_all.py --execute --stage business

# 只迁移知识库元数据
docker compose exec api python scripts/migrate_all.py --execute --stage knowledge

# 只迁移 Tasker 任务记录
docker compose exec api python scripts/migrate_all.py --execute --stage tasker
```

## 重启服务

```bash
docker compose up -d
```

## 验证迁移

### 检查服务状态

```bash
# 查看 API 服务日志
docker logs api-dev --tail 50

# 检查健康状态
curl http://localhost:5050/api/system/health
```

### 验证数据

```bash
# 使用迁移脚本验证
docker compose exec api python scripts/migrate_all.py --verify
```

预期输出:

```
============================================================
📊 验证结果汇总
============================================================
✅ departments: SQLite=X, PostgreSQL=X
✅ users: SQLite=X, PostgreSQL=X
✅ conversations: SQLite=X, PostgreSQL=X
...
全部匹配: ✅ 是
```
9 changes: 8 additions & 1 deletion docs/latest/changelog/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
- 系统层面添加 apikey,在智能体、知识库调用中支持 apikey 以支持外部调用
- 支持更多类型的文档源的导入功能
- 检查非 Agent 场景下的知识库的可见情况
- Tasker 新增删除任务的接口
- 部分场景应该使用默认模型作为默认值而不是空值
- CommonRAG 添加更多检索类型,比如 BM25,关键词,grep 等
- 文件上传解析后,如何提示用户需要入库
- 检索测试中,添加问答
- 优化 MySQL 查询工具中,自动从环境变量中加载知识库的表述作为工具的描述


### Bugs
- 部分异常状态下,智能体的模型名称出现重叠[#279](https://github.com/xerrors/Yuxi-Know/issues/279)
Expand All @@ -24,6 +31,7 @@
- 工具传递给模型的时候,使用英文,但部分模型不支持中文函数名(如gpt-4o-mini)
- 当前的 upload 图谱查询为同步操作,可能会导致页面卡顿
- FileTable 的自动刷新失效
- 生成基准测试会把所有的向量都计算一遍不合理

## v0.5

Expand All @@ -33,7 +41,6 @@
- 优化 RAG 检索,支持根据文件 pattern 来检索(Agentic Mode)
- 重构智能体对于“工具变更/模型变更”的处理逻辑,无需导入更复杂的中间件
- 重构知识库的 Agentic 配置逻辑,与 Tools 解耦
- 新增Sqlite Web UI 方便通过Web页面管理数据库中数据[#463](https://github.com/xerrors/Yuxi-Know/pull/463)
- 将工具与知识库解耦,在 context 中就完成解耦,虽然最终都是在 Agent 中的 get_tools 中获取
- 优化chunk逻辑,移除 QA 分割,集成到普通分块中,并优化可视化逻辑
- 重构知识库处理逻辑,分为 上传—解析—入库 三个阶段
Expand Down
14 changes: 14 additions & 0 deletions docs/latest/intro/knowledge-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
在前端界面中,默认完成前两步,即上传后会自动解析,如果想要实现解析后还继续入库的话,需要在上传的时候勾选自动入库。否则需要在上传后手动点击入库。


## 知识库权限控制

每个知识库可以配置独立的访问权限:

- **共享模式**: 设置知识库是否全局共享
- **部门访问**: 配置允许访问该知识库的部门范围

权限规则:
- **超级管理员**: 可访问所有知识库
- **管理员**: 可访问共享以及本部门所有知识库
- **普通用户**: 仅能访问已授权的知识库(通过部门或全局共享)

创建/编辑知识库时,可在"分享配置"中设置权限。

## 文档管理

本系统的“上传 → 解析入库 → 检索/可视化”流程既可通过 Web 界面完成,也可使用 API/脚本批量处理。详见[文档解析](../advanced/document-processing.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/latest/intro/project-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Yuxi-Know(语析)是一个基于知识图谱和向量数据库的智能知

- **后端服务**: [FastAPI](https://github.com/tiangolo/fastapi) + Python 3.12+
- **前端界面**: [Vue.js 3](https://github.com/vuejs/vue) + [Ant Design Vue](https://github.com/vueComponent/ant-design-vue)
- **数据库存储**: [SQLite](https://github.com/sqlite/sqlite) + [MinIO](https://github.com/minio/minio)
- **数据库存储**: [PostgreSQL](https://github.com/postgres/postgres) + [MinIO](https://github.com/minio/minio)
- **知识存储**: [Milvus](https://github.com/milvus-io/milvus)(向量数据库)+ [Neo4j](https://github.com/neo4j/neo4j)(图数据库)
- **智能体框架**: [LangGraph](https://github.com/langchain-ai/langgraph)
- **文档解析**: [LightRAG](https://github.com/HKUDS/LightRAG) + [MinerU](https://github.com/HKUDS/MinerU) + [PP-Structure-V3](https://github.com/PaddlePaddle/PaddleOCR)
Expand All @@ -20,5 +20,5 @@ Yuxi-Know(语析)是一个基于知识图谱和向量数据库的智能知
- **知识库管理**: 支持多种存储形式(Milvus、LightRAG)
- **知识图谱**: 自动构建和可视化知识图谱,支持图查询
- **文档解析**: 支持 PDF、Word、图片等多种格式的智能解析
- **权限管理**: 三级权限体系(超级管理员、管理员、普通用户)
- **权限管理**: 基于部门的知识库访问控制
- **内容安全**: 内置内容审查机制,保障服务合规性
7 changes: 4 additions & 3 deletions docs/latest/intro/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

```bash
# 克隆稳定版本
git clone --branch v0.4.3 --depth 1 https://github.com/xerrors/Yuxi-Know.git
git clone --branch v0.5.0-beta --depth 1 https://github.com/xerrors/Yuxi-Know.git
cd Yuxi-Know
```

::: warning 版本说明
- `v0.4.3`: 稳定版本
- `v0.4.4`: 稳定版本
- `v0.5.0-beta`: 由于数据库重构使用 postgres,可能会存在数据库迁移问题,建议新用户使用。
- `main`: 最新开发版本(不稳定,新特性可能会导致新 bug)
:::

Expand Down Expand Up @@ -106,7 +107,7 @@ docker compose down
## 故障排除

::: tip 调试面板
前端有个**调试面板**,长按侧边栏空白处触发,生产环境建议删除此特性,在 `AppLayout.vue` 中注释掉相关代码。
前端有个**调试面板**,在头像选项里,生产环境建议删除此特性,在 `AppLayout.vue` 中注释掉相关代码。
:::

#### 查看服务状态
Expand Down
Loading