跳至主要內容

升级到 V4.6.8

五六零网校大约 4 分钟

V4.6.8 功能介绍

  • 新增 - 知识库搜索合并模块。
  • 新增 - 新的 Http 模块,支持更加灵活的参数传入。同时支持了输入输出自动数据类型转化,例如:接口输出的 JSON 类型会自动转成字符串类型,直接给其他模块使用。此外,还补充了一些例子,可在文档中查看。
  • 优化 - 内容补全。将内容补全内置到【知识库搜索】中,并实现了一次内容补全,即可完成“指代消除”和“问题扩展”。FastGPT知识库搜索详细流程可查看:知识库搜索介绍
  • 优化 - LLM 模型配置,不再区分对话、分类、提取模型。同时支持模型的默认参数,避免不同模型参数冲突,可通过defaultConfig传入默认的配置。
  • 优化 - 流响应,参考了ChatNextWeb的流,更加丝滑。此外,之前提到的乱码、中断,刷新后又正常了,可能会修复)
  • 修复 - 语音输入文件无法上传。
  • 修复 - 对话框重新生成无法使用。

升级教程

步骤一:修改docker-compose.yml配置

修改 docker-compose.ymlmongo部分,补上commandmongodb.key

官方的修改示例

mongo:
  image: mongo:5.0.18
  # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
  container_name: mongo
  ports:
    - 27017:27017
  networks:
    - fastgpt
  command: mongod --keyFile /data/mongodb.key --replSet rs0
  environment:
    # 这里密码不用变。
    - MONGO_INITDB_ROOT_USERNAME=myname
    - MONGO_INITDB_ROOT_PASSWORD=mypassword
  volumes:
    - ./mongo/data:/data/db
    - ./mongodb.key:/data/mongodb.key

网校优化版的示例

version: '3.3'
services:
  pg:
    # image: ankane/pgvector:v0.5.0 # docker
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0 # 阿里云
    container_name: pg
    restart: always
    networks:
      - fastgpt
    environment:
      - POSTGRES_USER=username
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=postgres
    volumes:
      - ./pg/data:/var/lib/postgresql/data

  mongo:
    # image: mongo:5.0.18
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
    container_name: mongo
    restart: always
    networks:
      - fastgpt
    command: mongod --keyFile /data/mongodb.key --replSet rs0
    environment:
      - MONGO_INITDB_ROOT_USERNAME=username
      - MONGO_INITDB_ROOT_PASSWORD=password
    volumes:
      - ./mongo/data:/data/db
      - ./mongodb.key:/data/mongodb.key

  fastgpt:
    container_name: fastgpt
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.6.8 # 阿里云
    ports:
      - xxxx:3000
    networks:
      - fastgpt
    depends_on:
      - mongo
      - pg
    restart: always
    environment:
      - DEFAULT_ROOT_PSW=a6UPrcgUUBRrDpG2xJgM
      - OPENAI_BASE_URL=https://api.openai.com/v1
      - CHAT_API_KEY=sk-xxxxx
      - DB_MAX_LINK=50 # database max link
      - TOKEN_KEY=any
      - ROOT_KEY=xxxxx
      - FILE_TOKEN_KEY=filetokenkey
      - MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
      - PG_URL=postgresql://username:password@pg:5432/postgres
    volumes:
      - ./config.json:/app/data/config.json

networks:
  fastgpt:

  • xxxx:3000 左侧的xxxx修改为fastgpt的站点访问端口
  • CHAT_API_KEY=sk-xxxxx 修改为openai的实际KEY

步骤二:更新config.json文件配置

4.6.8版本优化了各种模型,所以对应的配置文件也需要修改

完整的config.json配置示例

