Skip to content

Commit 27566fd

Browse files
committed
fix: system tool config
1 parent 857606b commit 27566fd

File tree

9 files changed

+48
-46
lines changed

9 files changed

+48
-46
lines changed

packages/global/core/app/plugin/utils.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type StoreNodeItemType } from '../../workflow/type/node';
22
import { type FlowNodeInputItemType } from '../../workflow/type/io';
33
import { FlowNodeTypeEnum } from '../../workflow/node/constant';
4+
import { PluginSourceEnum } from './constants';
45

56
export const getPluginInputsFromStoreNodes = (nodes: StoreNodeItemType[]) => {
67
return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || [];
@@ -22,3 +23,34 @@ export const getPluginRunContent = ({
2223
});
2324
return JSON.stringify(pluginInputsWithValue);
2425
};
26+
27+
/**
28+
plugin id rule:
29+
- personal: ObjectId
30+
- commercial: commercial-ObjectId
31+
- systemtool: systemTool-id
32+
(deprecated) community: community-id
33+
*/
34+
export function splitCombinePluginId(id: string) {
35+
const splitRes = id.split('-');
36+
if (splitRes.length === 1) {
37+
// app id
38+
return {
39+
source: PluginSourceEnum.personal,
40+
pluginId: id
41+
};
42+
}
43+
44+
const [source, pluginId] = id.split('-') as [PluginSourceEnum, string | undefined];
45+
if (!source || !pluginId) throw new Error('pluginId not found');
46+
47+
// 兼容4.10.0 之前的插件
48+
if (source === 'community' || id === 'commercial-dalle3') {
49+
return {
50+
source: PluginSourceEnum.systemTool,
51+
pluginId: `${PluginSourceEnum.systemTool}-${pluginId}`
52+
};
53+
}
54+
55+
return { source, pluginId: id };
56+
}

packages/service/core/app/plugin/controller.ts

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,7 @@ import type {
3737
} from '@fastgpt/global/core/workflow/type/io';
3838
import { isProduction } from '@fastgpt/global/common/system/constants';
3939
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
40-
41-
/**
42-
plugin id rule:
43-
- personal: ObjectId
44-
- commercial: commercial-ObjectId
45-
- systemtool: systemTool-id
46-
(deprecated) community: community-id
47-
*/
48-
export function splitCombinePluginId(id: string) {
49-
const splitRes = id.split('-');
50-
if (splitRes.length === 1) {
51-
// app id
52-
return {
53-
source: PluginSourceEnum.personal,
54-
pluginId: id
55-
};
56-
}
57-
58-
const [source, pluginId] = id.split('-') as [PluginSourceEnum, string | undefined];
59-
if (!source || !pluginId) throw new Error('pluginId not found');
60-
61-
// 兼容4.10.0 之前的插件
62-
if (source === 'community' || id === 'commercial-dalle3') {
63-
return {
64-
source: PluginSourceEnum.systemTool,
65-
pluginId: `${PluginSourceEnum.systemTool}-${pluginId}`
66-
};
67-
}
68-
69-
return { source, pluginId: id };
70-
}
40+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
7141

