一、下载源码
按官方的说明下载源码
git clone https://github.com/infiniflow/ragflow.git
cd ragflow/
二、移除pyicu
pyicu在windows下一直没有编译过,会报如下错误
在pyproject.toml文件中移除pyicu,移除后对项目影响不大。
三、安装依赖
在ragflow目录执行如下命令安装项目依赖
uv sync --python 3.10 --all-extras
四、激活虚拟环境
在ragflow目录执行如下命令激活环境
.\.venv\scripts\activate.bat
五、下载模型
在ragflow目录执行如下命令下载模型
python download_deps.py
注意:下载较慢,可以使用其他方法加快下载进度
下载后需要将nltk_data目录移动到如下目录,不然启动后端服务时会报找不到tokenizers\punkt_tab的错误。
六、启动依赖服务
修改配置文件.\conf\service_conf.yaml中es、mysql、minio、redis的相关参数,然后启动es、mysql、minio、redis服务。其中mysql需要先创建 rag_flow 数据库,不然启动后端服务时会提示找不到rag_flow数据库。
另外:es需要安装8.0以上的版本,不然会报Exception: Elasticsearch version must be greater than or equal to 8, current version: 7
七、启动前端服务
进入web目录,安装前端项目依赖
npm i
完成后运行项目
npm run dev
然后出现如下图,则可以通过浏览器访问
如果运行时报如下错误,则多试几次npm run dev就可以了
error - [plugin: ./node_modules/@umijs/plugins/dist/tailwindcss] tailwindcss generate failed after 5 seconds, please check your tailwind.css and tailwind.config.js
八、启动后端服务(ragflow_server)
打开PyCharm工具,通过如图运行ragflow_server.py。
如果采用如下CMD命令运行,会报ModuleNotFoundError: No module named 'api'错误
python .\api\ragflow_server.py
运行成功后,前端界面就可以注册、登录了。
在启动ragflow_server时,会出现如下两个错误
1、not find model file path det.onnx
首先将ragflow\huggingface.co\InfiniFlow目录的下deepdoc复制到ragflow\rag\res目录
然后按如下图修改ocr.py文件即可
2、Resource punkt_tab not found
将ragflow目录的nltk_data子目录复制到ragflow\.venv\Lib目录即可
九、启动文档解析任务服务(task_executor)
通过如图运行task_executor.py
运行后在前端测试上传文档word和pdf
1、上传word文档,提示在C:\Users\Administrator\.ragflow目录下没有bge-large-zh-v1.5模型
将ragflow\huggingface.co\BAAI目录下的bge-large-zh-v1.5目录复制到C:\Users\Administrator\.ragflow目录即可
2、上传pdf文档,提示ragflow\rag/res/deepdoc\updown_concat_xgb.model": No such file or directory
将ragflow\huggingface.co\InfiniFlow\text_concat_xgb_v1.0目录下的updown_concat_xgb.model文件复制到ragflow\rag\res\deepdoc目录,重新解析文档即可
最后,文档解析成功后,进行聊天测试,能根据知识库回答问题,至此,源代码运行成功!