本地部署基于LLama3知识库问答 (OLLama+Oneapi+Fastgpt)
关于如何本地部署基于LLama3知识库问答系统的指南,涉及OLLama、OneAPI和FastGPT三个组件。文档内容主要分为以下几个步骤:使用docker搭建ollama容器:安装NVIDIA Container Toolkit,包括配置仓库和安装相关包。启动ollama容器,映射端口并设置卷。使用ChatOllama下载模型以及体验模型:通过docker-compose.yml文件运行容器,并
·
1.使用docker搭建ollama容器
1.Install the NVIDIA Container Toolkit.
Configure the repository
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
2.Install the NVIDIA Container Toolkit packages
sudo apt-get install -y nvidia-container-toolkit
3.Start the container
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
2.使用ChatOllama下载模型 以及体验模型
1.创建chatollama文件夹 然后下载docker-compose.yml
2.运行容器
docker-compose build
docker-compose up
3.首次运行需要初始化初始化SQLite数据库
docker compose exec chatollama npx prisma migrate dev
4.登录127.0.0.1:3000 访问chatOllama 配置ollama地址
5.下载embedding和chat模型 进行推理 以及可以插入本地数据库数据
3.Docker命令创建one-api容器(ip:3001):
sudo docker run --name oneapi -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data justsong/one-api
创建容器 访问127.0.0.1:3001 创建一个令牌 设置无线访问 以及无限访问时间
创建chat以及embedding渠道
embeding渠道
设置秘钥为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk
chat渠道
4.Docker命令创建fastgpt容器(ip:3020):
在任意目录中手动创建文件夹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: pg
restart: always
ports: # 生产环境建议不要暴露
- 5432: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: # 生产环境建议不要暴露
- 27017: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:v4.6.6 # 阿里云
ports:
- 3020:3000 #与One API的默认3000地址冲突,所有修改为3020
networks:
- fastgpt
depends_on:
- mongo
- pg
restart: always
environment:
# root 密码,用户名为: root
- DEFAULT_ROOT_PSW=1234
# 中转地址,如果是用官方号,不需要管
- OPENAI_BASE_URL=http://192.168.35.134:3000/v1
- CHAT_API_KEY=sk-ZZKMAmTrQcv5Xbiw16857a9a070d454bAdF95aEf814f0e38
- 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/postgres
volumes:
- ./config.json:/app/data/config.json
networks:
fastgpt:
主要修改以下
- OPENAI_BASE_URL=http://192.168.35.134:3000/v1 你的Ipv4地址
- CHAT_API_KEY=sk-ZZKMAmTrQcv5Xbiw16857a9a070d4 换成你的秘钥
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": "chatglm3",
"name": "chatglm3",
"inputPrice": 0,
"outputPrice": 0,
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 2000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
}
],
"cqModels": [
{
"model": "chatglm3",
"name": "chatglm3",
"inputPrice": 0,
"outputPrice": 0,
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 2000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
}
],
"extractModels": [
{
"model": "chatglm3",
"name": "chatglm3",
"inputPrice": 0,
"outputPrice": 0,
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 2000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
}
],
"qgModels": [
{
"model": "chatglm3",
"name": "chatglm3",
"inputPrice": 0,
"outputPrice": 0,
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 2000,
"maxTemperature": 1.2,
"censor": false,
"vision": false,
"defaultSystemChatPrompt": ""
}
],
"vectorModels": [
{
"model": "m3e",
"name": "m3e",
"price": 0.1,
"defaultToken": 700,
"maxToken": 3000
}
],
"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
}
}
然后在此目录下打开终端输入以下命令(创建的fastgpt文件夹内打开命令行):
docker-compose bulid #依据docker-compose.yum生成镜像
docker-compose up -d #启动容器加 -d代表后台守护进程启动
进入fastgpt的web页面:
输入默认的用户名root,密码1234 创建应用设置
设置知识库
进行对话
更多推荐
已为社区贡献2条内容
所有评论(0)