Skip to content

Commit

Permalink
4.8.4 (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Jun 12, 2024
1 parent bc6864c commit d0085a2
Show file tree
Hide file tree
Showing 61 changed files with 558 additions and 348 deletions.
4 changes: 2 additions & 2 deletions docSite/content/zh-cn/docs/development/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ weight: 708

**开发环境下**,你需要将示例配置文件 `config.json` 复制成 `config.local.json` 文件才会生效。

这个配置文件中包含了系统参数和各个模型配置`使用时务必去掉注释!!!!!!!!!!!!!!`
这个配置文件中包含了系统参数和各个模型配置

## 4.6.8+ 版本新配置文件

Expand Down Expand Up @@ -158,7 +158,7 @@ llm模型全部合并

1. [部署 ReRank 模型](/docs/development/custom-models/bge-rerank/)
1. 找到 FastGPT 的配置文件中的 `reRankModels`, 4.6.6 以前是 `ReRankModels`
2. 修改对应的值:(记得去掉注释)
2. 修改对应的值:

```json
{
Expand Down
18 changes: 15 additions & 3 deletions docSite/content/zh-cn/docs/development/upgrading/484.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ description: 'FastGPT V4.8.4 更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 821
weight: 820
---

<!-- ## 升级指南
## 升级指南

### 1. 修改镜像

- fastgpt 镜像 tag 修改成 v4.8.4
- fastgpt-sandbox 镜像 tag 修改成 v4.8.4 (选择性,无变更)
- 商业版镜像 tag 修改成 v4.8.4 -->
- 商业版镜像 tag 修改成 v4.8.4

### 2. 商业版用户执行初始化

从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 商业版的域名**

```bash
curl --location --request POST 'https://{{host}}/api/admin/init/484' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```

## V4.8.4 更新说明

Expand Down
2 changes: 2 additions & 0 deletions files/docker/docker-compose-milvus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ services:
- MILVUS_TOKEN=none
# sandbox 地址
- SANDBOX_URL=http://sandbox:3000
# 日志等级: debug, info, warn, error
- LOG_LEVEL=info
volumes:
- ./config.json:/app/data/config.json

Expand Down
2 changes: 2 additions & 0 deletions files/docker/docker-compose-pgvector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ services:
- PG_URL=postgresql://username:password@pg:5432/postgres
# sandbox 地址
- SANDBOX_URL=http://sandbox:3000
# 日志等级: debug, info, warn, error
- LOG_LEVEL=info
volumes:
- ./config.json:/app/data/config.json

Expand Down
2 changes: 2 additions & 0 deletions files/docker/docker-compose-zilliz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ services:
- MILVUS_TOKEN=zilliz_cloud_token
# sandbox 地址
- SANDBOX_URL=http://sandbox:3000
# 日志等级: debug, info, warn, error
- LOG_LEVEL=info
volumes:
- ./config.json:/app/data/config.json

Expand Down
5 changes: 2 additions & 3 deletions packages/global/core/app/collaborator.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { UpdateClbPermissionProps } from '../../support/permission/collaborator';
import { PermissionValueType } from '../../support/permission/type';

export type UpdateAppCollaboratorBody = {
export type UpdateAppCollaboratorBody = UpdateClbPermissionProps & {
appId: string;
tmbIds: string[];
permission: PermissionValueType;
};

export type AppCollaboratorDeleteParams = {
Expand Down
3 changes: 2 additions & 1 deletion packages/global/core/workflow/type/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { RuntimeNodeItemType } from '../runtime/type';
import { PluginTypeEnum } from '../../plugin/constants';
import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge';
import { NextApiResponse } from 'next';
import { AppDetailType, AppSchema } from '../../app/type';

export type FlowNodeCommonType = {
flowNodeType: FlowNodeTypeEnum; // render node card
Expand Down Expand Up @@ -131,7 +132,7 @@ export type ChatDispatchProps = {
teamId: string;
tmbId: string;
user: UserModelSchema;
appId?: string;
app: AppDetailType | AppSchema;
chatId?: string;
responseChatItemId?: string;
histories: ChatItemType[];
Expand Down
5 changes: 5 additions & 0 deletions packages/global/support/permission/collaborator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ export type CollaboratorItemType = {
name: string;
avatar: string;
};

export type UpdateClbPermissionProps = {
tmbIds: string[];
permission: PermissionValueType;
};
17 changes: 16 additions & 1 deletion packages/global/support/permission/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export enum AuthUserTypeEnum {

export enum PermissionTypeEnum {
'private' = 'private',
'public' = 'public'
'public' = 'public',
clbPrivate = 'clbPrivate',
publicRead = 'publicRead',
publicWrite = 'publicWrite'
}
export const PermissionTypeMap = {
[PermissionTypeEnum.private]: {
Expand All @@ -21,6 +24,18 @@ export const PermissionTypeMap = {
[PermissionTypeEnum.public]: {
iconLight: 'support/permission/publicLight',
label: 'permission.Public'
},
[PermissionTypeEnum.publicRead]: {
iconLight: 'support/permission/publicLight',
label: '团队可访问'
},
[PermissionTypeEnum.publicWrite]: {
iconLight: 'support/permission/publicLight',
label: '团队可编辑'
},
[PermissionTypeEnum.clbPrivate]: {
iconLight: 'support/permission/privateLight',
label: '仅协作者'
}
};

Expand Down
9 changes: 6 additions & 3 deletions packages/global/support/permission/user/constant.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { PermissionKeyEnum, PermissionList, ReadPermissionVal } from '../constant';
import { PermissionListType } from '../type';

export const TeamPermissionList = {
export const TeamPermissionList: PermissionListType = {
[PermissionKeyEnum.read]: {
...PermissionList[PermissionKeyEnum.read]
...PermissionList[PermissionKeyEnum.read],
description: '成员仅可阅读相关资源,无法新建资源'
},
[PermissionKeyEnum.write]: {
...PermissionList[PermissionKeyEnum.write]
...PermissionList[PermissionKeyEnum.write],
description: '除了可读资源外,还可以新建新的资源'
},
[PermissionKeyEnum.manage]: {
...PermissionList[PermissionKeyEnum.manage],
Expand Down
9 changes: 2 additions & 7 deletions packages/global/support/user/team/controller.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type UpdateTeamProps = {

/* ------------- member ----------- */
export type DelMemberProps = {
memberId: string;
tmbId: string;
};
export type UpdateTeamMemberProps = {
teamId: string;
Expand All @@ -33,7 +33,7 @@ export type UpdateTeamMemberProps = {
export type InviteMemberProps = {
teamId: string;
usernames: string[];
role: `${TeamMemberRoleEnum}`;
permission: PermissionValueType;
};
export type UpdateInviteProps = {
tmbId: string;
Expand All @@ -43,8 +43,3 @@ export type InviteMemberResponse = Record<
'invite' | 'inValid' | 'inTeam',
{ username: string; userId: string }[]
>;

export type UpdateTeamMemberPermissionProps = {
memberIds: string[];
permission: PermissionValueType;
};
2 changes: 1 addition & 1 deletion packages/service/common/string/tiktoken/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const countGptMessagesTokens = (

callbackMap[id] = (data) => {
// 检测是否有内存泄漏
addLog.info(`Count token time: ${Date.now() - start}, token: ${data}`);
addLog.debug(`Count token time: ${Date.now() - start}, token: ${data}`);
// console.log(process.memoryUsage());

resolve(data);
Expand Down
28 changes: 22 additions & 6 deletions packages/service/common/system/log.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import dayjs from 'dayjs';
import chalk from 'chalk';
import { isProduction } from './constants';

enum LogLevelEnum {
debug = 'debug',
info = 'info',
warn = 'warn',
error = 'error'
debug = 0,
info = 1,
warn = 2,
error = 3
}
const logMap = {
[LogLevelEnum.debug]: {
Expand All @@ -21,20 +22,35 @@ const logMap = {
levelLog: chalk.red('[Error]')
}
};
const envLogLevelMap: Record<string, number> = {
debug: 0,
info: 1,
warn: 2,
error: 3
};

const logLevel = (() => {
if (!isProduction) return LogLevelEnum.debug;
const envLogLevel = (process.env.LOG_LEVEL || 'info').toLocaleLowerCase();
if (!envLogLevel || envLogLevelMap[envLogLevel] === undefined) return LogLevelEnum.info;
return envLogLevelMap[envLogLevel];
})();

/* add logger */
export const addLog = {
log(level: LogLevelEnum, msg: string, obj: Record<string, any> = {}) {
if (level < logLevel) return;

const stringifyObj = JSON.stringify(obj);
const isEmpty = Object.keys(obj).length === 0;

console.log(
`${logMap[level].levelLog} ${dayjs().format('YYYY-MM-DD HH:mm:ss')} ${msg} ${
level !== 'error' && !isEmpty ? stringifyObj : ''
level !== LogLevelEnum.error && !isEmpty ? stringifyObj : ''
}`
);

level === 'error' && console.error(obj);
level === LogLevelEnum.error && console.error(obj);

const lokiUrl = process.env.LOKI_LOG_URL as string;
if (!lokiUrl) return;
Expand Down
17 changes: 10 additions & 7 deletions packages/service/core/dataset/collection/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ export const delCollectionRelatedSource = async ({
.map((item) => item?.metadata?.relatedImgId || '')
.filter(Boolean);

// delete files
await delFileByFileIdList({
bucketName: BucketNameEnum.dataset,
fileIdList
});
// delete images
await delImgByRelatedId({
teamId,
relateIds: relatedImageIds,
session
});
// delete files
await delFileByFileIdList({
bucketName: BucketNameEnum.dataset,
fileIdList
});
};
/**
* delete collection and it related data
Expand Down Expand Up @@ -182,14 +182,16 @@ export async function delCollectionAndRelatedSources({
);
const collectionIds = collections.map((item) => String(item._id));

await delCollectionRelatedSource({ collections, session });

// delete training data
await MongoDatasetTraining.deleteMany({
teamId,
datasetIds: { $in: datasetIds },
collectionId: { $in: collectionIds }
});

/* file and imgs */
await delCollectionRelatedSource({ collections, session });

// delete dataset.datas
await MongoDatasetData.deleteMany(
{ teamId, datasetIds: { $in: datasetIds }, collectionId: { $in: collectionIds } },
Expand All @@ -199,6 +201,7 @@ export async function delCollectionAndRelatedSources({
// delete collections
await MongoDatasetCollection.deleteMany(
{
teamId,
_id: { $in: collectionIds }
},
{ session }
Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/dataset/collection/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function findCollectionAndChild({
return collections;
}
const [collection, childCollections] = await Promise.all([
MongoDatasetCollection.findById(collectionId, fields),
MongoDatasetCollection.findById(collectionId, fields).lean(),
find(collectionId)
]);

Expand Down
9 changes: 5 additions & 4 deletions packages/service/core/dataset/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ export async function delDatasetRelevantData({
teamId,
datasetId: { $in: datasetIds }
},
'_id teamId fileId metadata'
'_id teamId datasetId fileId metadata'
).lean();

// image and file
await delCollectionRelatedSource({ collections, session });

// delete training data
await MongoDatasetTraining.deleteMany({
teamId,
datasetId: { $in: datasetIds }
});

// image and file
await delCollectionRelatedSource({ collections, session });

// delete dataset.datas
await MongoDatasetData.deleteMany({ teamId, datasetId: { $in: datasetIds } }, { session });

Expand Down
4 changes: 2 additions & 2 deletions packages/service/core/workflow/dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,13 @@ export function responseStatus({
/* get system variable */
export function getSystemVariable({
user,
appId,
app,
chatId,
responseChatItemId,
histories = []
}: Props) {
return {
appId,
appId: String(app._id),
chatId,
responseChatItemId,
histories,
Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/workflow/dispatch/tools/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
let {
res,
detail,
appId,
app: { _id: appId },
chatId,
stream,
responseChatItemId,
Expand Down
10 changes: 5 additions & 5 deletions packages/service/core/workflow/dispatch/tools/runApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type Response = DispatchNodeResultType<{
export const dispatchAppRequest = async (props: Props): Promise<Response> => {
const {
res,
teamId,
tmbId,
app: workflowApp,
stream,
detail,
histories,
Expand All @@ -46,10 +45,11 @@ export const dispatchAppRequest = async (props: Props): Promise<Response> => {
return Promise.reject('Input is empty');
}

// 检查该工作流的tmb是否有调用该app的权限(不是校验对话的人,是否有权限)
const { app: appData } = await authAppByTmbId({
appId: app.id,
teamId,
tmbId,
teamId: workflowApp.teamId,
tmbId: workflowApp.tmbId,
per: ReadPermissionVal
});

Expand All @@ -68,7 +68,7 @@ export const dispatchAppRequest = async (props: Props): Promise<Response> => {

const { flowResponses, flowUsages, assistantResponses } = await dispatchWorkFlow({
...props,
appId: app.id,
app: appData,
runtimeNodes: storeNodes2RuntimeNodes(appData.modules, getDefaultEntryNodeIds(appData.modules)),
runtimeEdges: initWorkflowEdgeStatus(appData.edges),
histories: chatHistories,
Expand Down
Loading

0 comments on commit d0085a2

Please sign in to comment.