FastGPT原生部署

labring/FastGPT: FastGPT is a knowledge-based QA system built on the LLM, offers out-of-the-box data processing and model invocation capabilities, allows for workflow orchestration through Flow visualization!

可以查看官方文档使用dockers部署,本文介绍的原生部署的方式。

知识库原理

img

image-20230929191248527

FastGPT依赖

PostgreSQL DB

https://ftp.postgresql.org/pub/source/

PostgreSQL依赖库

dnf install gcc bison gcc-c++ readline readline-devel zlib zlib-devel perl perl-devel systemd-devel libicu libicu-devel

安装

#创建用户及目录
useradd postgres
mkdir -p /opt/postgres
mkdir -p /data/postgresdb
chown -R postgres:postgres /opt/postgres
chown -R postgres:postgres /opt/postgresdb

#配置
./configure --prefix=/opt/postgresql --datadir=/data/postgresdb --with-blocksize=8 --with-segsize=1 --with-wal-blocksize=8 --without-readline

#编译安装
make
make install

#初始化
mkdir -p /data/postgresdb/data
/initdb -D /data/postgresdb/data/

#启动
sudo -u postgres /opt/postgresql/bin/pg_ctl -D /data/postgresdb/data/ -l postgresdb.log start

#配置文件
#修改监听的地址
data/postgresql.conf

data/pg_hba.conf

host    fastgpt_te    fastgpt_user    192.168.0.0/24    md5

pgvector插件

pgvector/pgvector:Postgres 的开源向量相似性搜索

cd /tmp
git clone --branch v0.5.0 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudo

启用扩展(在每个要使用它的数据库中执行一次)
CREATE EXTENSION vector;

创建库、用户

CREATE DATABASE fastgpt_te;
ALTER USER fastgpt_user WITH PASSWORD 'fastgpt_123pass';
GRANT ALL PRIVILEGES ON DATABASE fastgpt_te TO fastgpt_user;
CREATE EXTENSION vector;

连接串

PG_URL=postgresql://fastgpt_user:fastgpt_123pass@192.168.0.108:5432/fastgpt_te

mongo DB

下载 MongoDB 社区服务器 | MongoDB

# 创建配置文件
mongod.conf

net:
  bindIp: 0.0.0.0

#启动
./mongod --dbpath /data/mongodb --logpath /data/mongodb/log/mongod.log --config /opt/mongodb-7.0/mongod.conf --fork

#停止
./mongod --dbpath /data/mongodb --logpath /data/mongodb/log/mongod.log --config /opt/mongodb-7.0/mongod.conf --shutdown 

安装mongo shell

https://downloads.mongodb.com/compass/mongodb-mongosh-shared-openssl3-2.0.1.x86_64.rpm

创建库、用户

use fastgpt_mon_te
db.createUser({
  user: "fastgpt_mon_user",
  pwd: "fastgpt_mon_pass",
  roles: [
    { role: "readWrite", db: "fastgpt_mon_te" }
  ]
})

连接串

MONGODB_URI=mongodb://fastgpt_mon_user:fastgpt_mon_pass@192.168.0.108:27017/fastgpt_mon_te?authSource=fastgpt_mon_te

one api

用作fastGPT-api

https://oneapi.ahaly.cc/
sk-xcbE********

Node.js

部署FastGPT

labring/FastGPT: FastGPT is a knowledge-based QA system built on the LLM, offers out-of-the-box data processing and model invocation capabilities, allows for workflow orchestration through Flow visualization!

#配置文件
FastGPT/projects/app/.env.template
复制.env.template 文件,在同级目录下生成一个.env.local 文件,修改.env.local 里内容才是有效的变量
#模型相关
FastGPT/projects/app/data/config.json

#pnpm
npm install -g pnpm

pnpm i
# FastGPT 主程序
cd projects/app 
#开发者运行
pnpm dev

#生产运行
pnpm build
pnpm start

演示

可以在我搭建的中测试效果。

AHA项目常见问题

常见问题

error: relation “modeldata’ does not exist

PgDatasetTableName = 'modeldata';

-- 创建 "vector" 扩展(如果不存在)
CREATE EXTENSION IF NOT EXISTS vector;

-- 创建表 modeldata
CREATE TABLE IF NOT EXISTS modeldata (
    id BIGSERIAL PRIMARY KEY,
    vector VECTOR(1536) NOT NULL,
    user_id VARCHAR(50) NOT NULL,
    kb_id VARCHAR(50),
    source VARCHAR(100),
    file_id VARCHAR(100),
    q TEXT NOT NULL,
    a TEXT
);

-- 创建索引 "modelData_userId_index"
CREATE INDEX IF NOT EXISTS modelData_userId_index ON modeldata USING HASH (user_id);

-- 创建索引 "modelData_kbId_index"
CREATE INDEX IF NOT EXISTS modelData_kbId_index ON modeldata USING HASH (kb_id);

-- 创建复合索引 "idx_model_data_md5_q_a_user_id_kb_id"
CREATE INDEX IF NOT EXISTS idx_model_data_md5_q_a_user_id_kb_id ON modeldata (md5(q), md5(a), user_id, kb_id);

原文

原文地址,遇到格式错误或者超链接图片失效的请查看原文。转载注明来源
FastGPT原生部署 - good good study,day day up~

# AI 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×