Dify-RAG
高效模块化的 RAG 包,可以快速替换 Dify 中原有的默认模块,大幅提升 Dify 的 RAG 效果。作为通用的基础包,也可以用于其他开源 RAG 服务。
安装
pip install dify-rag
为了在 Dify 项目中使用,可以在 api/pyproject.toml 中添加 dify-rag 依赖,之后更新对应的 lock 文件,在不同版本的 Dify 中存在一些差异:
- poetry 1.x 版本,需要调用
poetry lock --no-update更新 lock 文件依赖 - poetry 2.x 版本,需要调用
poetry lock更新 lock 文件依赖 - uv 版本,需要调用
uv lock更新 lock 文件依赖
使用
目前实现的模块是直接可以插拔放入 Dify 项目中的,只需要在 Dify 项目中替换掉相关模块即可。下面以 html 解析为例:
在 api/core/rag/extractor/extract_processor.py 中将原先使用 Dify 内置的 HtmlExtractor 切换为 Dify-RAG 中的 HtmlExtractor 即可。
具体需要将原有的 from core.rag.extractor.html_extractor import HtmlExtractor 替换为 from dify_rag.extractor.html_extractor import HtmlExtractor 即可
其他模块的替换也是类似的,可以根据自己的需要自行替换增强。
支持的文档格式
| 格式 | 结构化解析 | 表格解析 |
|---|---|---|
| html | 支持 | 支持独立拆分,支持转换 markdown 格式,支持按行切分 |
| md | 支持 | 支持独立拆分,支持 markdown 格式,支持按行切分 |
| docx | 支持 | 支持独立拆分,支持转换 markdown 格式,支持按行切分 |
| 部分支持,需本身有目录信息 | 不支持 | |
| epub | 支持 | 支持独立拆分,支持转换 markdown 格式,支持按行切分 |
| xlsx | 支持 | 支持独立拆分,支持转换 markdown 格式,支持按行切分 |
| csv | 支持 | 支持独立拆分,支持转换 markdown 格式,支持按行切分 |
Metadata
Release files for dify-rag 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dify_rag-0.2.2.tar.gz | 48.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dify_rag-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 113.3 kB
Release files / dify_rag-0.2.2.tar.gz
| Download URL | dify_rag-0.2.2.tar.gz |
|---|---|
| Size | 48.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf90db9647ed6dc7df5df608787a7545303a40bc66694817a4e679efc9e27898
|
|
BLAKE2b-256 checksum How to use checksums |
c3996442af000907e025d83b34478288943bf3db9324faff5a4e5d21a9dd7cde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.9
|
Release files / dify_rag-0.2.2-py3-none-any.whl
| Download URL | dify_rag-0.2.2-py3-none-any.whl |
|---|---|
| Size | 64.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49433be97ee442ae1b680d2f2cda1f2ac668e10526e6873540fb8eb6e0f2067e
|
|
BLAKE2b-256 checksum How to use checksums |
ba712d94b3c20fdc8a793670d68fdf3591a626c3518f692019c1b62328584dc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.9
|
Security for dify-rag 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.