mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
Feat: Workflow loop node;feat: support openai o1;perf: query extension prompt;fix: intro was not delivered when the datase was created (#2719)
* feat: loop node (#2675) * loop node frontend * loop-node * fix-code * fix version * fix * fix * fix * perf: loop array code * perf: get histories error tip * feat: support openai o1 * perf: query extension prompt * feat: 4811 doc * remove log * fix: loop node zindex & variable picker type (#2710) * perf: performance * perf: workflow performance * remove uninvalid code * perf:code * fix: invoice table refresh * perf: loop node data type * fix: loop node store assistants * perf: target connection * feat: loop node support help line * perf: add default icon --------- Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
@@ -344,7 +344,7 @@ export const runtimePrompt2ChatsValue = (
|
||||
return value;
|
||||
};
|
||||
|
||||
export const getSystemPrompt = (prompt?: string): ChatItemType[] => {
|
||||
export const getSystemPrompt_ChatItemType = (prompt?: string): ChatItemType[] => {
|
||||
if (!prompt) return [];
|
||||
return [
|
||||
{
|
||||
|
@@ -24,6 +24,7 @@ export enum WorkflowIOValueTypeEnum {
|
||||
arrayNumber = 'arrayNumber',
|
||||
arrayBoolean = 'arrayBoolean',
|
||||
arrayObject = 'arrayObject',
|
||||
arrayAny = 'arrayAny',
|
||||
any = 'any',
|
||||
|
||||
chatHistory = 'chatHistory',
|
||||
@@ -135,7 +136,17 @@ export enum NodeInputKeyEnum {
|
||||
fileUrlList = 'fileUrlList',
|
||||
|
||||
// user select
|
||||
userSelectOptions = 'userSelectOptions'
|
||||
userSelectOptions = 'userSelectOptions',
|
||||
|
||||
// loop
|
||||
loopInputArray = 'loopInputArray',
|
||||
childrenNodeIdList = 'childrenNodeIdList',
|
||||
nodeWidth = 'nodeWidth',
|
||||
nodeHeight = 'nodeHeight',
|
||||
// loop start
|
||||
loopStartInput = 'loopStartInput',
|
||||
// loop end
|
||||
loopEndInput = 'loopEndInput'
|
||||
}
|
||||
|
||||
export enum NodeOutputKeyEnum {
|
||||
@@ -178,7 +189,13 @@ export enum NodeOutputKeyEnum {
|
||||
ifElseResult = 'ifElseResult',
|
||||
|
||||
//user select
|
||||
selectResult = 'selectResult'
|
||||
selectResult = 'selectResult',
|
||||
|
||||
// loop
|
||||
loopArray = 'loopArray',
|
||||
|
||||
// loop start
|
||||
loopStartInput = 'loopStartInput'
|
||||
}
|
||||
|
||||
export enum VariableInputEnum {
|
||||
|
@@ -125,7 +125,10 @@ export enum FlowNodeTypeEnum {
|
||||
textEditor = 'textEditor',
|
||||
customFeedback = 'customFeedback',
|
||||
readFiles = 'readFiles',
|
||||
userSelect = 'userSelect'
|
||||
userSelect = 'userSelect',
|
||||
loop = 'loop',
|
||||
loopStart = 'loopStart',
|
||||
loopEnd = 'loopEnd'
|
||||
}
|
||||
|
||||
// node IO value type
|
||||
@@ -162,6 +165,10 @@ export const FlowValueTypeMap = {
|
||||
label: 'array<object>',
|
||||
value: WorkflowIOValueTypeEnum.arrayObject
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayAny]: {
|
||||
label: 'array',
|
||||
value: WorkflowIOValueTypeEnum.arrayAny
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.any]: {
|
||||
label: 'any',
|
||||
value: WorkflowIOValueTypeEnum.any
|
||||
|
@@ -172,6 +172,15 @@ export type DispatchNodeResponseType = {
|
||||
|
||||
// update var
|
||||
updateVarResult?: any[];
|
||||
|
||||
// loop
|
||||
loopResult?: any[];
|
||||
loopInput?: any[];
|
||||
loopDetail?: ChatHistoryItemResType[];
|
||||
// loop start
|
||||
loopInputValue?: any;
|
||||
// loop end
|
||||
loopOutputValue?: any;
|
||||
};
|
||||
|
||||
export type DispatchNodeResultType<T = {}> = {
|
||||
|
@@ -29,6 +29,9 @@ import { TextEditorNode } from './system/textEditor';
|
||||
import { CustomFeedbackNode } from './system/customFeedback';
|
||||
import { ReadFilesNodes } from './system/readFiles';
|
||||
import { UserSelectNode } from './system/userSelect/index';
|
||||
import { LoopNode } from './system/loop/loop';
|
||||
import { LoopStartNode } from './system/loop/loopStart';
|
||||
import { LoopEndNode } from './system/loop/loopEnd';
|
||||
|
||||
const systemNodes: FlowNodeTemplateType[] = [
|
||||
AiChatModule,
|
||||
@@ -46,7 +49,8 @@ const systemNodes: FlowNodeTemplateType[] = [
|
||||
LafModule,
|
||||
IfElseNode,
|
||||
VariableUpdateNode,
|
||||
CodeNode
|
||||
CodeNode,
|
||||
LoopNode
|
||||
];
|
||||
/* app flow module templates */
|
||||
export const appSystemModuleTemplates: FlowNodeTemplateType[] = [
|
||||
@@ -74,5 +78,7 @@ export const moduleTemplatesFlat: FlowNodeTemplateType[] = [
|
||||
EmptyNode,
|
||||
RunPluginModule,
|
||||
RunAppNode,
|
||||
RunAppModule
|
||||
RunAppModule,
|
||||
LoopStartNode,
|
||||
LoopEndNode
|
||||
];
|
||||
|
@@ -83,3 +83,25 @@ export const Input_Template_File_Link: FlowNodeInputItemType = {
|
||||
description: i18nT('app:workflow.user_file_input_desc'),
|
||||
valueType: WorkflowIOValueTypeEnum.arrayString
|
||||
};
|
||||
|
||||
export const Input_Template_Children_Node_List: FlowNodeInputItemType = {
|
||||
key: NodeInputKeyEnum.childrenNodeIdList,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
valueType: WorkflowIOValueTypeEnum.arrayString,
|
||||
label: '',
|
||||
value: []
|
||||
};
|
||||
export const Input_Template_Node_Width: FlowNodeInputItemType = {
|
||||
key: NodeInputKeyEnum.nodeWidth,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
valueType: WorkflowIOValueTypeEnum.number,
|
||||
label: '',
|
||||
value: 900
|
||||
};
|
||||
export const Input_Template_Node_Height: FlowNodeInputItemType = {
|
||||
key: NodeInputKeyEnum.nodeHeight,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
valueType: WorkflowIOValueTypeEnum.number,
|
||||
label: '',
|
||||
value: 900
|
||||
};
|
||||
|
54
packages/global/core/workflow/template/system/loop/loop.ts
Normal file
54
packages/global/core/workflow/template/system/loop/loop.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { FlowNodeTemplateType } from '../../../type/node';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
NodeOutputKeyEnum,
|
||||
WorkflowIOValueTypeEnum
|
||||
} from '../../../constants';
|
||||
import { getHandleConfig } from '../../utils';
|
||||
import { i18nT } from '../../../../../../web/i18n/utils';
|
||||
import {
|
||||
Input_Template_Children_Node_List,
|
||||
Input_Template_Node_Height,
|
||||
Input_Template_Node_Width
|
||||
} from '../../input';
|
||||
|
||||
export const LoopNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.loop,
|
||||
templateType: FlowNodeTemplateTypeEnum.tools,
|
||||
flowNodeType: FlowNodeTypeEnum.loop,
|
||||
sourceHandle: getHandleConfig(true, true, true, true),
|
||||
targetHandle: getHandleConfig(true, true, true, true),
|
||||
avatar: 'core/workflow/template/loop',
|
||||
name: i18nT('workflow:loop'),
|
||||
intro: i18nT('workflow:intro_loop'),
|
||||
showStatus: true,
|
||||
version: '4811',
|
||||
inputs: [
|
||||
{
|
||||
key: NodeInputKeyEnum.loopInputArray,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.reference],
|
||||
valueType: WorkflowIOValueTypeEnum.arrayAny,
|
||||
required: true,
|
||||
label: i18nT('workflow:loop_input_array'),
|
||||
value: []
|
||||
},
|
||||
Input_Template_Children_Node_List,
|
||||
Input_Template_Node_Width,
|
||||
Input_Template_Node_Height
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
id: NodeOutputKeyEnum.loopArray,
|
||||
key: NodeOutputKeyEnum.loopArray,
|
||||
label: i18nT('workflow:loop_result'),
|
||||
type: FlowNodeOutputTypeEnum.static,
|
||||
valueType: WorkflowIOValueTypeEnum.arrayAny
|
||||
}
|
||||
]
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
import { i18nT } from '../../../../../../web/i18n/utils';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
WorkflowIOValueTypeEnum
|
||||
} from '../../../constants';
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
|
||||
import { FlowNodeTemplateType } from '../../../type/node';
|
||||
import { getHandleConfig } from '../../utils';
|
||||
|
||||
export const LoopEndNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.loopEnd,
|
||||
templateType: FlowNodeTemplateTypeEnum.systemInput,
|
||||
flowNodeType: FlowNodeTypeEnum.loopEnd,
|
||||
sourceHandle: getHandleConfig(false, false, false, false),
|
||||
targetHandle: getHandleConfig(false, false, false, true),
|
||||
unique: true,
|
||||
forbidDelete: true,
|
||||
avatar: 'core/workflow/template/loopEnd',
|
||||
name: i18nT('workflow:loop_end'),
|
||||
showStatus: false,
|
||||
version: '4811',
|
||||
inputs: [
|
||||
{
|
||||
key: NodeInputKeyEnum.loopEndInput,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.reference],
|
||||
valueType: WorkflowIOValueTypeEnum.any,
|
||||
label: '',
|
||||
required: true,
|
||||
value: []
|
||||
}
|
||||
],
|
||||
outputs: []
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
|
||||
import { FlowNodeTemplateType } from '../../../type/node.d';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
WorkflowIOValueTypeEnum
|
||||
} from '../../../constants';
|
||||
import { getHandleConfig } from '../../utils';
|
||||
import { i18nT } from '../../../../../../web/i18n/utils';
|
||||
|
||||
export const LoopStartNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.loopStart,
|
||||
templateType: FlowNodeTemplateTypeEnum.systemInput,
|
||||
flowNodeType: FlowNodeTypeEnum.loopStart,
|
||||
sourceHandle: getHandleConfig(false, true, false, false),
|
||||
targetHandle: getHandleConfig(false, false, false, false),
|
||||
avatar: 'core/workflow/template/loopStart',
|
||||
name: i18nT('workflow:loop_start'),
|
||||
unique: true,
|
||||
forbidDelete: true,
|
||||
showStatus: false,
|
||||
version: '4811',
|
||||
inputs: [
|
||||
{
|
||||
key: NodeInputKeyEnum.loopStartInput,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
valueType: WorkflowIOValueTypeEnum.any,
|
||||
label: '',
|
||||
required: true,
|
||||
value: ''
|
||||
}
|
||||
],
|
||||
outputs: []
|
||||
};
|
1
packages/global/core/workflow/type/node.d.ts
vendored
1
packages/global/core/workflow/type/node.d.ts
vendored
@@ -95,6 +95,7 @@ export type NodeTemplateListType = {
|
||||
// react flow node type
|
||||
export type FlowNodeItemType = FlowNodeTemplateType & {
|
||||
nodeId: string;
|
||||
parentNodeId?: string;
|
||||
isError?: boolean;
|
||||
debugResult?: {
|
||||
status: 'running' | 'success' | 'skipped' | 'failed';
|
||||
|
Reference in New Issue
Block a user