From c5032153e1f151c00ff62af1c37f67752a1dcc8f Mon Sep 17 00:00:00 2001 From: RonnyChan96 Date: Sun, 27 Apr 2025 17:25:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[elsa]=20=E7=9F=A5=E8=AF=86=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E8=8A=82=E7=82=B9=E6=B7=BB=E5=8A=A0userId=E5=85=A5?= =?UTF-8?q?=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elsa/fit-elsa-react/src/common/Consts.js | 12 +++++++ .../knowledgeRetrievalComponent.jsx | 5 +-- .../knowledgeRetrievalNodeState.jsx | 3 ++ .../compatibility/compatibilityProcessors.js | 32 ++++++++++++++++--- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/framework/elsa/fit-elsa-react/src/common/Consts.js b/framework/elsa/fit-elsa-react/src/common/Consts.js index 39a0fb902..75fd09570 100644 --- a/framework/elsa/fit-elsa-react/src/common/Consts.js +++ b/framework/elsa/fit-elsa-react/src/common/Consts.js @@ -204,4 +204,16 @@ export const DEFAULT_LOOP_NODE_CONTEXT = { referenceNode: VIRTUAL_CONTEXT_NODE.id, value: [VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID], }], +}; + +export const DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_USER_ID = { + id: `userId_${uuidv4()}`, + name: 'userId', + type: 'String', + from: 'Reference', + referenceNode: VIRTUAL_CONTEXT_NODE.id, + referenceId: VIRTUAL_CONTEXT_NODE_VARIABLES.USER_ID, + referenceKey: VIRTUAL_CONTEXT_NODE_VARIABLES.USER_ID, + editable: false, + value: [VIRTUAL_CONTEXT_NODE_VARIABLES.USER_ID], }; \ No newline at end of file diff --git a/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalComponent.jsx b/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalComponent.jsx index 3e8f61274..73078eb8a 100644 --- a/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalComponent.jsx +++ b/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalComponent.jsx @@ -7,7 +7,7 @@ import {v4 as uuidv4} from 'uuid'; import {KnowledgeRetrievalWrapper} from '@/components/knowledgeRetrieval/KnowledgeRetrievalWrapper.jsx'; import {retrievalComponent} from '@/components/retrieval/retrievalComponent.jsx'; -import {DATA_TYPES, DEFAULT_KNOWLEDGE_REPO_GROUP, FROM_TYPE} from '@/common/Consts.js'; +import {DATA_TYPES, DEFAULT_KNOWLEDGE_REPO_GROUP, DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_USER_ID, FROM_TYPE, VIRTUAL_CONTEXT_NODE} from '@/common/Consts.js'; import { UpdateGroupIdReducer, UpdateInputParamReducer, @@ -138,7 +138,8 @@ export const knowledgeRetrievalComponent = (jadeConfig, shape) => { from: FROM_TYPE.INPUT, value: DEFAULT_KNOWLEDGE_REPO_GROUP, }], - }], + }, + DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_USER_ID], outputParams: [{ id: `output_${uuidv4()}`, name: 'output', diff --git a/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalNodeState.jsx b/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalNodeState.jsx index 77cfe6b0f..6359dee29 100644 --- a/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalNodeState.jsx +++ b/framework/elsa/fit-elsa-react/src/components/knowledgeRetrieval/knowledgeRetrievalNodeState.jsx @@ -39,6 +39,9 @@ export const knowledgeRetrievalNodeState = (id, x, y, width, height, parent, dra { name: 'option', }, + { + name: 'userId', + }, ], return: { type: 'object', diff --git a/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js b/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js index a0db5e2fb..0512fd29a 100644 --- a/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js +++ b/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js @@ -9,8 +9,10 @@ import {getDefaultReference} from '@/components/util/ReferenceUtil.js'; import { DATA_TYPES, DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT, + DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_USER_ID, DEFAULT_LLM_KNOWLEDGE_BASES, - DEFAULT_LLM_REFERENCE_OUTPUT, DEFAULT_LOOP_NODE_CONTEXT, + DEFAULT_LLM_REFERENCE_OUTPUT, + DEFAULT_LOOP_NODE_CONTEXT, DEFAULT_MAX_MEMORY_ROUNDS, END_NODE_TYPE, FLOW_TYPE, @@ -390,10 +392,30 @@ export const knowledgeRetrievalCompatibilityProcessor = (shapeData, graph, pageH const process = self.process; self.process = () => { process.apply(self); - const optionValue = self.shapeData.flowMeta.jober.converter.entity.inputParams.find(inputParam => inputParam.name === 'option').value; - if (!optionValue.find(v => v.name === 'groupId')) { - optionValue.push(DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT); - } + + const optionParamProcess = () => { + const optionValue = self.shapeData.flowMeta.jober.converter.entity.inputParams.find(inputParam => inputParam.name === 'option').value; + if (!optionValue.find(v => v.name === 'groupId')) { + optionValue.push(DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT); + } + }; + + const userIdParamProcess = () => { + const inputParams = self.shapeData.flowMeta.jober.converter.entity.inputParams; + const userIdParam = inputParams.find(inputParam => inputParam.name === 'userId'); + if (!userIdParam) { + inputParams.push(DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_USER_ID); + } + const entityParams = self.shapeData.flowMeta.jober.entity.params; + if (!entityParams.find(param => param.name === 'userId')) { + const optionIndex = entityParams.findIndex(param => param.name === 'option'); + const insertIndex = optionIndex !== -1 ? optionIndex + 1 : entityParams.length; + entityParams.splice(insertIndex, 0, {name: 'userId'}); + } + }; + + optionParamProcess(); + userIdParamProcess(); }; return self; From 4b15d7ea4c9a1000781e1ca71173a6252b370264 Mon Sep 17 00:00:00 2001 From: RonnyChan96 Date: Mon, 28 Apr 2025 09:34:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[elsa]=20=E6=A3=80=E8=A7=86=E6=84=8F?= =?UTF-8?q?=E8=A7=81=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?inputParam=E4=B8=ADoption=E7=9A=84=E7=A9=BA=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/flow/compatibility/compatibilityProcessors.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js b/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js index 0512fd29a..85b1e1196 100644 --- a/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js +++ b/framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js @@ -394,8 +394,10 @@ export const knowledgeRetrievalCompatibilityProcessor = (shapeData, graph, pageH process.apply(self); const optionParamProcess = () => { - const optionValue = self.shapeData.flowMeta.jober.converter.entity.inputParams.find(inputParam => inputParam.name === 'option').value; - if (!optionValue.find(v => v.name === 'groupId')) { + const optionValue = self.shapeData.flowMeta.jober.converter.entity.inputParams + .find(inputParam => inputParam.name === 'option')?.value; + + if (Array.isArray(optionValue) && !optionValue.some(v => v.name === 'groupId')) { optionValue.push(DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT); } };