4.8.11 code perf (#2804)

* perf: support child layout

* perf: user form ui

* perf: plugin tool output code

* perf: code

* perf: node fold hook
This commit is contained in:
Archer
2024-09-26 16:27:28 +08:00
committed by GitHub
parent e6bad93b32
commit 54e0a0eab1
23 changed files with 153 additions and 114 deletions

View File

@@ -9,6 +9,7 @@ import {
UserInputFormItemType,
UserInputInteractive
} from '@fastgpt/global/core/workflow/template/system/interactive/type';
import { addLog } from '../../../../common/system/log';
type Props = ModuleDispatchProps<{
[NodeInputKeyEnum.description]: string;
@@ -48,7 +49,8 @@ export const dispatchFormInput = async (props: Props): Promise<FormInputResponse
try {
return JSON.parse(text);
} catch (error) {
return text;
addLog.warn('formInput error', { error });
return {};
}
})();

View File

@@ -47,15 +47,13 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
const plugin = await getChildAppRuntimeById(pluginId);
const outputFilterMap = plugin.nodes
.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput)!
.inputs.reduce(
(acc, cur) => {
const outputFilterMap =
plugin.nodes
.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput)
?.inputs.reduce<Record<string, boolean>>((acc, cur) => {
acc[cur.key] = cur.isToolOutput === false ? false : true;
return acc;
},
{} as Record<string, boolean>
);
}, {}) ?? {};
const runtimeNodes = storeNodes2RuntimeNodes(
plugin.nodes,
@@ -125,13 +123,12 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
moduleLogo: plugin.avatar,
totalPoints: usagePoints,
pluginOutput: output?.pluginOutput,
pluginDetail:
pluginData && pluginData.permission.hasWritePer // Not system plugin
? flowResponses.filter((item) => {
const filterArr = [FlowNodeTypeEnum.pluginOutput];
return !filterArr.includes(item.moduleType as any);
})
: undefined
pluginDetail: pluginData?.permission?.hasWritePer // Not system plugin
? flowResponses.filter((item) => {
const filterArr = [FlowNodeTypeEnum.pluginOutput];
return !filterArr.includes(item.moduleType as any);
})
: undefined
},
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [
{
@@ -143,14 +140,11 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
[DispatchNodeResponseKeyEnum.toolResponses]: output?.pluginOutput
? Object.keys(output.pluginOutput)
.filter((key) => outputFilterMap[key])
.reduce(
(acc, key) => {
acc[key] = output.pluginOutput![key];
return acc;
},
{} as Record<string, any>
)
: {},
.reduce<Record<string, any>>((acc, key) => {
acc[key] = output.pluginOutput![key];
return acc;
}, {})
: null,
...(output ? output.pluginOutput : {})
};
};