{
  "systemEnv": {
    "openapiPrefix": "fastgpt",
    "vectorMaxProcess": 15,
    "qaMaxProcess": 15,
    "pgHNSWEfSearch": 100
  },
  "llmModels": [
    {
      "model": "gpt-3.5-turbo-1106",
      "name": "gpt-3.5-turbo",
      "maxContext": 16000,
      "maxResponse": 4000,
      "quoteMaxToken": 13000,
      "maxTemperature": 1.2,
      "inputPrice": 0,
      "outputPrice": 0,
      "censor": false,
      "vision": false,
      "datasetProcess": false,
      "toolChoice": true,
      "functionCall": false,
      "customCQPrompt": "",
      "customExtractPrompt": "",
      "defaultSystemChatPrompt": "",
      "defaultConfig": {}
    },
    {
      "model": "gpt-3.5-turbo-16k",
      "name": "gpt-3.5-turbo-16k",
      "maxContext": 16000,
      "maxResponse": 16000,
      "quoteMaxToken": 13000,
      "maxTemperature": 1.2,
      "inputPrice": 0,
      "outputPrice": 0,
      "censor": false,
      "vision": false,
      "datasetProcess": true,
      "toolChoice": true,
      "functionCall": false,
      "customCQPrompt": "",
      "customExtractPrompt": "",
      "defaultSystemChatPrompt": "",
      "defaultConfig": {}
    },
    {
      "model": "gpt-4-0125-preview",
      "name": "gpt-4-turbo",
      "maxContext": 125000,
      "maxResponse": 4000,
      "quoteMaxToken": 100000,
      "maxTemperature": 1.2,
      "inputPrice": 0,
      "outputPrice": 0,
      "censor": false,
      "vision": false,
      "datasetProcess": false,
      "toolChoice": true,
      "functionCall": false,
      "customCQPrompt": "",
      "customExtractPrompt": "",
      "defaultSystemChatPrompt": "",
      "defaultConfig": {}
    },
    {
      "model": "gpt-4-vision-preview",
      "name": "gpt-4-vision",
      "maxContext": 128000,
      "maxResponse": 4000,
      "quoteMaxToken": 100000,
      "maxTemperature": 1.2,
      "inputPrice": 0,
      "outputPrice": 0,
      "censor": false,
      "vision": false,
      "datasetProcess": false,
      "toolChoice": true,
      "functionCall": false,
      "customCQPrompt": "",
      "customExtractPrompt": "",
      "defaultSystemChatPrompt": "",
      "defaultConfig": {}
    }
  ],
  "vectorModels": [
    {
      "model": "text-embedding-ada-002",
      "name": "Embedding-2",
      "inputPrice": 0,
      "outputPrice": 0,
      "defaultToken": 700,
      "maxToken": 3000,
      "weight": 100,
      "defaultConfig": {}
    }
  ],
  "reRankModels": [],
  "audioSpeechModels": [
    {
      "model": "tts-1",
      "name": "OpenAI TTS1",
      "inputPrice": 0,
      "outputPrice": 0,
      "voices": [
        { "label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy" },
        { "label": "Echo", "value": "echo", "bufferId": "openai-Echo" },
        { "label": "Fable", "value": "fable", "bufferId": "openai-Fable" },
        { "label": "Onyx", "value": "onyx", "bufferId": "openai-Onyx" },
        { "label": "Nova", "value": "nova", "bufferId": "openai-Nova" },
        { "label": "Shimmer", "value": "shimmer", "bufferId": "openai-Shimmer" }
      ]
    }
  ],
  "whisperModel": {
    "model": "whisper-1",
    "name": "Whisper1",
    "inputPrice": 0,
    "outputPrice": 0
  }
}

步骤三:创建Mongo密钥

  1. 进入项目目录,例如/www/wwwroot/FastGPT
cd /www/wwwroot/FastGPT
  1. 在项目目录下,运行终端命令
# 创建 mongo 密钥
openssl rand -base64 756 > ./mongodb.key

# 继续将./mongodb.key 文件权限设置为600
chmod 600 ./mongodb.key

# 将./mongodb.key 文件所有者修改
chown 999:root ./mongodb.key

步骤四:进入Mongo容器,初始化部分合集

在终端运行命令

  1. 进入Mongo容器
docker exec -it mongo bash
  1. 连接Mongo数据库
mongo -u username -p password --authenticationDatabase admin
  • 注意:myname 和mypassword 对应docker-compose.yml配置的Mongo部分的用户名和密码

如图:
Alt text

  1. 确保已经正确连接Mongo数据库后,执行初始化副本集
rs.initiate({
  _id: "rs0",
  members: [
    { _id: 0, host: "mongo:27017" }
  ]
})

注意: 如果需要外网访问,mongo:27017 可以改成 ip:27017。但是需要同时修改 FastGPT 连接的参数(MONGODB_URI=mongodb://myname:mypassword@mongo:27017/fastgpt?authSource=admin => MONGODB_URI=mongodb://myname:mypassword@ip:27017/fastgpt?authSource=admin)

  1. 检查状态。如果提示 rs0 状态,则代表运行成功
rs.status()

步骤五:更新镜像

使用命令一键停止当前容器+更新镜像+自动部署

docker-compose down && docker-compose pull && docker-compose up -d