7242
type ChildAppType = SystemPluginTemplateItemType & {
7343
teamId?: string;

packages/service/core/app/plugin/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { type ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
22
import { type PluginRuntimeType } from '@fastgpt/global/core/app/plugin/type';
3-
import { splitCombinePluginId } from './controller';
43
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
4+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
55

6-
/*
6+
/*
77
Plugin points calculation:
88
1. 系统插件/商业版插件:
99
- 有错误:返回 0

packages/service/core/app/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { getEmbeddingModel } from '../ai/model';
33
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
44
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
55
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
6-
import { getChildAppPreviewNode, splitCombinePluginId } from './plugin/controller';
6+
import { getChildAppPreviewNode } from './plugin/controller';
77
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
88
import { authAppByTmbId } from '../../support/permission/app/auth';
99
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
1010
import { getErrText } from '@fastgpt/global/common/error/utils';
11+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
1112

1213
export async function listAppDatasetDataByTeamIdAndDatasetIds({
1314
teamId,

packages/service/core/workflow/dispatch/plugin/run.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { getPluginInputsFromStoreNodes } from '@fastgpt/global/core/app/plugin/utils';
1+
import {
2+
getPluginInputsFromStoreNodes,
3+
splitCombinePluginId
4+
} from '@fastgpt/global/core/app/plugin/utils';
25
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
36
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
47
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
@@ -16,7 +19,7 @@ import { computedPluginUsage } from '../../../app/plugin/utils';
1619
import { filterSystemVariables } from '../utils';
1720
import { getPluginRunUserQuery } from '@fastgpt/global/core/workflow/utils';
1821
import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
19-
import { getChildAppRuntimeById, splitCombinePluginId } from '../../../app/plugin/controller';
22+
import { getChildAppRuntimeById } from '../../../app/plugin/controller';
2023
import { dispatchWorkFlow } from '../index';
2124
import { getUserChatInfoAndAuthTeamPoints } from '../../../../support/permission/auth/team';
2225
import { dispatchRunTool } from './runTool';

packages/service/core/workflow/dispatch/plugin/runTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { APIRunTool } from '../../../app/tool/api';
1313
import { MongoSystemPlugin } from '../../../app/plugin/systemPluginSchema';
1414
import { SystemToolInputTypeEnum } from '@fastgpt/global/core/app/systemTool/constants';
1515
import type { StoreSecretValueType } from '@fastgpt/global/common/secret/type';
16-
import { getSystemToolById, splitCombinePluginId } from '../../../app/plugin/controller';
16+
import { getSystemToolById } from '../../../app/plugin/controller';
1717

1818
type SystemInputConfigType = {
1919
type: SystemToolInputTypeEnum;

packages/service/support/permission/app/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { AppPermission } from '@fastgpt/global/support/permission/app/controller
1010
import { type PermissionValueType } from '@fastgpt/global/support/permission/type';
1111
import { AppFolderTypeList } from '@fastgpt/global/core/app/constants';
1212
import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type';
13-
import { splitCombinePluginId } from '../../../core/app/plugin/controller';
1413
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
1514
import { type AuthModeType, type AuthResponseType } from '../type';
1615
import { AppDefaultPermissionVal } from '@fastgpt/global/support/permission/app/constant';
16+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
1717

1818
export const authPluginByTmbId = async ({
1919
tmbId,

projects/app/src/pages/api/core/app/plugin/getPreviewNode.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
*/
44
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
55
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
6-
import {
7-
getChildAppPreviewNode,
8-
splitCombinePluginId
9-
} from '@fastgpt/service/core/app/plugin/controller';
6+
import { getChildAppPreviewNode } from '@fastgpt/service/core/app/plugin/controller';
107
import { type FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node.d';
118
import { NextAPI } from '@/service/middleware/entry';
129
import { type ApiRequestProps } from '@fastgpt/service/type/next';
1310
import { authApp } from '@fastgpt/service/support/permission/app/auth';
1411
import type { NextApiResponse } from 'next';
1512
import { getLocale } from '@fastgpt/service/common/middle/i18n';
13+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
1614

1715
export type GetPreviewNodeQuery = { appId: string; versionId?: string };
1816

projects/app/src/pages/api/core/app/plugin/getVersionList.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
66
import { authApp } from '@fastgpt/service/support/permission/app/auth';
77
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
88
import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination';
9-
import {
10-
getSystemPluginByIdAndVersionId,
11-
splitCombinePluginId
12-
} from '@fastgpt/service/core/app/plugin/controller';
9+
import { getSystemPluginByIdAndVersionId } from '@fastgpt/service/core/app/plugin/controller';
1310
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
1411
import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin';
1512
import { Types } from '@fastgpt/service/common/mongo';
13+
import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils';
1614

1715
export type getToolVersionListProps = PaginationProps<{
1816
pluginId?: string;

0 commit comments

Comments
 (0)