简单记录一下Fast GPT知识库搭建文件
搭建文件有三个: fastgpt俩文件,one-api文件,chatglm,以及 m3e或者其他向量处理模型
首先第一个 fastgpt的文件,这里我比官网加入了m3e向量处理模型
# 非 host 版本, 不使用本机代理 # (不懂 Docker 的,只需要关心 OPENAI_BASE_URL 和 CHAT_API_KEY 即可!) version: '3.3' services: m3e: # image: stawky/m3e-large-api:latest image: registry.cn-hangzhou.aliyuncs.com/fastgpt_docker/m3e-large-api:latest container_name: m3e_vector restart: always ports: - 16008:6008 networks: - fastgpt 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: # 生产环境建议不要暴露 - 5433:5432 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 ports: # 生产环境建议不要暴露 - 27018:27017 networks: - fastgpt 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: - 13000:3000 networks: - fastgpt depends_on: - mongo - pg restart: always environment: # root 密码,用户名为: root - DEFAULT_ROOT_PSW=1234 # 中转地址,如果是用官方号,不需要管。务必加 /v1 - OPENAI_BASE_URL=http://host.docker.internal:13127/v1 - CHAT_API_KEY=sk-************************************ - DB_MAX_LINK=5 # database max link - TOKEN_KEY=any - ROOT_KEY=root_key - FILE_TOKEN_KEY=filetoken # mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin - MONGODB_URI=mongodb://username:password@host.docker.internal:27018/fastgpt?authSource=admin # pg配置. 不需要改 - PG_URL=postgresql://username:password@host.docker.internal:5433/postgres volumes: - ./config.json:/app/data/config.json networks: fastgpt:
FastGPT config.json
{ "systemEnv": { "openapiPrefix": "fastgpt", "vectorMaxProcess": 15, "qaMaxProcess": 15, "pgHNSWEfSearch": 100 }, "chatModels": [ { "model": "ChatGLM3", "name": "ChatGLM3", "price": 0, "maxToken": 4000, "quoteMaxToken": 2000, "maxTemperature": 1.2, "censor": false, "defaultSystemChatPrompt": "" }, { "model": "gpt-3.5-turbo", "name": "GPT35", "inputPrice": 0, "outputPrice": 0, "maxContext": 4000, "maxResponse": 4000, "quoteMaxToken": 2000, "maxTemperature": 1.2, "censor": false, "vision": false, "defaultSystemChatPrompt": "" }, { "model": "gpt-3.5-turbo-16k", "name": "GPT35-16k", "maxContext": 16000, "maxResponse": 16000, "inputPrice": 0, "outputPrice": 0, "quoteMaxToken": 8000, "maxTemperature": 1.2, "censor": false, "vision": false, "defaultSystemChatPrompt": "" }, { "model": "gpt-4", "name": "GPT4-8k", "maxContext": 8000, "maxResponse": 8000, "inputPrice": 0, "outputPrice": 0, "quoteMaxToken": 4000, "maxTemperature": 1.2, "censor": false, "vision": false, "defaultSystemChatPrompt": "" }, { "model": "gpt-4-vision-preview", "name": "GPT4-Vision", "maxContext": 128000, "maxResponse": 4000, "inputPrice": 0, "outputPrice": 0, "quoteMaxToken": 100000, "maxTemperature": 1.2, "censor": false, "vision": true, "defaultSystemChatPrompt": "" } ], "qaModels": [ { "model": "ChatGLM3", "name": "ChatGLM3", "maxToken": 8000, "price": 0 }, { "model": "gpt-3.5-turbo-16k", "name": "GPT35-16k", "maxContext": 16000, "maxResponse": 16000, "inputPrice": 0, "outputPrice": 0 } ], "cqModels": [ { "model": "ChatGLM3", "name": "ChatGLM3", "maxToken": 8000, "price": 0, "functionCall": true, "functionPrompt": "" }, { "model": "gpt-3.5-turbo", "name": "GPT35", "maxContext": 4000, "maxResponse": 4000, "inputPrice": 0, "outputPrice": 0, "toolChoice": true, "functionPrompt": "" }, { "model": "gpt-4", "name": "GPT4-8k", "maxContext": 8000, "maxResponse": 8000, "inputPrice": 0, "outputPrice": 0, "toolChoice": true, "functionPrompt": "" } ], "extractModels": [ { "model": "ChatGLM3", "name": "ChatGLM3", "maxToken": 8000, "price": 0, "functionCall": true, "functionPrompt": "" }, { "model": "gpt-3.5-turbo-1106", "name": "GPT35-1106", "maxContext": 16000, "maxResponse": 4000, "inputPrice": 0, "outputPrice": 0, "toolChoice": true, "functionPrompt": "" } ], "qgModels": [ { "model": "ChatGLM3", "name": "ChatGLM3", "maxToken": 4000, "price": 0 }, { "model": "gpt-3.5-turbo-1106", "name": "GPT35-1106", "maxContext": 1600, "maxResponse": 4000, "inputPrice": 0, "outputPrice": 0 } ], "vectorModels": [ { "model": "text-embedding-ada-002", "name": "Embedding-2", "price": 0.2, "defaultToken": 700, "maxToken": 3000 }, { "model": "m3e", "name": "M3E(测试使用)", "price": 0.1, "defaultToken": 500, "maxToken": 1800 } ], "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 } }
第二个 openapi文件 这里和官方一样, 至于chatglm这里采用本地部署并未使用docker
version: '3.4' services: one-api: image: justsong/one-api:latest container_name: one-api restart: always command: --log-dir /app/logs ports: - 13127:3000 volumes: - ./data/oneapi:/data - ./logs:/app/logs environment: - SQL_DSN=oneapi:123456@tcp(db:3306)/one-api # 修改此行,或注释掉以使用 SQLite 作为数据库 - REDIS_CONN_STRING=redis://redis - SESSION_SECRET=random_string # 修改为随机字符串 - TZ=Asia/Shanghai # - NODE_TYPE=slave # 多机部署时从节点取消注释该行 # - SYNC_FREQUENCY=60 # 需要定期从数据库加载数据时取消注释该行 # - FRONTEND_BASE_URL=https://openai.justsong.cn # 多机部署时从节点取消注释该行 depends_on: - redis - db 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 redis: image: redis:latest container_name: redis restart: always db: image: mysql:8.2.0 restart: always container_name: mysql volumes: - ./data/mysql:/var/lib/mysql # 挂载目录,持久化存储 ports: - '3306:3306' environment: TZ: Asia/Shanghai # 设置时区 MYSQL_ROOT_PASSWORD: 'OneAPI@justsong' # 设置 root 用户的密码 MYSQL_USER: oneapi # 创建专用用户 MYSQL_PASSWORD: '123456' # 设置专用用户密码 MYSQL_DATABASE: one-api # 自动创建数据库
第三个chatglm 部署文档
这里是官方docker可以尝试下,也可以使用linux部署,这个看官方readme就好了
version: "3.6" services: glm3_api: image: python:3.10.13-slim restart: unless-stopped working_dir: /glm3 container_name: glm3_api env_file: ./.env networks: - v_glm3 deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] environment: - MODEL_PATH=/models/chatglm3-6b - EMBEDDING_PATH=/models/bge-large-zh-v1.5 - TZ=Asia/Shanghai - PYTHONDONTWRITEBYTECODE=1 - PYTHONUNBUFFERED=1 - DOCKER=True ports: - 8100:8000 volumes: - ./:/glm3 - ${MODELSCOPE_CACHE}:/ZhipuAI/chatglm3-6b - ${MODELSCOPE_CACHE}:/hub/bge-large-zh-v1.5 command: - sh - -c - | sed -i s/deb.debian.org/mirrors.tencentyun.com/g /etc/apt/sources.list sed -i s/security.debian.org/mirrors.tencentyun.com/g /etc/apt/sources.list apt-get update python -m pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple --upgrade pip pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple python openai_api.py networks: v_glm3: driver: bridge
总结
总结来说呢,就是需要再Fast GPT官方给的部署基础上 多加一个m3e向量处理模型,官方这里通过调用one-api转接道openAI那里处理了,如果是私有部署的话,一些敏感信息是不可能送到openai那里去处理向量的.
还会有更好的向量模型这里Fast GPT推荐m3e就用的这个,可以深入调研下,以便更好匹配知识库识别准确度.