Skip to content

Commit

Permalink
v4.5 (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Oct 17, 2023
1 parent dd8f274 commit 3b776b6
Show file tree
Hide file tree
Showing 98 changed files with 1,524 additions and 982 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ ARG name
# copy packages and one project
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY ./packages ./packages
COPY ./projects/$name ./projects/$name
COPY ./projects/$name/package.json ./projects/$name/package.json

RUN \
[ -f pnpm-lock.yaml ] && pnpm install || \
(echo "Lockfile not found." && exit 1)

RUN pnpm prune

# Rebuild the source code only when needed
FROM node:current-alpine AS builder
WORKDIR /app

ARG name

# copy common node_modules and one project node_modules
COPY package.json pnpm-workspace.yaml ./
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/packages ./packages
COPY --from=deps /app/projects/$name ./projects/$name
COPY ./projects/$name ./projects/$name
COPY --from=deps /app/projects/$name/node_modules ./projects/$name/node_modules

# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
Expand Down
Binary file added docSite/assets/imgs/v45-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docSite/assets/imgs/v45-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docSite/assets/imgs/v45-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docSite/assets/imgs/v45-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docSite/content/docs/custom-models/chatglm2-m3e.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One

```json
"ChatModels": [
//已有模型
//其他对话模型
{
"model": "chatglm2",
"name": "chatglm2",
"contextMaxToken": 8000,
"maxToken": 8000,
"price": 0,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"price": 0,
"defaultSystem": ""
"defaultSystemChatPrompt": ""
}
],
"VectorModels": [
Expand Down
6 changes: 3 additions & 3 deletions docSite/content/docs/custom-models/chatglm2.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One
{
"model": "chatglm2",
"name": "chatglm2",
"contextMaxToken": 8000,
"maxToken": 8000,
"price": 0,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"price": 0,
"defaultSystem": ""
"defaultSystemChatPrompt": ""
}
]
```
Expand Down
92 changes: 53 additions & 39 deletions docSite/content/docs/development/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,75 @@ weight: 520
},
"ChatModels": [
{
"model": "gpt-3.5-turbo",
"name": "GPT35-4k",
"contextMaxToken": 4000, // 最大token,均按 gpt35 计算
"model": "gpt-3.5-turbo", // 实际调用的模型
"name": "GPT35-4k", // 展示的名字
"maxToken": 4000, // 最大token,均按 gpt35 计算
"quoteMaxToken": 2000, // 引用内容最大 token
"maxTemperature": 1.2, // 最大温度
"price": 0,
"defaultSystem": ""
"defaultSystemChatPrompt": ""
},
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"contextMaxToken": 16000,
"maxToken": 16000,
"quoteMaxToken": 8000,
"maxTemperature": 1.2,
"price": 0,
"defaultSystem": ""
"defaultSystemChatPrompt": ""
},
{
"model": "gpt-4",
"name": "GPT4-8k",
"contextMaxToken": 8000,
"maxToken": 8000,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"price": 0,
"defaultSystem": ""
"defaultSystemChatPrompt": ""
}
],
"QAModel": [ // QA 拆分模型
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0
}
],
"ExtractModels": [ // 内容提取模型
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0,
"functionCall": true, // 是否支持 function call
"functionPrompt": "" // 自定义非 function call 提示词
}
],
"CQModels": [ // Classify Question: 问题分类模型
{
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0,
"functionCall": true,
"functionPrompt": ""
},
{
"model": "gpt-4",
"name": "GPT4-8k",
"maxToken": 8000,
"price": 0,
"functionCall": true,
"functionPrompt": ""
}
],
"QGModels": [ // Question Generation: 生成下一步指引模型
{
"model": "gpt-3.5-turbo",
"name": "GPT35-4k",
"maxToken": 4000,
"price": 0
}
],
"VectorModels": [
Expand All @@ -62,36 +106,6 @@ weight: 520
"defaultToken": 500,
"maxToken": 3000
}
],
"QAModel": { // QA 拆分模型
"model": "gpt-3.5-turbo-16k",
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0
},
"ExtractModel": { // 内容提取模型
"model": "gpt-3.5-turbo-16k",
"functionCall": true, // 是否使用 functionCall
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0,
"prompt": ""
},
"CQModel": { // Classify Question: 问题分类模型
"model": "gpt-3.5-turbo-16k",
"functionCall": true,
"name": "GPT35-16k",
"maxToken": 16000,
"price": 0,
"prompt": ""
},
"QGModel": { // Question Generation: 生成下一步指引模型
"model": "gpt-3.5-turbo",
"name": "GPT35-4k",
"maxToken": 4000,
"price": 0,
"prompt": "",
"functionCall": false
}
]
}
```
15 changes: 15 additions & 0 deletions docSite/content/docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ docker-compose 端口定义为:`映射端口:运行端口`。

(自行补习 docker 基本知识)

### relation "modeldata" does not exist

PG 数据库没有连接上/初始化失败,可以查看日志。FastGPT 会在每次连接上 PG 时进行表初始化,如果报错会有对应日志。

1. 检查数据库容器是否正常启动
2. 非 docker 部署的,需要手动安装 pg vector 插件
3. 查看 fastgpt 日志,有没有相关报错

### Operation `auth_codes.findOne()` buffering timed out after 10000ms

mongo连接失败,检查
1. mongo 服务有没有起来(有些 cpu 不支持 AVX,无法用 mongo5,需要换成 mongo4.x,可以dockerhub找个最新的4.x,修改镜像版本,重新运行)
2. 环境变量(账号密码,注意host和port)


### 错误排查方式

遇到问题先按下面方式排查。
Expand Down
6 changes: 3 additions & 3 deletions docSite/content/docs/installation/one-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ CHAT_API_KEY=sk-xxxxxx
{
"model": "ERNIE-Bot", // 这里的模型需要对应 One API 的模型
"name": "文心一言", // 对外展示的名称
"contextMaxToken": 4000, // 最大长下文 token,无论什么模型都按 GPT35 的计算。GPT 外的模型需要自行大致计算下这个值。可以调用官方接口去比对 Token 的倍率,然后在这里粗略计算。
"maxToken": 4000, // 最大长下文 token,无论什么模型都按 GPT35 的计算。GPT 外的模型需要自行大致计算下这个值。可以调用官方接口去比对 Token 的倍率,然后在这里粗略计算。
// 例如:文心一言的中英文 token 基本是 1:1,而 GPT 的中文 Token 是 2:1,如果文心一言官方最大 Token 是 4000,那么这里就可以填 8000,保险点就填 7000.
"price": 0, // 1个token 价格 => 1.5 / 100000 * 1000 = 0.015元/1k token
"quoteMaxToken": 2000, // 引用知识库的最大 Token
"maxTemperature": 1, // 最大温度
"price": 0, // 1个token 价格 => 1.5 / 100000 * 1000 = 0.015元/1k token
"defaultSystem": "" // 默认的系统提示词
"defaultSystemChatPrompt": "" // 默认的系统提示词
}
...
],
Expand Down
84 changes: 84 additions & 0 deletions docSite/content/docs/installation/upgrading/45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: 'V4.5(需进行较为复杂更新)'
description: 'FastGPT V4.5 更新'
icon: 'upgrade'
draft: false
toc: true
weight: 839
---

FastGPT V4.5 引入 PgVector0.5 版本的 HNSW 索引,极大的提高了知识库检索的速度,比起`IVFFlat`索引大致有3~10倍的性能提升,可轻松实现百万数据毫秒级搜索。缺点在于构建索引的速度非常慢,4c16g 500w 组数据使用`并行构建`大约花了 48 小时。具体参数配置可参考 [PgVector官方](https://github.com/pgvector/pgvector)

下面需要对数据库进行一些操作升级:

## PgVector升级:Sealos 部署方案

1. 点击[Sealos桌面](https://cloud.sealos.io)的数据库应用。
2. 点击【pg】数据库的详情。
3. 点击右上角的重启,等待重启完成。
4. 点击左侧的一键链接,等待打开 Terminal。
5. 依次输入下方 sql 命令

```sql
-- 升级插件名
ALTER EXTENSION vector UPDATE;
-- 插件是否升级成功,成功的话,vector插件版本为 0.5.0,旧版的为 0.4.1
\dx

