ResearchGPT/PrivateGPT部署

ResearchGPT

github

1.装包部署

python 复制代码
git clone https://github.com/mukulpatnaik/researchgpt.git
cd researchgpt
pip install -r requirements.txt
  • 安装openai有很多坑,从python版本选择开始就要注意。
    python版本选择:3.8。
  • 装包要在终端开vpn
  • No module named 'openai.embeddings_utils' : openai.embeddings_utils does not exist in latest openai 1.2.0, but exists in 0.27.7
    先卸载原版本再安装0.27.7:
python 复制代码
pip uninstall openai
python 复制代码
pip install openai==0.27.7
  1. Redis安装

  2. 设置环境变量:在环境变量里设置OPENAI_API_KEY,可以通过在命令提示符(CMD)或者PowerShell中输入echo %OPENAI_API_KEY%来验证环境变量是否设置成功。

    需要拿到一个openaikey

  3. 运行

python 复制代码
uvicorn main:app --reload

原版,无法运行,要改端口:

python 复制代码
uvicorn main:app --host 127.0.0.1 --port 45144 --reload

而且终端要:

python 复制代码
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890
  • 报错:redis.exceptions.ConnectionError: Error 10061 connecting to localhost:45183. 由 于目标计算机积极拒绝,无法连接。

    解决方法:是由于没有启动redis服务,启动服务(找到安装路径,打开redis-servce.exe文件即可)。

  • 报错:INFO: 127.0.0.1:52751 - "POST /process_pdf HTTP/1.1" 500 Internal Server Error

    ERROR: Exception in ASGI application.

    解析:the 127.0.0.1:64603 part is not the address and port the server is running on. Instead, it's the address and port of the client that sent the HTTP request to the server.这个错误是由于下面那个错误导致的。

  • 报错:Done creating dataframe

    openai.error.RateLimitError: Rate limit reached for text-embedding-ada-002 in organization org-s7q4Pdq4wxWqju2UCefWy6uZ on requests per min (RPM): Limit 3, Used 3, Requested 1. Please try again in 20s
    限制规则见openai文档。

curl http://localhost:19327/v1/completions \ -H "Content-Type: application/json" \ -d '{ "prompt": "告诉我中国的首都在哪里" }'

python scripts/openai_server_demo/openai_api_server.py --base_model /path/to/base_model --lora_model /path/to/lora_model --gpus 0,1

PrivateGPT

不行,换方法 ,本地基于llama2部署

按照官方步骤一步步来即可。

一些要点:

  • Makefile安装
    当用户编译文件过多的时候,使用makefile可以帮助模块化编译文件,makefile是一个脚本文件,根据规则,来执行相应的脚本文件,实现自动化编译。
    首先安装chocolatey,以管理员权限打开cmd命令行提示,执行如下内容:
python 复制代码
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

安装make

python 复制代码
choco install make

测试make是否成功安装

python 复制代码
make --version
  • Poetry安装
    这里注意,官方下载指定都不好使,会把安装地址重定向,导致安装依赖包时出错。
    下载方法:
powershell 复制代码
安装:pip install --user poetry

卸载:pip uninstall poetry

安装检查:

1、安装完成后要在环境变量新增一条poetry的环境变量

2、控制台执行poetry --version,出现Poetry version 表示安装成功

  • 通过poetry安装依赖包:
powershell 复制代码
poetry install --with ui
powershell 复制代码
poetry install --with local

下载模型

powershell 复制代码
poetry run python scripts/setup
  • 尝试运行
powershell 复制代码
make run

端口号不是localhost
解决:在工程中ctrl+shift+f寻找uvicorn.run找到

powershell 复制代码
# uvicorn.run(app, host="0.0.0.0", port=settings().server.port, log_config=None)

uvicorn.run(app, host="127.0.0.1", port=settings().server.port, log_config=None)

修改即可

然后再make run

啊啊啊啊啊啊终于成功了,接下来我要详细理解这个工程,以方便以后微调。

相关推荐
承渊政道2 小时前
Fooocus本地AI绘图教程:Windows部署、低门槛生图与远程访问
人工智能·windows·cpolar·fooocus·生图
熊猫钓鱼>_>2 小时前
普通用户视角的端侧智能体验手记【鸿蒙心迹】
开发语言·人工智能·华为·智能手机·性能优化·ai编程·harmonyos
AI算力3 小时前
私有云时代来临:AI NAS如何重塑你的数字生活?
人工智能·科技·ai·生活·nas·ai算力·ainas
程序员cxuan3 小时前
讲真,智能路由这事儿,还得看基元律动
人工智能·后端·程序员
zixu_star3 小时前
定时任务是什么?从日常自动化到 AI 应用,软件如何自动执行任务?
运维·人工智能·自动化
Baihai_IDP3 小时前
别再争论 AI 该不该像人了,赋予 AI 人格是非常有效的后训练策略
人工智能·llm·aigc
框架那些事儿3 小时前
一篇文章,搞懂 Agent 的工具调用机制
人工智能·全栈
武子康3 小时前
H3-World 写了 CPU offload,为什么还不能保证塞进 48GB?
大数据·人工智能·深度学习
Linye4 小时前
配了 3 套 AI 规则还打架?聊聊 Agent 信源仲裁与三层验真
人工智能·架构
雪庭4 小时前
WorkBuddy 专家包:AI 错题本管家开发全程复盘
人工智能