Skip to content

Commit d2d7eac

Browse files
authored
4.6.4 (labring#588)
1 parent 84cf6b5 commit d2d7eac

File tree

105 files changed

+1088
-798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1088
-798
lines changed

docSite/assets/imgs/webSync1.jpg

268 KB
Loading

docSite/assets/imgs/webSync10.jpg

1.65 MB
Loading

docSite/assets/imgs/webSync2.jpg

123 KB
Loading

docSite/assets/imgs/webSync3.jpg

190 KB
Loading

docSite/assets/imgs/webSync4.jpg

139 KB
Loading

docSite/assets/imgs/webSync5.jpg

322 KB
Loading

docSite/assets/imgs/webSync6.jpg

836 KB
Loading

docSite/assets/imgs/webSync7.jpg

1.55 MB
Loading

docSite/assets/imgs/webSync8.jpg

1.55 MB
Loading

docSite/assets/imgs/webSync9.jpg

1.49 MB
Loading
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: 'Web 站点同步'
3+
description: 'FastGPT Web 站点同步功能介绍和使用方式'
4+
icon: 'language'
5+
draft: false
6+
toc: true
7+
weight: 105
8+
---
9+
10+
![](/imgs/webSync1.jpg)
11+
12+
## 什么是 Web 站点同步
13+
14+
Web 站点同步利用爬虫的技术,可以通过一个入口网站,自动捕获`同域名`下的所有网站,目前最多支持`200`个子页面。出于合规与安全角度,FastGPT 仅支持`静态站点`的爬取,主要用于各个文档站点快速构建知识库。
15+
16+
Tips: 国内的媒体站点基本不可用,公众号、csdn、知乎等。可以通过终端发送`curl`请求检测是否为静态站点,例如:
17+
18+
```bash
19+
curl ai.fastgpt.in
20+
```
21+
22+
## 如何使用
23+
24+
### 1. 新建知识库,选择 Web 站点同步
25+
26+
![](/imgs/webSync2.jpg)
27+
28+
![](/imgs/webSync3.jpg)
29+
30+
### 2. 点击配置站点信息
31+
32+
![](/imgs/webSync4.jpg)
33+
34+
### 3. 填写网址和选择器
35+
36+
![](/imgs/webSync5.jpg)
37+
38+
好了, 现在点击开始同步,静等系统自动抓取网站信息即可。
39+
40+
41+
## 创建应用,绑定知识库
42+
43+
![](/imgs/webSync6.jpg)
44+
45+
## 选择器如何使用
46+
47+
选择器是 HTML CSS JS 的产物,你可以通过选择器来定位到你需要抓取的具体内容,而不是整个站点。使用方式为:
48+
49+
### 首先打开浏览器调试面板(通常是 F12,或者【右键 - 检查】)
50+
51+
![](/imgs/webSync7.jpg)
52+
53+
![](/imgs/webSync8.jpg)
54+
55+
### 输入对应元素的选择器
56+
57+
[菜鸟教程 css 选择器](https://www.runoob.com/cssref/css-selectors.html),具体选择器的使用方式可以参考菜鸟教程。
58+
59+
上图中,我们选中了一个区域,对应的是`div`标签,它有 `data-prismjs-copy`, `data-prismjs-copy-success`, `data-prismjs-copy-error` 三个属性,这里我们用到一个就够。所以选择器是:
60+
**`div[data-prismjs-copy]`**
61+
62+
除了属性选择器,常见的还有类和ID选择器。例如:
63+
64+
![](/imgs/webSync9.jpg)
65+
66+
上图 class 里的是类名(可能包含多个类名,都是空格隔开的,选择一个即可),选择器可以为:**`.docs-content`**
67+
68+
### 多选择器使用
69+
70+
在开头的演示中,我们对 FastGPT 文档是使用了多选择器的方式来选择,通过逗号隔开了两个选择器。
71+
72+
![](/imgs/webSync10.jpg)
73+
74+
我们希望选中上图两个标签中的内容,此时就需要两组选择器。一组是:`.docs-content .mb-0.d-flex`,含义是 `docs-content` 类下同时包含 `mb-0``d-flex` 两个类的子元素;
75+
76+
另一组是`.docs-content div[data-prismjs-copy]`,含义是`docs-content` 类下包含`data-prismjs-copy`属性的`div`元素。
77+
78+
把两组选择器用逗号隔开即可:`.docs-content .mb-0.d-flex, .docs-content div[data-prismjs-copy]`

docSite/content/docs/development/one-api.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
22
title: '接入微软、ChatGLM、本地模型等'
3-
description: '通过接入 One API 来实现对各种大模型的支持'
3+
description: '部署和接入 OneAPI,实现对各种大模型的支持'
44
icon: 'Api'
55
draft: false
66
toc: true
77
weight: 708
88
---
99

10-
* 默认情况下,FastGPT 只配置了 GPT 的 3 个模型,如果你需要接入其他模型,需要进行一些额外配置。
10+
* 默认情况下,FastGPT 只配置了 GPT 的模型,如果你需要接入其他模型,需要进行一些额外配置。
1111
* [One API](https://github.com/songquanpeng/one-api) 是一个 OpenAI 接口管理 & 分发系统,可以通过标准的 OpenAI API 格式访问所有的大模型,开箱即用。
12-
13-
FastGPT 可以通过接入 One API 来实现对各种大模型的支持。部署方法也很简单。
12+
* FastGPT 可以通过接入 OneAPI 来实现对不同大模型的支持。OneAPI 的部署方法也很简单。
1413

1514
## MySQL 版本
1615

docSite/content/docs/development/openapi/dataset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ curl --location --request POST 'https://fastgpt.run/api/core/dataset/searchTest'
179179
{{< tab tabName="响应示例" >}}
180180
{{< markdownify >}}
181181

182-
返回 top limit 结果
182+
返回 top k 结果, limit 为预估条数,会按每条数据 800 tokens 的长度进行预估,20条也就是返回 16000 tokens 长度的数据,最多测试 30000 tokens 的数据。
183183

184184
```bash
185185
{
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: 'V4.6.4(需要初始化)'
3+
description: 'FastGPT V4.6.4'
4+
icon: 'upgrade'
5+
draft: false
6+
toc: true
7+
weight: 832
8+
---
9+
10+
## 1。执行初始化 API
11+
12+
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`,{{host}} 替换成自己域名)
13+
14+
1. https://xxxxx/api/admin/initv464
15+
16+
```bash
17+
curl --location --request POST 'https://{{host}}/api/admin/initv464' \
18+
--header 'rootkey: {{rootkey}}' \
19+
--header 'Content-Type: application/json'
20+
```
21+
22+
初始化说明:
23+
1. 初始化 PG 的createTime字段
24+
2. 初始化 Mongo 中 chat 的 feedback 字段
25+
26+
27+
## V4.6.4 功能介绍
28+
29+
1. 重写 - 分享链接身份逻辑,采用 localID 记录用户的ID。
30+
2. 商业版新增 - 分享链接 SSO 方案,通过`身份鉴权`地址,仅需`3个接口`即可完全接入已有用户系统。具体参考[分享链接身份鉴权](/docs/development/openapi/share/)
31+
3. 调整 - 知识库搜索模块 topk 逻辑,采用 MaxToken 计算,兼容不同长度的文本块
32+
4. 调整鉴权顺序,提高 apikey 的优先级,避免cookie抢占 apikey 的鉴权。
33+
5. 链接读取支持多选择器。参考[Web 站点同步用法](/docs/course/webSync)
34+
6. 修复 - 分享链接图片上传鉴权问题
35+
7. 修复 - Mongo 连接池未释放问题。
36+
8. 修复 - Dataset Intro 无法更新
37+
9. 修复 - md 代码块问题
38+
10. 修复 - root 权限问题
39+
11. 优化 docker file
40+
41+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const HUMAN_ICON = `/icon/human.svg`;
2+
export const LOGO_ICON = `/icon/logo.svg`;

packages/global/common/system/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type FeConfigsType = {
99
hide_app_flow?: boolean;
1010
concatMd?: string;
1111
docUrl?: string;
12+
chatbotUrl?: string;
1213
openAPIDocUrl?: string;
1314
systemTitle?: string;
1415
googleClientVerKey?: string;

packages/global/core/chat/api.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type UpdateChatFeedbackProps = {
2+
chatId: string;
3+
chatItemId: string;
4+
shareId?: string;
5+
outLinkUid?: string;
6+
userBadFeedback?: string;
7+
userGoodFeedback?: string;
8+
};

packages/global/core/chat/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ export enum ChatStatusEnum {
5050
finish = 'finish'
5151
}
5252

53-
export const HUMAN_ICON = `/icon/human.svg`;
54-
export const LOGO_ICON = `/icon/logo.svg`;
55-
5653
export const IMG_BLOCK_KEY = 'img-block';
5754
export const FILE_BLOCK_KEY = 'file-block';
5855

packages/global/core/chat/type.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export type ChatItemSchema = {
3838
time: Date;
3939
obj: `${ChatRoleEnum}`;
4040
value: string;
41-
userFeedback?: string;
41+
userGoodFeedback?: string;
42+
userBadFeedback?: string;
43+
robotBadFeedback?: string;
4244
adminFeedback?: AdminFbkType;
4345
[ModuleOutputKeyEnum.responseData]?: ChatHistoryItemResType[];
4446
};
@@ -56,7 +58,8 @@ export type ChatItemType = {
5658
dataId?: string;
5759
obj: ChatItemSchema['obj'];
5860
value: any;
59-
userFeedback?: string;
61+
userGoodFeedback?: string;
62+
userBadFeedback?: string;
6063
adminFeedback?: ChatItemSchema['feedback'];
6164
[ModuleOutputKeyEnum.responseData]?: ChatHistoryItemResType[];
6265
};

packages/global/core/dataset/api.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export type CreateDatasetCollectionParams = {
2525
chunkSize?: number;
2626
fileId?: string;
2727
rawLink?: string;
28+
qaPrompt?: string;
29+
hashRawText?: string;
2830
metadata?: Record<string, any>;
2931
};
3032

@@ -40,6 +42,7 @@ export type PgSearchRawType = {
4042
export type PushDatasetDataChunkProps = {
4143
q: string; // embedding content
4244
a?: string; // bonus content
45+
chunkIndex?: number;
4346
indexes?: Omit<DatasetDataIndexItemType, 'dataId'>[];
4447
};
4548

packages/global/core/dataset/type.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export type DatasetCollectionSchemaType = {
4545
chunkSize: number;
4646
fileId?: string;
4747
rawLink?: string;
48+
qaPrompt?: string;
49+
hashRawText?: string;
4850
metadata?: Record<string, any>;
4951
};
5052

@@ -134,6 +136,7 @@ export type DatasetDataItemType = {
134136
sourceId?: string;
135137
q: string;
136138
a: string;
139+
chunkIndex: number;
137140
indexes: DatasetDataIndexItemType[];
138141
isOwner: boolean;
139142
canWrite: boolean;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1+
export enum UserStatusEnum {
2+
active = 'active',
3+
forbidden = 'forbidden'
4+
}
5+
export const userStatusMap = {
6+
[UserStatusEnum.active]: {
7+
label: 'support.user.status.active'
8+
},
9+
[UserStatusEnum.forbidden]: {
10+
label: 'support.user.status.forbidden'
11+
}
12+
};
13+
114
export enum OAuthEnum {
215
github = 'github',
316
google = 'google'
417
}
18+
19+
export enum UserAuthTypeEnum {
20+
register = 'register',
21+
findPassword = 'findPassword'
22+
}

packages/global/support/user/type.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InformTypeEnum } from './constant';
1+
import { InformTypeEnum, UserStatusEnum } from './constant';
22
import { TeamItemType } from './team/type';
33

44
export type UserModelSchema = {
@@ -12,6 +12,7 @@ export type UserModelSchema = {
1212
openaiKey: string;
1313
createTime: number;
1414
timezone: string;
15+
status: `${UserStatusEnum}`;
1516
openaiAccount?: {
1617
key: string;
1718
baseUrl: string;

packages/service/common/api/plusRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
7070
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
7171

7272
export function request(url: string, data: any, config: ConfigType, method: Method): any {
73-
if (!global.systemEnv?.pluginBaseUrl) {
73+
if (global.systemEnv && !global.systemEnv?.pluginBaseUrl) {
7474
return Promise.reject('该功能为商业版特有...');
7575
}
7676

packages/service/common/file/image/schema.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const ImageSchema = new Schema({
88
ref: TeamCollectionName,
99
required: true
1010
},
11+
createTime: {
12+
type: Date,
13+
default: () => new Date()
14+
},
1115
binary: {
1216
type: Buffer
1317
},
@@ -25,7 +29,10 @@ try {
2529
console.log(error);
2630
}
2731

28-
export const MongoImage: Model<{ teamId: string; binary: Buffer; metadata?: Record<string, any> }> =
29-
models['image'] || model('image', ImageSchema);
32+
export const MongoImage: Model<{
33+
teamId: string;
34+
binary: Buffer;
35+
metadata?: { fileId?: string };
36+
}> = models['image'] || model('image', ImageSchema);
3037

3138
MongoImage.syncIndexes();

packages/service/common/mongo/controller.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/service/common/mongo/init.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import mongoose from './index';
2-
import { createLogger, format, transports } from 'winston';
3-
import 'winston-mongodb';
42

53
/**
64
* connect MongoDB and init data
@@ -36,7 +34,6 @@ export async function connectMongo({
3634
});
3735

3836
console.log('mongo connected');
39-
initLogger();
4037

4138
afterHook && (await afterHook());
4239
} catch (error) {
@@ -45,35 +42,3 @@ export async function connectMongo({
4542
global.mongodb = undefined;
4643
}
4744
}
48-
49-
function initLogger() {
50-
global.logger = createLogger({
51-
transports: [
52-
new transports.MongoDB({
53-
db: process.env.MONGODB_URI as string,
54-
collection: 'server_logs',
55-
options: {
56-
useUnifiedTopology: true
57-
},
58-
cappedSize: 500000000,
59-
tryReconnect: true,
60-
metaKey: 'meta',
61-
format: format.combine(format.timestamp(), format.json())
62-
}),
63-
new transports.Console({
64-
format: format.combine(
65-
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
66-
format.printf((info) => {
67-
if (info.level === 'error') {
68-
console.log(info.meta);
69-
return `[${info.level.toLocaleUpperCase()}]: ${[info.timestamp]}: ${info.message}`;
70-
}
71-
return `[${info.level.toLocaleUpperCase()}]: ${[info.timestamp]}: ${info.message}${
72-
info.meta ? `: ${JSON.stringify(info.meta)}` : ''
73-
}`;
74-
})
75-
)
76-
})
77-
]
78-
});
79-
}

packages/service/common/mongo/type.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import type { Logger } from 'winston';
33

44
declare global {
55
var mongodb: Mongoose | undefined;
6-
var logger: Logger;
76
}

0 commit comments

Comments
 (0)