feat: add update variable node (#1362)

* feat: add variable update node

* fix

* fix

* change component quote
This commit is contained in:
heheer
2024-05-06 12:20:29 +08:00
committed by GitHub
parent d057ba29f0
commit 59bd2a47b6
25 changed files with 503 additions and 36 deletions

View File

@@ -101,7 +101,10 @@ export enum NodeInputKeyEnum {
// if else
condition = 'condition',
ifElseList = 'ifElseList'
ifElseList = 'ifElseList',
// variable update
updateList = 'updateList'
}
export enum NodeOutputKeyEnum {

View File

@@ -112,7 +112,8 @@ export enum FlowNodeTypeEnum {
tools = 'tools',
stopTool = 'stopTool',
lafModule = 'lafModule',
ifElseNode = 'ifElseNode'
ifElseNode = 'ifElseNode',
variableUpdate = 'variableUpdate'
}
export const EDGE_TYPE = 'default';

View File

@@ -9,7 +9,8 @@ export enum SseResponseEventEnum {
toolCall = 'toolCall', // tool start
toolParams = 'toolParams', // tool params return
toolResponse = 'toolResponse', // tool response return
flowResponses = 'flowResponses' // sse response request
flowResponses = 'flowResponses', // sse response request
variables = 'variables'
}
export enum DispatchNodeResponseKeyEnum {

View File

@@ -18,10 +18,10 @@ import { PluginOutputModule } from './system/pluginOutput';
import { RunPluginModule } from './system/runPlugin';
import { AiQueryExtension } from './system/queryExtension';
import type { FlowNodeTemplateType, nodeTemplateListType } from '../type';
import { FlowNodeTemplateTypeEnum } from '../../workflow/constants';
import type { FlowNodeTemplateType } from '../type';
import { lafModule } from './system/laf';
import { ifElseNode } from './system/ifElse/index';
import { variableUpdateNode } from './system/variableUpdate';
/* app flow module templates */
export const appSystemModuleTemplates: FlowNodeTemplateType[] = [
@@ -39,7 +39,8 @@ export const appSystemModuleTemplates: FlowNodeTemplateType[] = [
HttpModule468,
AiQueryExtension,
lafModule,
ifElseNode
ifElseNode,
variableUpdateNode
];
/* plugin flow module templates */
export const pluginSystemModuleTemplates: FlowNodeTemplateType[] = [
@@ -57,7 +58,8 @@ export const pluginSystemModuleTemplates: FlowNodeTemplateType[] = [
HttpModule468,
AiQueryExtension,
lafModule,
ifElseNode
ifElseNode,
variableUpdateNode
];
/* all module */
@@ -81,5 +83,6 @@ export const moduleTemplatesFlat: FlowNodeTemplateType[] = [
RunPluginModule,
AiQueryExtension,
lafModule,
ifElseNode
ifElseNode,
variableUpdateNode
];

View File

@@ -0,0 +1,35 @@
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
import { FlowNodeTemplateType } from '../../../type/index.d';
import {
FlowNodeTemplateTypeEnum,
NodeInputKeyEnum,
WorkflowIOValueTypeEnum
} from '../../../constants';
import { getHandleConfig } from '../../utils';
export const variableUpdateNode: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.variableUpdate,
templateType: FlowNodeTemplateTypeEnum.tools,
flowNodeType: FlowNodeTypeEnum.variableUpdate,
sourceHandle: getHandleConfig(true, true, true, true),
targetHandle: getHandleConfig(true, true, true, true),
avatar: '/imgs/workflow/variable.png',
name: '变量更新',
intro: '可以更新指定节点的输出值和全局变量',
showStatus: true,
isTool: false,
inputs: [
{
key: NodeInputKeyEnum.updateList,
valueType: WorkflowIOValueTypeEnum.any,
label: '',
renderTypeList: [FlowNodeInputTypeEnum.hidden],
editField: {
key: true,
valueType: true
},
value: []
}
],
outputs: []
};

View File

@@ -0,0 +1,5 @@
export type TUpdateListItem = {
variable?: ReferenceValueProps;
value?: ReferenceValueProps;
renderType?: FlowNodeInputTypeEnum.input | FlowNodeInputTypeEnum.reference;
};