参考

https://doc.fastgpt.in/docs/development/custom-models/chatglm2-m3e/

特点

  • 贼啦快~

注意

  • chatglm2-m3e启动有点慢,需要等待日志中显示6006端口的时候才可以。
  • 三个服务部署,之间不能直接通信,需要使用iptables -t filter -I FORWARD 1 -j ACCEPT规避docker自带isolate策略,实现互相通信。
  • fastdfs部署的时候,config.json文件最好是删掉gpt相关的信息,只保留chatglm2的信息。否则,通过浏览器观察数据上传过程中的现象,即使vectorModel=m3e,但是agentModel依旧是gpt-3.5-xxx。具体不了解。

部署

chatglm2-m3e

下载文件

nohup git clone https://huggingface.co/THUDM/chatglm2-6b &
  • 注意:git下载后的.git依旧有用,不要只保留模型文件。

docker-compose.yml

version: '3.3'
services:
  chatglm2-m3e:
    container_name: chatglm2-m3e
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt_docker/chatglm2-m3e:latest
    restart: always
    volumes:
      - ./THUDM:/app/THUDM
    dns:
      - 47.93.41.92
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: [gpu]
              device_ids: ['0']
    #entrypoint:
    #  - sh
    #  - -euc
    #  - |
    #    python glm2.py
    networks:
      chatglm2-m3e-network:
        ipv4_address: 172.18.59.31

  reranker:
    container_name: reranker
    image: luanshaotong/reranker:v0.1
    restart: always
    networks:
      chatglm2-m3e-network:
        ipv4_address: 172.18.59.32

networks:
  chatglm2-m3e-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.59.0/24

fastgpt

docker-compose.yml

version: '3.3'
services:
  pg:
    #image: ankane/pgvector:v0.5.0 # git
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0 # 阿里云
    container_name: pg
    restart: always
    ports: # 生产环境建议不要暴露
      - 5432:5432
    networks:
      fastgpt:
        ipv4_address: 172.18.58.52
    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
    ports:
      - 27017:27017
    networks:
      fastgpt:
        ipv4_address: 172.18.58.51
    command: mongod --keyFile /data/db/mongodb.key --replSet rs0
    environment:
      # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
      - MONGO_INITDB_ROOT_USERNAME=username
      - MONGO_INITDB_ROOT_PASSWORD=password
    volumes:
      - ./mongo/data:/data/db
  fastgpt:
    container_name: fastgpt
    #image: ghcr.io/labring/fastgpt:latest # git
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
    ports:
      - 3000:3000
    networks:
      fastgpt:
        ipv4_address: 172.18.58.31
    depends_on:
      - mongo
      - pg
    restart: always
    environment:
      # root 密码,用户名为: root
      - DEFAULT_ROOT_PSW=Lab@1234
      # 中转地址,如果是用官方号,不需要管。务必加 /v1
      #- OPENAI_BASE_URL=http://172.18.59.31:6006/v1
      - OPENAI_BASE_URL=http://172.18.60.31:3000/v1
      #- CHAT_API_KEY=sk-aaabbbcccdddeeefffggghhhiiijjjkkk
      - CHAT_API_KEY=sk-ESiim8KiW5klni8XDb30A36f29D848C1A8Dc3cAa2154A332
      - DB_MAX_LINK=5
      - TOKEN_KEY=any
      - ROOT_KEY=root_key
      - FILE_TOKEN_KEY=filetoken
      # mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
      - MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
      # pg配置. 不需要改
      - PG_URL=postgresql://username:password@pg:5432/postgres
    volumes:
      - ./config.json:/app/data/config.json
networks:
  fastgpt:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.58.0/24

config.json

cat config.json
{
  "systemEnv": {
    "openapiPrefix": "fastgpt",
    "vectorMaxProcess": 15,
    "qaMaxProcess": 15,
    "pgHNSWEfSearch": 100
  },
  "llmModels": [
    {
      "model": "chatglm2",
      "name": "chatglm2",
      "maxToken": 8000,
      "price": 0,
      "quoteMaxToken": 4000,
      "maxTemperature": 1.2,
      "defaultSystemChatPrompt": ""
    }
  ],
  "vectorModels": [
    {
      "model": "text-embedding-ada-002",
      "name": "Embedding-2",
      "inputPrice": 0,
      "outputPrice": 0,
      "defaultToken": 700,
      "maxToken": 3000,
      "weight": 100,
      "defaultConfig": {}
    },
    {
      "model": "m3e",
      "name": "M3E(测试使用)",
      "price": 0.1,
      "defaultToken": 500,
      "maxToken": 1800
    }
  ],
  "reRankModels": [
    {
      "model": "bge-reranker-base",
      "name": "检索重排-base",
      "inputPrice": 0,
      "requestUrl": "http://172.18.59.32:6006/api/v1/rerank",
      "requestAuth": "安全凭证,已自动补 Bearer"
    }
  ],
  "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
  }
}

openai

version: '3.3'

services:
  new-api:
    image: calciumion/new-api:latest
    container_name: new-api
    restart: always
    command: --log-dir /app/logs
    ports:
      - "3001:3000"
    volumes:
      - ./data:/data
      - ./logs:/app/logs
    environment:
      - REDIS_CONN_STRING=redis://redis
      - SESSION_SECRET=abc123
      - TZ=Asia/Shanghai

    depends_on:
      - redis
    healthcheck:
      test: [ "CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $2}'" ]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      new-api-network:
        ipv4_address: 172.18.60.31
        
  redis:
    image: redis:latest
    container_name: redis
    restart: always
    
    networks:
      new-api-network:
        ipv4_address: 172.18.60.32

networks:
  new-api-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.60.0/24
最后修改:2024 年 05 月 11 日
如果觉得我的文章对你有用,请随意赞赏