-- 下面两个语句会设置 pg 在构建索引时可用的内存大小,需根据自身的数据库规格来动态配置,可配置为 1/4 的内存大小
alter system set maintenance_work_mem = '2400MB';
select pg_reload_conf();

-- 开始构建索引,该索引构建时间非常久,直接点击右上角的叉,退出 Terminal 即可
CREATE INDEX CONCURRENTLY vector_index ON modeldata USING hnsw (vector vector_ip_ops) WITH (m = 16, ef_construction = 64);
-- 可以再次点击一键链接,进入 Terminal,输入下方命令,如果看到 "vector_index" hnsw (vector vector_ip_ops) WITH (m='16', ef_construction='64') 则代表构建完成(注意,后面没有 INVALID)
\d modeldata
```

| | |
| --------------------- | --------------------- |
| ![](/imgs/v45-1.png) | ![](/imgs/v45-2.png) |
| ![](/imgs/v45-3.png) | ![](/imgs/v45-4.png) |



## PgVector升级:Docker-compose.yml 部署方案

下面的命令是基于给的 docker-compose 模板,如果数据库账号密码更换了,请自行调整。

1. 修改 `docker-compose.yml` 中pg的镜像版本,改成 `ankane/pgvector:v0.5.0``registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0`
2. 重启 pg 容器(docker-compose pull && docker-compose up -d),等待重启完成。
3. 进入容器: `docker exec -it pg bash`
4. 连接数据库: `psql 'postgresql://username:password@localhost:5432/postgres'`
5. 执行下面 sql 命令

```sql
-- 升级插件名
ALTER EXTENSION vector UPDATE;
-- 插件是否升级成功,成功的话,vector插件版本为 0.5.0,旧版的为 0.4.2
\dx

-- 下面两个语句会设置 pg 在构建索引时可用的内存大小,需根据自身的数据库规格来动态配置,可配置为 1/4 的内存大小
alter system set maintenance_work_mem = '2400MB';
select pg_reload_conf();

-- 开始构建索引,该索引构建时间非常久,直接关掉终端即可,不要使用 ctrl+c 关闭
CREATE INDEX CONCURRENTLY vector_index ON modeldata USING hnsw (vector vector_ip_ops) WITH (m = 16, ef_construction = 64);
-- 可以再次连接数据库,输入下方命令。如果看到 "vector_index" hnsw (vector vector_ip_ops) WITH (m='16', ef_construction='64') 则代表构建完成(注意,后面没有 INVALID)
\d modeldata
```

## 版本新功能介绍

### Fast GPT V4.5

1. 新增 - 升级 PgVector 插件,引入 HNSW 索引,极大加快的知识库搜索速度。
2. 新增 - AI对话模块,增加【返回AI内容】选项,可控制 AI 的内容不直接返回浏览器。
3. 新增 - 支持问题分类选择模型
4. 优化 - TextSplitter,采用递归拆解法。
5. 优化 - 高级编排 UX 性能
6. 修复 - 分享链接鉴权问题

## 该版本需要修改 `config.json` 文件

最新配置可参考: [V45版本最新 config.json](/docs/development/configuration)
Loading

0 comments on commit 3b776b6

Please sign in to comment.