diff --git "a/tools/kbwf_mineru_local_markdown/1.0.0/MinerU\346\234\254\345\234\260PDF\345\205\245\345\272\223\345\267\245\344\275\234\346\265\201\346\250\241\346\235\277.kbwf" "b/tools/kbwf_mineru_local_markdown/1.0.0/MinerU\346\234\254\345\234\260PDF\345\205\245\345\272\223\345\267\245\344\275\234\346\265\201\346\250\241\346\235\277.kbwf" new file mode 100644 index 0000000..b3ca48c Binary files /dev/null and "b/tools/kbwf_mineru_local_markdown/1.0.0/MinerU\346\234\254\345\234\260PDF\345\205\245\345\272\223\345\267\245\344\275\234\346\265\201\346\250\241\346\235\277.kbwf" differ diff --git a/tools/kbwf_mineru_local_markdown/README.md b/tools/kbwf_mineru_local_markdown/README.md new file mode 100644 index 0000000..273e317 --- /dev/null +++ b/tools/kbwf_mineru_local_markdown/README.md @@ -0,0 +1,86 @@ +# MinerU 本地 PDF 入库工作流模板 + +## 简介 + +**MinerU 本地 PDF 入库工作流模板** 是一个面向知识库构建场景的工作流模板。它调用本地离线部署的 MinerU(Gradio 服务)解析用户上传的 PDF,直接获取 Markdown 文本,并在 MaxKB 内继续完成文档分段和知识库入库。 + +该模板适合无法访问公网 API、需要本地私有化部署、或者只需要文本入库而不要求图片上传 OSS 的场景。 + +## 工作流能力 + +- 接收用户上传的 PDF 文件 +- 调用本地 MinerU 服务完成 PDF 转 Markdown +- 直接使用 Markdown 文本进入文档分段节点 +- 将分段结果写入指定知识库,完成 RAG 入库 + +## 前置条件 + +1. 已离线部署 MinerU(Gradio 服务) + +参考: +https://opendatalab.github.io/MinerU/zh/quick_start/docker_deployment/ + +2. 在 MaxKB 容器内安装依赖并授权临时目录 + +```bash +# 到 maxkb 容器内安装 gradio_client +docker exec -it maxkb bash +pip install gradio_client + +# 如果安装 gradio_client 提示 huggingface-hub 版本冲突,则使用 pip 的兼容性模式,同时安装兼容版本 +pip install gradio_client huggingface-hub==0.34.0 + +# 授权 tmp 目录的访问操作权限 +chmod 777 /tmp +``` + +## 工作流结构 + +该模板通常包含以下几个核心节点: + +1. 开始节点:接收用户上传的 PDF 文件 +2. MinerU 离线 PDF 转 Markdown 工具:调用本地 MinerU 解析文档 +3. 文档分段节点:对 Markdown 文本进行切分 +4. 知识库写入节点:将切分后的结果写入知识库 + +## 关键参数 + +### MinerU 工具节点输入参数 + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| `file_input` | Array / Object | ✅ | 开始节点传入的文件对象 | +| `url_prefix` | String | ✅ | MaxKB 基础地址前缀,用于拼接文件下载地址 | +| `mineru_gradio_url` | String | ✅ | 本地 MinerU Gradio 服务地址 | +| `gradio_retry_count` | Integer | ❌ | Gradio 调用失败时的重试次数 | +| `max_convert_pages` | Integer | ❌ | 最大处理页数 | +| `timeout` | Integer | ❌ | 下载与解析超时时间,单位秒 | + +### 启动参数示例 + +| 参数名 | 示例值 | +| --- | --- | +| `url_prefix` | `http://192.168.11.114:8080/admin` | +| `mineru_gradio_url` | `http://192.168.11.114:7860/` | +| `gradio_retry_count` | `2` | +| `max_convert_pages` | `500` | +| `timeout` | `600` | + +## 使用说明 + +1. 导入该 `kbwf` 模板到 MaxKB +2. 确认工具节点中的 `url_prefix` 与 `mineru_gradio_url` 填写正确 +3. 按需设置 `gradio_retry_count`、`max_convert_pages`、`timeout` +4. 上传测试 PDF 文件 +5. 检查工具节点输出中的 `content` +6. 确认文档分段与知识库写入结果正常 + +## 注意事项 + +- 该模板依赖本地 MinerU 服务可访问,不能直接替代在线 MinerU API 工作流 +- 该模板输出以 Markdown 文本为主,不包含图片上传 OSS 的处理链路 +- 如果 PDF 文件较大或内容复杂,建议调大 `timeout` 并确认容器临时目录可写 + +## 关联工具 + +- `tool_mineru_local_markdown`:本工作流依赖的核心工具 diff --git a/tools/kbwf_mineru_local_markdown/data.yaml b/tools/kbwf_mineru_local_markdown/data.yaml new file mode 100644 index 0000000..e22d3db --- /dev/null +++ b/tools/kbwf_mineru_local_markdown/data.yaml @@ -0,0 +1,5 @@ +name: MinerU 本地 PDF 入库工作流模板 +tags: + - 知识库模板 +title: 基于本地离线 MinerU 解析 PDF 为 Markdown,并完成文档分段与知识库入库 +description: 基于本地离线部署的 MinerU,将单个 PDF 解析为 Markdown 文本,再通过 MaxKB 工作流完成文档分段和知识库入库,适用于内网环境与离线部署场景。 diff --git a/tools/kbwf_mineru_local_markdown/logo.png b/tools/kbwf_mineru_local_markdown/logo.png new file mode 100644 index 0000000..034bf72 Binary files /dev/null and b/tools/kbwf_mineru_local_markdown/logo.png differ diff --git "a/tools/tool_mineru_local_markdown/1.0.0/MinerU\347\246\273\347\272\277PDF\350\275\254\346\215\242Markdown.tool" "b/tools/tool_mineru_local_markdown/1.0.0/MinerU\347\246\273\347\272\277PDF\350\275\254\346\215\242Markdown.tool" new file mode 100644 index 0000000..206cce5 Binary files /dev/null and "b/tools/tool_mineru_local_markdown/1.0.0/MinerU\347\246\273\347\272\277PDF\350\275\254\346\215\242Markdown.tool" differ diff --git a/tools/tool_mineru_local_markdown/README.md b/tools/tool_mineru_local_markdown/README.md new file mode 100644 index 0000000..8bb8dcc --- /dev/null +++ b/tools/tool_mineru_local_markdown/README.md @@ -0,0 +1,88 @@ +# MinerU 离线 PDF 转 Markdown + +## 简介 + +**MinerU 离线 PDF 转 Markdown** 用于在 MaxKB 工作流中调用本地离线部署的 MinerU(Gradio 服务)解析 PDF,并直接返回 Markdown 文本,方便后续执行文档分段、入库、RAG 等处理。 + +与 ZIP 结果流不同,本工具不进行 ZIP 打包、不上传 OSS,输出更轻量,适合内网环境或仅需文本结果的场景。 + +## 核心能力 + +- 调用本地离线部署的 MinerU 服务解析 PDF +- 直接输出 Markdown 文本,便于下游节点继续处理 +- 支持配置重试次数、最大处理页数与超时时间 + +## 前置条件 + +1. 已离线部署 MinerU(Gradio 服务) + +参考: +https://opendatalab.github.io/MinerU/zh/quick_start/docker_deployment/ + +2. 在 MaxKB 容器内安装依赖并授权临时目录 + +```bash +# 到 maxkb 容器内安装 gradio_client +docker exec -it maxkb bash +pip install gradio_client + +# 如果安装 gradio_client 提示 huggingface-hub 版本冲突,则使用 pip 的兼容性模式,同时安装兼容版本 +pip install gradio_client huggingface-hub==0.34.0 + +# 授权 tmp 目录的访问操作权限 +chmod 777 /tmp +``` + +## 参数说明 + +### 输入参数 + +| 参数名 (`Key`) | 类型 | 必填 | 说明 | 示例 | +| --- | --- | --- | --- | --- | +| `file_input` | Array / Object | ✅ | MaxKB 文件对象,通常为上游节点输出的文件列表或字典 | `{{start.file_list}}` | + +### 启动参数 + +| 参数名 (`Key`) | 类型 | 必填 | 说明 | 默认值 | +| --- | --- | --- | --- | --- | +| `url_prefix` | String | ✅ | MaxKB 基础地址前缀,用于拼接文件下载地址 | `http://192.168.11.114:8080/admin` | +| `mineru_gradio_url` | String | ✅ | 本地 MinerU Gradio 服务地址 | `http://192.168.11.114:7860/` | +| `gradio_retry_count` | Integer | ❌ | Gradio 调用失败时的重试次数 | `2` | +| `max_convert_pages` | Integer | ❌ | 最大处理页数,用于限制单次解析范围 | `500` | +| `timeout` | Integer | ❌ | 下载与解析超时时间,单位秒 | `600` | + +## 输出结果 + +工具执行成功后返回 `Array[Object]`,长度为 1。示例: + +```json +[ + { + "status": "completed", + "task_id": "local-xxxxxxxxxxxx", + "name": "xxx.pdf", + "size": 12345, + "uid": 1775184, + "content": "# Markdown...", + "markdown_raw": "# Markdown(rendered)..." + } +] +``` + +字段说明: + +- `content`:推荐给下游节点使用的 Markdown 文本 +- `markdown_raw`:MinerU 渲染版 Markdown,便于排查格式问题 + +## 使用建议 + +- 如果下游节点只识别 `content`,优先使用 `content` +- 如果 PDF 页数很多,建议显式设置 `max_convert_pages` +- 如果网络或本地服务偶发不稳定,可适当调大 `gradio_retry_count` +- 如果大文件处理耗时较长,建议调大 `timeout` + +## 适用场景 + +- 内网环境下的 PDF 转 Markdown 解析 +- 文档预处理后直接进入知识库分段 +- 工作流中需要轻量文本输出,不需要图片上传与 OSS 回填 diff --git a/tools/tool_mineru_local_markdown/data.yaml b/tools/tool_mineru_local_markdown/data.yaml new file mode 100644 index 0000000..cb6b9c2 --- /dev/null +++ b/tools/tool_mineru_local_markdown/data.yaml @@ -0,0 +1,5 @@ +name: MinerU 离线 PDF 转 Markdown +tags: + - 内容处理 +title: 调用本地 MinerU 将 PDF 解析为 Markdown 文本 +description: 调用本地离线部署的 MinerU(Gradio 服务)解析 PDF,直接返回 Markdown 文本(不打包 ZIP、不上传 OSS),适用于工作流后续分段、入库与 RAG 处理。 diff --git a/tools/tool_mineru_local_markdown/logo.png b/tools/tool_mineru_local_markdown/logo.png new file mode 100644 index 0000000..034bf72 Binary files /dev/null and b/tools/tool_mineru_local_markdown/logo.png differ