创建并运行chatglm3容器
docker run --name chatglm3 -p 8000:8000 registry.cn-hangzhou.aliyuncs.com/ryyan/chatglm.cpp:chatglm3-q5_1
创建并运行one-api容器
(其中挂载路径 D:\one-api 可以选择你自己喜欢的目录)
docker run --name oneapi -d -p 3000:3000 -e TZ=Asia/Shanghai -v D:\one-api:/data justsong/one-api
浏览器登录 http://127.0.0.1:3000/
默认用户名 root 密码 123456
添加渠道
添加令牌
复制令牌
测试一下刚刚创建的渠道
部署FastGPT
在你自己喜欢的磁盘上创建fastgpt目录,我是 D:\fastgpt
创建两个文件 docker-compose.yml 和 config.json
其中,docker-compose.yml 内容为:
# 非 host 版本, 不使用本机代理
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: pgrestart: alwaysports: # 生产环境建议不要暴露- 5432:5432networks:- fastgptenvironment:# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果- POSTGRES_USER=username- POSTGRES_PASSWORD=password- POSTGRES_DB=postgresvolumes:- ./pg/data:/var/lib/postgresql/datamongo:image: mongo:5.0.18# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云container_name: mongorestart: alwaysports: # 生产环境建议不要暴露- 27017:27017networks:- fastgptenvironment:# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果- MONGO_INITDB_ROOT_USERNAME=username- MONGO_INITDB_ROOT_PASSWORD=passwordvolumes:- ./mongo/data:/data/dbfastgpt:container_name: fastgpt#image: ghcr.io/labring/fastgpt:latest # gitimage: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.6.6 # 阿里云ports:- 3020:3000 #与One API的默认3000地址冲突,所有修改为3020networks:- fastgptdepends_on:- mongo- pgrestart: alwaysenvironment:# root 密码,用户名为: root- DEFAULT_ROOT_PSW=1234# 中转地址,如果是用官方号,不需要管- OPENAI_BASE_URL=http://172.16.xxx.yyy:3000/v1- CHAT_API_KEY=sk-lBKqDxIOQtVgkPYo7274CbC9632748B6Ac8d515123456789- 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@mongo:27017/fastgpt?authSource=admin# pg配置. 不需要改- PG_URL=postgresql://username:password@pg:5432/postgresvolumes:- ./config.json:/app/data/config.json
networks:fastgpt:
需要修改的地方是
- OPENAI_BASE_URL=http://172.16.xxx.yyy:3000/v1
- CHAT_API_KEY=sk-lBKqDxIOQtVgkPYo7274CbC9632748B6Ac8d515123456789
改成你的IP,和刚才在 One API 中复制的令牌
config.json 的内容为:
{"systemEnv": {"openapiPrefix": "fastgpt","vectorMaxProcess": 15,"qaMaxProcess": 15,"pgHNSWEfSearch": 100},"chatModels": [{"model": "chatglm3","name": "chatglm3","inputPrice": 0,"outputPrice": 0,"maxContext": 4000,"maxResponse": 4000,"quoteMaxToken": 2000,"maxTemperature": 1.2,"censor": false,"vision": false,"defaultSystemChatPrompt": ""}],"qaModels": [{"model": "gpt-3.5-turbo-16k","name": "GPT35-16k","maxContext": 16000,"maxResponse": 16000,"inputPrice": 0,"outputPrice": 0}],"cqModels": [{"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": "gpt-3.5-turbo-1106","name": "GPT35-1106","maxContext": 16000,"maxResponse": 4000,"inputPrice": 0,"outputPrice": 0,"toolChoice": true,"functionPrompt": ""}],"qgModels": [{"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","inputPrice": 0,"outputPrice": 0,"defaultToken": 700,"maxToken": 3000,"weight": 100}],"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}
}
保存完之后,在当前目录中打开 Windows PowerShell,我是用 Git Bash Here, 两个都是一样的。
输入以下两个命令:
拉取镜像
docker-compose pull
运行容器
docker-compose up -d
如果需要修改docker-compose.yml,执行
docker-compose down
docker-compose up -d
就能重新构建容器了
运行成功了,可以使用 docker ps 命令检查以下所有容器是否正常启动
打开浏览器访问 http://127.0.0.1:3020/
默认用户名 root 密码 1234
接下来就是玩了:
--------------------------------------------------------添加其他更多模型------------------------------------------------------------------------------------------------------
前提条件,先安装其他模型,请看文章 docker安装ollama-CSDN博客
例如,我这里又加上了 llama2 和 gemma:7b,可以直接修改config.json文件
然后,重启One API容器,
docker stop oneapi
docker start oneapi
登录one api,添加渠道
登录FastGPT,添加新的应用
有时候模型很久都没有响应,不知道是不是休眠了,回到one-api页面,点击一下测试,刷新几下浏览器,多点几次,它又醒了,搞不懂。
或者直接命令行运行模型:
目前测试发现,gemma:7b 模型速度快,但是没有 ChatGLM3 聪明。