几步搭建本地AI大模型chat聊天(2)

105 阅读1分钟

本片内容基于ollama和librechat开发,最终实现一个CHATGPT的效果。

image.png

www.librechat.ai/blog/2024-0… librechat提供的使用文档

使用 LibreChat
1. 参考文档

www.librechat.ai/docs/local/…

2. 克隆项目

git clone https://github.com/danny-avila/LibreChat.git

3. 安装项目依赖(需要node版本>=20)

npm ci

4. 需要安装mongodb

在数据库中创建LibreChat

www.mongodb.com/try/downloa…

5. 配置环境变量

复制配置文件cp .env.example .env并修改相关配置

.env配置文件中添加数据库:

MONGO_URI=mongodb://localhost:27017/LibreChat

.env配置文件中添加Ollama支持:ps:这一步好像不用,配置迁移到librechat.yaml了

ENDPOINTS=openAI,assistants,custom

通过环境变量为文件设置备用路径

CONFIG_PATH="/librechat.yaml"

6. 配置librechat.yaml

复制librechat.example.yaml为librechat.yaml,配置自定义模型Ollama 参考文档:www.librechat.ai/docs/config…

  custom:
    - name: "Ollama"
      apiKey: "ollama"
      # use 'host.docker.internal' instead of localhost if running LibreChat in a docker container
      baseURL: "http://localhost:11434/v1/" 
      models:
        default: [
          "qwen2.5:7b",
          ]
        # fetching list of models is supported but the `name` field must start
        # with `ollama` (case-insensitive), as it does in this example.
        fetch: true
      titleConvo: true
      titleModel: "current_model"
      summarize: false
      summaryModel: "current_model"
      forcePrompt: false
      modelDisplayLabel: "Ollama"
7. 重新构建前端

npm run frontend

8. 运行后端服务

npm run backend

最后在浏览器8080端口打开网页注册登录即可。