diff --git a/packages/global/core/app/utils.ts b/packages/global/core/app/utils.ts index 679282528..44a00a4bc 100644 --- a/packages/global/core/app/utils.ts +++ b/packages/global/core/app/utils.ts @@ -131,6 +131,7 @@ export const appWorkflow2Form = ({ nodes }: { nodes: StoreNodeItemType[] }) => { intro: node.intro || '', flowNodeType: node.flowNodeType, showStatus: node.showStatus, + version: '481', inputs: node.inputs, outputs: node.outputs, templateType: FlowNodeTemplateTypeEnum.other diff --git a/packages/global/core/plugin/httpPlugin/utils.ts b/packages/global/core/plugin/httpPlugin/utils.ts index 5eb9ea05a..c2121ea3e 100644 --- a/packages/global/core/plugin/httpPlugin/utils.ts +++ b/packages/global/core/plugin/httpPlugin/utils.ts @@ -282,6 +282,7 @@ export const httpApiSchema2Plugins = async ({ x: 616.4226348688949, y: -165.05298493910115 }, + version: PluginInputModule.version, inputs: pluginInputs, outputs: pluginOutputs }, @@ -296,6 +297,7 @@ export const httpApiSchema2Plugins = async ({ x: 1607.7142331269126, y: -151.8669210746189 }, + version: PluginOutputModule.version, inputs: [ { key: pluginOutputKey, @@ -334,6 +336,7 @@ export const httpApiSchema2Plugins = async ({ x: 1042.549746602742, y: -447.77496332641647 }, + version: HttpModule468.version, inputs: [ { key: NodeInputKeyEnum.addInputParam, diff --git a/packages/global/core/workflow/template/system/aiChat.ts b/packages/global/core/workflow/template/system/aiChat.ts index f00c97b90..8f3feeeba 100644 --- a/packages/global/core/workflow/template/system/aiChat.ts +++ b/packages/global/core/workflow/template/system/aiChat.ts @@ -31,6 +31,7 @@ export const AiChatModule: FlowNodeTemplateType = { intro: 'AI 大模型对话', showStatus: true, isTool: true, + version: '481', inputs: [ Input_Template_SettingAiModel, // --- settings modal diff --git a/packages/global/core/workflow/template/system/assignedAnswer.ts b/packages/global/core/workflow/template/system/assignedAnswer.ts index 5ccb38ab3..6f133b557 100644 --- a/packages/global/core/workflow/template/system/assignedAnswer.ts +++ b/packages/global/core/workflow/template/system/assignedAnswer.ts @@ -17,6 +17,7 @@ export const AssignedAnswerModule: FlowNodeTemplateType = { name: '指定回复', intro: '该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。', + version: '481', inputs: [ { key: NodeInputKeyEnum.answerText, diff --git a/packages/global/core/workflow/template/system/classifyQuestion.ts b/packages/global/core/workflow/template/system/classifyQuestion.ts index c2afe4a46..f8325d733 100644 --- a/packages/global/core/workflow/template/system/classifyQuestion.ts +++ b/packages/global/core/workflow/template/system/classifyQuestion.ts @@ -29,6 +29,7 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = { name: '问题分类', intro: `根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:\n类型1: 打招呼\n类型2: 关于商品“使用”问题\n类型3: 关于商品“购买”问题\n类型4: 其他问题`, showStatus: true, + version: '481', inputs: [ { ...Input_Template_SelectAIModel, diff --git a/packages/global/core/workflow/template/system/contextExtract.ts b/packages/global/core/workflow/template/system/contextExtract.ts index c34697ba7..d34608b18 100644 --- a/packages/global/core/workflow/template/system/contextExtract.ts +++ b/packages/global/core/workflow/template/system/contextExtract.ts @@ -25,6 +25,7 @@ export const ContextExtractModule: FlowNodeTemplateType = { intro: '可从文本中提取指定的数据,例如:sql语句、搜索关键词、代码等', showStatus: true, isTool: true, + version: '481', inputs: [ { ...Input_Template_SelectAIModel, diff --git a/packages/global/core/workflow/template/system/datasetConcat.ts b/packages/global/core/workflow/template/system/datasetConcat.ts index 60b4d1779..ee2576e6f 100644 --- a/packages/global/core/workflow/template/system/datasetConcat.ts +++ b/packages/global/core/workflow/template/system/datasetConcat.ts @@ -42,6 +42,7 @@ export const DatasetConcatModule: FlowNodeTemplateType = { name: '知识库搜索引用合并', intro: '可以将多个知识库搜索结果进行合并输出。使用 RRF 的合并方式进行最终排序输出。', showStatus: false, + version: '481', inputs: [ { key: NodeInputKeyEnum.datasetMaxTokens, diff --git a/packages/global/core/workflow/template/system/datasetSearch.ts b/packages/global/core/workflow/template/system/datasetSearch.ts index 2808ca6f9..b8cf918e2 100644 --- a/packages/global/core/workflow/template/system/datasetSearch.ts +++ b/packages/global/core/workflow/template/system/datasetSearch.ts @@ -28,6 +28,7 @@ export const DatasetSearchModule: FlowNodeTemplateType = { intro: Dataset_SEARCH_DESC, showStatus: true, isTool: true, + version: '481', inputs: [ { key: NodeInputKeyEnum.datasetSelectList, diff --git a/packages/global/core/workflow/template/system/emptyNode.ts b/packages/global/core/workflow/template/system/emptyNode.ts index c26d1b1d2..0b58eb305 100644 --- a/packages/global/core/workflow/template/system/emptyNode.ts +++ b/packages/global/core/workflow/template/system/emptyNode.ts @@ -12,6 +12,7 @@ export const EmptyNode: FlowNodeTemplateType = { avatar: '', name: '', intro: '', + version: '481', inputs: [], outputs: [] }; diff --git a/packages/global/core/workflow/template/system/globalVariable.ts b/packages/global/core/workflow/template/system/globalVariable.ts index 27f7de779..590534877 100644 --- a/packages/global/core/workflow/template/system/globalVariable.ts +++ b/packages/global/core/workflow/template/system/globalVariable.ts @@ -20,6 +20,7 @@ export const getGlobalVariableNode = ({ avatar: '/imgs/workflow/variable.png', name: '全局变量', intro: '', + version: '481', inputs: [], outputs: variables.map((item) => ({ id: item.key, diff --git a/packages/global/core/workflow/template/system/http468.ts b/packages/global/core/workflow/template/system/http468.ts index 515c15da2..26d49701b 100644 --- a/packages/global/core/workflow/template/system/http468.ts +++ b/packages/global/core/workflow/template/system/http468.ts @@ -25,6 +25,7 @@ export const HttpModule468: FlowNodeTemplateType = { intro: '可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)', showStatus: true, isTool: true, + version: '481', inputs: [ { ...Input_Template_DynamicInput, diff --git a/packages/global/core/workflow/template/system/ifElse/index.ts b/packages/global/core/workflow/template/system/ifElse/index.ts index 0a244d662..314e925b4 100644 --- a/packages/global/core/workflow/template/system/ifElse/index.ts +++ b/packages/global/core/workflow/template/system/ifElse/index.ts @@ -22,6 +22,7 @@ export const IfElseNode: FlowNodeTemplateType = { name: '判断器', intro: '根据一定的条件,执行不同的分支。', showStatus: true, + version: '481', inputs: [ { key: NodeInputKeyEnum.ifElseList, diff --git a/packages/global/core/workflow/template/system/laf.ts b/packages/global/core/workflow/template/system/laf.ts index 2140432bb..154533ef7 100644 --- a/packages/global/core/workflow/template/system/laf.ts +++ b/packages/global/core/workflow/template/system/laf.ts @@ -25,6 +25,7 @@ export const LafModule: FlowNodeTemplateType = { intro: '可以调用Laf账号下的云函数。', showStatus: true, isTool: true, + version: '481', inputs: [ { ...Input_Template_DynamicInput, diff --git a/packages/global/core/workflow/template/system/pluginInput.ts b/packages/global/core/workflow/template/system/pluginInput.ts index 8e0d83f6b..ab3b42ad0 100644 --- a/packages/global/core/workflow/template/system/pluginInput.ts +++ b/packages/global/core/workflow/template/system/pluginInput.ts @@ -15,6 +15,7 @@ export const PluginInputModule: FlowNodeTemplateType = { name: '自定义插件输入', intro: '自定义配置外部输入,使用插件时,仅暴露自定义配置的输入', showStatus: false, + version: '481', inputs: [], outputs: [] }; diff --git a/packages/global/core/workflow/template/system/pluginOutput.ts b/packages/global/core/workflow/template/system/pluginOutput.ts index 9b709a3b0..2521e582d 100644 --- a/packages/global/core/workflow/template/system/pluginOutput.ts +++ b/packages/global/core/workflow/template/system/pluginOutput.ts @@ -15,6 +15,7 @@ export const PluginOutputModule: FlowNodeTemplateType = { name: '自定义插件输出', intro: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出', showStatus: false, + version: '481', inputs: [], outputs: [] }; diff --git a/packages/global/core/workflow/template/system/queryExtension.ts b/packages/global/core/workflow/template/system/queryExtension.ts index 6ee6689da..fa23d5a22 100644 --- a/packages/global/core/workflow/template/system/queryExtension.ts +++ b/packages/global/core/workflow/template/system/queryExtension.ts @@ -29,6 +29,7 @@ export const AiQueryExtension: FlowNodeTemplateType = { intro: '使用问题优化功能,可以提高知识库连续对话时搜索的精度。使用该功能后,会先利用 AI 根据上下文构建一个或多个新的检索词,这些检索词更利于进行知识库搜索。该模块已内置在知识库搜索模块中,如果您仅进行一次知识库搜索,可直接使用知识库内置的补全功能。', showStatus: true, + version: '481', inputs: [ { ...Input_Template_SelectAIModel, diff --git a/packages/global/core/workflow/template/system/runApp.ts b/packages/global/core/workflow/template/system/runApp.ts index 504ca3f0e..0d39310a3 100644 --- a/packages/global/core/workflow/template/system/runApp.ts +++ b/packages/global/core/workflow/template/system/runApp.ts @@ -23,6 +23,7 @@ export const RunAppModule: FlowNodeTemplateType = { name: '应用调用', intro: '可以选择一个其他应用进行调用', showStatus: true, + version: '481', inputs: [ { key: NodeInputKeyEnum.runAppSelectApp, diff --git a/packages/global/core/workflow/template/system/runPlugin.ts b/packages/global/core/workflow/template/system/runPlugin.ts index 419d6e061..43b904571 100644 --- a/packages/global/core/workflow/template/system/runPlugin.ts +++ b/packages/global/core/workflow/template/system/runPlugin.ts @@ -13,6 +13,7 @@ export const RunPluginModule: FlowNodeTemplateType = { name: '', showStatus: false, isTool: true, + version: '481', inputs: [], // [{key:'pluginId'},...] outputs: [] }; diff --git a/packages/global/core/workflow/template/system/stopTool.ts b/packages/global/core/workflow/template/system/stopTool.ts index 713c653fc..6881bd53b 100644 --- a/packages/global/core/workflow/template/system/stopTool.ts +++ b/packages/global/core/workflow/template/system/stopTool.ts @@ -13,6 +13,7 @@ export const StopToolNode: FlowNodeTemplateType = { name: '工具调用终止', intro: '该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。', + version: '481', inputs: [], outputs: [] }; diff --git a/packages/global/core/workflow/template/system/systemConfig.ts b/packages/global/core/workflow/template/system/systemConfig.ts index 69a8044bf..cb7aa5d11 100644 --- a/packages/global/core/workflow/template/system/systemConfig.ts +++ b/packages/global/core/workflow/template/system/systemConfig.ts @@ -18,6 +18,7 @@ export const SystemConfigNode: FlowNodeTemplateType = { intro: '可以配置应用的系统参数。', unique: true, forbidDelete: true, + version: '481', inputs: [ { key: NodeInputKeyEnum.welcomeText, diff --git a/packages/global/core/workflow/template/system/tools.ts b/packages/global/core/workflow/template/system/tools.ts index 8c0050df3..4c9e15b50 100644 --- a/packages/global/core/workflow/template/system/tools.ts +++ b/packages/global/core/workflow/template/system/tools.ts @@ -30,6 +30,7 @@ export const ToolModule: FlowNodeTemplateType = { name: '工具调用(实验)', intro: '通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。', showStatus: true, + version: '481', inputs: [ { ...Input_Template_SettingAiModel, diff --git a/packages/global/core/workflow/template/system/variableUpdate/index.tsx b/packages/global/core/workflow/template/system/variableUpdate/index.tsx index 6867d98bb..56771cd09 100644 --- a/packages/global/core/workflow/template/system/variableUpdate/index.tsx +++ b/packages/global/core/workflow/template/system/variableUpdate/index.tsx @@ -18,6 +18,7 @@ export const VariableUpdateNode: FlowNodeTemplateType = { intro: '可以更新指定节点的输出值或更新全局变量', showStatus: true, isTool: false, + version: '481', inputs: [ { key: NodeInputKeyEnum.updateList, diff --git a/packages/global/core/workflow/template/system/workflowStart.ts b/packages/global/core/workflow/template/system/workflowStart.ts index f43b7839c..ceb654b49 100644 --- a/packages/global/core/workflow/template/system/workflowStart.ts +++ b/packages/global/core/workflow/template/system/workflowStart.ts @@ -19,6 +19,7 @@ export const WorkflowStart: FlowNodeTemplateType = { intro: '', forbidDelete: true, unique: true, + version: '481', inputs: [{ ...Input_Template_UserChatInput, toolDescription: '用户问题' }], outputs: [ { diff --git a/packages/global/core/workflow/type/index.d.ts b/packages/global/core/workflow/type/index.d.ts index 549145465..f24fd07eb 100644 --- a/packages/global/core/workflow/type/index.d.ts +++ b/packages/global/core/workflow/type/index.d.ts @@ -28,6 +28,7 @@ export type FlowNodeCommonType = { name: string; intro?: string; // template list intro showStatus?: boolean; // chatting response step status + version: string; // data inputs: FlowNodeInputItemType[]; diff --git a/packages/service/core/plugin/controller.ts b/packages/service/core/plugin/controller.ts index 535d8eaef..a2718cd35 100644 --- a/packages/service/core/plugin/controller.ts +++ b/packages/service/core/plugin/controller.ts @@ -72,6 +72,7 @@ export async function getPluginPreviewNode({ id }: { id: string }): Promise { const setHoverNodeId = useContextSelector(WorkflowContext, (v) => v.setHoverNodeId); const onUpdateNodeError = useContextSelector(WorkflowContext, (v) => v.onUpdateNodeError); const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode); + const onResetNode = useContextSelector(WorkflowContext, (v) => v.onResetNode); // custom title edit const { onOpenModal: onOpenCustomTitleModal, EditModal: EditTitleModal } = useEditTitle({ @@ -77,12 +81,21 @@ const NodeCard = (props: Props) => { [isTool, nodeList] ); + const node = nodeList.find((node) => node.nodeId === nodeId); + const template = moduleTemplatesFlat.find((item) => item.flowNodeType === node?.flowNodeType); + const hasNewVersion = useMemo(() => { + return ( + template?.flowNodeType !== FlowNodeTypeEnum.pluginModule && + node?.version !== template?.version + ); + }, [node?.version, template?.flowNodeType, template?.version]); + /* Node header */ const Header = useMemo(() => { return ( {/* debug */} - + {/* tool target handle */} {showToolHandle && } @@ -123,6 +136,33 @@ const NodeCard = (props: Props) => { }} /> )} + + {hasNewVersion && ( + + + + )} { t, name, menuForbid, + hasNewVersion, pluginId, flowNodeType, intro, onOpenCustomTitleModal, onChangeNode, toast, - appT + appT, + node, + template, + onResetNode ]); return ( @@ -236,7 +280,8 @@ const MenuRender = React.memo(function MenuRender({ inputs: node.data.inputs, outputs: node.data.outputs, showStatus: node.data.showStatus, - pluginId: node.data.pluginId + pluginId: node.data.pluginId, + version: node.data.version }; return state.concat( storeNode2FlowNode({ @@ -250,7 +295,8 @@ const MenuRender = React.memo(function MenuRender({ showStatus: template.showStatus, pluginId: template.pluginId, inputs: template.inputs, - outputs: template.outputs + outputs: template.outputs, + version: template.version } }) ); @@ -265,7 +311,7 @@ const MenuRender = React.memo(function MenuRender({ }, [setEdges, setNodes] ); - const onclickSyncVersion = useCallback(async () => { + const onClickSyncVersion = useCallback(async () => { if (!pluginId) return; try { setLoading(true); @@ -310,7 +356,7 @@ const MenuRender = React.memo(function MenuRender({ icon: 'common/refreshLight', label: t('plugin.Synchronous version'), variant: 'whiteBase', - onClick: onOpenConfirmSync(onclickSyncVersion) + onClick: onOpenConfirmSync(onClickSyncVersion) } ] : []), @@ -362,21 +408,21 @@ const MenuRender = React.memo(function MenuRender({ ); }, [ - ConfirmDeleteModal, - ConfirmSyncModal, - DebugInputModal, - flowNodeType, - menuForbid?.copy, menuForbid?.debug, + menuForbid?.copy, menuForbid?.delete, + t, + flowNodeType, + onOpenConfirmSync, + onClickSyncVersion, + onOpenConfirmDeleteNode, + ConfirmSyncModal, + ConfirmDeleteModal, + DebugInputModal, + openDebugNode, nodeId, onCopyNode, - onDelNode, - onOpenConfirmDeleteNode, - onOpenConfirmSync, - onclickSyncVersion, - openDebugNode, - t + onDelNode ]); return Render; diff --git a/projects/app/src/components/core/workflow/utils.ts b/projects/app/src/components/core/workflow/utils.ts index 298b41871..232ec5beb 100644 --- a/projects/app/src/components/core/workflow/utils.ts +++ b/projects/app/src/components/core/workflow/utils.ts @@ -19,6 +19,7 @@ export const flowNode2StoreNodes = ({ flowNodeType: item.data.flowNodeType, showStatus: item.data.showStatus, position: item.position, + version: item.data.version, inputs: item.data.inputs, outputs: item.data.outputs, pluginId: item.data.pluginId diff --git a/projects/app/src/pages/api/core/plugin/pluginTemplate/getSystemPluginTemplates.ts b/projects/app/src/pages/api/core/plugin/pluginTemplate/getSystemPluginTemplates.ts index ef3a64c69..9f56f59fa 100644 --- a/projects/app/src/pages/api/core/plugin/pluginTemplate/getSystemPluginTemplates.ts +++ b/projects/app/src/pages/api/core/plugin/pluginTemplate/getSystemPluginTemplates.ts @@ -22,6 +22,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< intro: plugin.intro, showStatus: true, isTool: plugin.isTool, + version: '481', inputs: [], outputs: [] })) || []; diff --git a/projects/app/src/pages/api/core/plugin/pluginTemplate/getTeamPluginTemplates.ts b/projects/app/src/pages/api/core/plugin/pluginTemplate/getTeamPluginTemplates.ts index c153e1dd1..319d5c936 100644 --- a/projects/app/src/pages/api/core/plugin/pluginTemplate/getTeamPluginTemplates.ts +++ b/projects/app/src/pages/api/core/plugin/pluginTemplate/getTeamPluginTemplates.ts @@ -47,6 +47,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< name: plugin.name, intro: plugin.intro, showStatus: false, + version: '481', inputs: [], outputs: [] })); diff --git a/projects/app/src/pages/plugin/list/component/EditModal.tsx b/projects/app/src/pages/plugin/list/component/EditModal.tsx index 01eb6dd9c..ccfa5ec82 100644 --- a/projects/app/src/pages/plugin/list/component/EditModal.tsx +++ b/projects/app/src/pages/plugin/list/component/EditModal.tsx @@ -39,6 +39,7 @@ export const defaultForm: EditFormType = { x: 616.4226348688949, y: -165.05298493910115 }, + version: '481', inputs: [], outputs: [] }, @@ -52,6 +53,7 @@ export const defaultForm: EditFormType = { x: 1607.7142331269126, y: -151.8669210746189 }, + version: '481', inputs: [], outputs: [] } diff --git a/projects/app/src/web/core/app/templates.ts b/projects/app/src/web/core/app/templates.ts index 87365fd03..2b1749759 100644 --- a/projects/app/src/web/core/app/templates.ts +++ b/projects/app/src/web/core/app/templates.ts @@ -26,6 +26,7 @@ export const appTemplates: (AppItemType & { x: 531.2422736065552, y: -486.7611729549753 }, + version: '481', inputs: [ { key: 'welcomeText', @@ -88,6 +89,7 @@ export const appTemplates: (AppItemType & { x: 558.4082376415505, y: 123.72387429194112 }, + version: '481', inputs: [ { key: 'userChatInput', @@ -119,6 +121,7 @@ export const appTemplates: (AppItemType & { x: 1097.7317280958762, y: -244.16014496351386 }, + version: '481', inputs: [ { key: 'model', @@ -253,6 +256,7 @@ export const appTemplates: (AppItemType & { x: 496.57560693988853, y: -490.7611729549753 }, + version: '481', inputs: [ { key: 'welcomeText', @@ -332,6 +336,7 @@ export const appTemplates: (AppItemType & { x: 558.4082376415505, y: 123.72387429194112 }, + version: '481', inputs: [ { key: 'userChatInput', @@ -363,6 +368,7 @@ export const appTemplates: (AppItemType & { x: 1097.7317280958762, y: -244.16014496351386 }, + version: '481', inputs: [ { key: 'model', @@ -497,6 +503,7 @@ export const appTemplates: (AppItemType & { x: 531.2422736065552, y: -486.7611729549753 }, + version: '481', inputs: [ { key: 'welcomeText', @@ -559,6 +566,7 @@ export const appTemplates: (AppItemType & { x: 558.4082376415505, y: 123.72387429194112 }, + version: '481', inputs: [ { key: 'userChatInput', @@ -590,6 +598,7 @@ export const appTemplates: (AppItemType & { x: 1638.509551404687, y: -341.0428450861567 }, + version: '481', inputs: [ { key: 'model', @@ -709,6 +718,7 @@ export const appTemplates: (AppItemType & { x: 918.5901682164496, y: -227.11542247619582 }, + version: '481', inputs: [ { key: 'datasets', @@ -821,6 +831,7 @@ export const appTemplates: (AppItemType & { x: 531.2422736065552, y: -486.7611729549753 }, + version: '481', inputs: [ { key: 'welcomeText', @@ -883,6 +894,7 @@ export const appTemplates: (AppItemType & { x: 558.4082376415505, y: 123.72387429194112 }, + version: '481', inputs: [ { key: 'userChatInput', @@ -914,6 +926,7 @@ export const appTemplates: (AppItemType & { x: 2701.1267277679685, y: -767.8956312653042 }, + version: '481', inputs: [ { key: 'model', @@ -1034,6 +1047,7 @@ export const appTemplates: (AppItemType & { x: 1020.9667229609946, y: -385.0060974413916 }, + version: '481', inputs: [ { key: 'model', @@ -1114,6 +1128,7 @@ export const appTemplates: (AppItemType & { x: 1874.9167551056487, y: 434.98431875888207 }, + version: '481', inputs: [ { key: 'text', @@ -1139,6 +1154,7 @@ export const appTemplates: (AppItemType & { x: 1851.010152279949, y: -613.3555232387284 }, + version: '481', inputs: [ { key: 'datasets', diff --git a/projects/app/src/web/core/app/utils.ts b/projects/app/src/web/core/app/utils.ts index 494662a04..f2e1fa1a4 100644 --- a/projects/app/src/web/core/app/utils.ts +++ b/projects/app/src/web/core/app/utils.ts @@ -27,6 +27,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 531.2422736065552, y: -486.7611729549753 }, + version: '481', inputs: [ { key: NodeInputKeyEnum.welcomeText, @@ -79,6 +80,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 558.4082376415505, y: 123.72387429194112 }, + version: '481', inputs: [ { key: 'userChatInput', @@ -115,6 +117,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 1106.3238387960757, y: -350.6030674683474 }, + version: '481', inputs: [ { key: 'model', @@ -247,6 +250,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 1638.509551404687, y: -341.0428450861567 }, + version: '481', // [FlowNodeTypeEnum.chatNode] inputs: [ { key: 'model', @@ -366,6 +370,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 918.5901682164496, y: -227.11542247619582 }, + version: '481', inputs: [ { key: 'datasets', @@ -484,6 +489,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 500, y: 545 }, + version: '481', inputs: [ { key: 'datasets', @@ -597,6 +603,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 500 + 500 * (i + 1), y: 545 }, + version: tool.version, inputs: tool.inputs, outputs: tool.outputs } @@ -625,6 +632,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType { x: 1062.1738942532802, y: -223.65033022650476 }, + version: '481', inputs: [ { key: 'model', diff --git a/projects/app/src/web/core/workflow/adapt.ts b/projects/app/src/web/core/workflow/adapt.ts index b4e6dd157..86657ec87 100644 --- a/projects/app/src/web/core/workflow/adapt.ts +++ b/projects/app/src/web/core/workflow/adapt.ts @@ -39,6 +39,7 @@ export const getGlobalVariableNode = (nodes: FlowNodeItemType[], t: TFunction) = intro: '', unique: true, forbidDelete: true, + version: '481', inputs: [], outputs: [] }; @@ -418,6 +419,7 @@ export const v1Workflow2V2 = ( pluginId, pluginType: node.pluginType, parentId: node.parentId, + version: 'v2.0', inputs, outputs diff --git a/projects/app/src/web/core/workflow/utils.ts b/projects/app/src/web/core/workflow/utils.ts index dfc822bc1..6d3667442 100644 --- a/projects/app/src/web/core/workflow/utils.ts +++ b/projects/app/src/web/core/workflow/utils.ts @@ -24,7 +24,11 @@ import { } from '@fastgpt/global/core/workflow/utils'; import { getSystemVariables } from '../app/utils'; import { TFunction } from 'next-i18next'; -import { ReferenceValueProps } from '@fastgpt/global/core/workflow/type/io'; +import { + FlowNodeInputItemType, + FlowNodeOutputItemType, + ReferenceValueProps +} from '@fastgpt/global/core/workflow/type/io'; import { IfElseListItemType } from '@fastgpt/global/core/workflow/template/system/ifElse/type'; import { VariableConditionEnum } from '@fastgpt/global/core/workflow/template/system/ifElse/constant'; @@ -87,7 +91,8 @@ export const storeNode2FlowNode = ({ ...templateOutput, value: storeOutput.value }; - }) + }), + version: storeNode.version || '481' }; return { @@ -298,3 +303,34 @@ export const getWorkflowGlobalVariables = ( return [...globalVariables, ...systemVariables]; }; + +export type CombinedItemType = Partial & Partial; + +export const updateFlowNodeVersion = ( + node: FlowNodeItemType, + template: FlowNodeTemplateType +): FlowNodeItemType => { + function updateArrayBasedOnTemplate( + nodeArray: T[], + templateArray: T[] + ): T[] { + return templateArray.map((templateItem) => { + const nodeItem = nodeArray.find((item) => item.key === templateItem.key); + if (nodeItem) { + return { ...templateItem, ...nodeItem } as T; + } + return { ...templateItem }; + }); + } + + const updatedNode: FlowNodeItemType = { ...node, ...template, name: node.name }; + + if (node.inputs && template.inputs) { + updatedNode.inputs = updateArrayBasedOnTemplate(node.inputs, template.inputs); + } + if (node.outputs && template.outputs) { + updatedNode.outputs = updateArrayBasedOnTemplate(node.outputs, template.outputs); + } + + return updatedNode; +};