Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions framework/elsa/fit-elsa-react/src/common/Consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const knowledgeRetrievalNodeState = (id, x, y, width, height, parent, dra
{
name: 'option',
},
{
name: 'userId',
},
],
return: {
type: 'object',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -390,10 +392,32 @@ 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 (Array.isArray(optionValue) && !optionValue.some(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;
Expand Down