Skip to content

Commit f8b8746

Browse files
committed
Merge remote-tracking branch 'main_repo/3.5.x' into 3.5.x_enhancement_elsa_default_collapse
# Conflicts: # framework/elsa/fit-elsa-react/src/components/end/OutputVariable.jsx
2 parents d1b750b + 2635de1 commit f8b8746

15 files changed

Lines changed: 222 additions & 134 deletions

File tree

framework/elsa/fit-elsa-react/src/common/Consts.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ export const VIRTUAL_CONTEXT_NODE = {
5353
name: 'systemEnv',
5454
};
5555

56+
export const VIRTUAL_CONTEXT_NODE_VARIABLES = {
57+
INSTANCE_ID: 'instanceId',
58+
APP_ID: 'appId',
59+
MEMORIES: 'memories',
60+
USE_MEMORY: 'useMemory',
61+
USER_ID: 'userId',
62+
FILE_URLS: 'fileUrls',
63+
CHAT_ID: 'chatId',
64+
};
65+
5666
export const CONNECTOR = {
5767
RADIUS: 6,
5868
CONDITION_RADIUS: 4,
@@ -177,4 +187,21 @@ export const RENDER_TYPE = {
177187
RADIO: 'Radio',
178188
INPUT: 'Input',
179189
SWITCH: 'Switch',
190+
};
191+
192+
export const DEFAULT_LOOP_NODE_CONTEXT = {
193+
id: uuidv4(),
194+
name: 'context',
195+
type: DATA_TYPES.OBJECT,
196+
from: FROM_TYPE.EXPAND,
197+
value: {
198+
id: uuidv4(),
199+
name: VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID,
200+
type: DATA_TYPES.STRING,
201+
from: FROM_TYPE.REFERENCE,
202+
referenceId: VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID,
203+
referenceKey: VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID,
204+
referenceNode: VIRTUAL_CONTEXT_NODE.id,
205+
value: [VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID],
206+
},
180207
};

framework/elsa/fit-elsa-react/src/components/common/JadePanelHeader.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ export const JadePanelHeader = ({text, tips, shapeStatus, onClick, editable = tr
2727
return (<>
2828
<div className='panel-header'>
2929
<span className='jade-panel-header-font'>{t(text)}</span>
30-
<Popover
30+
{tips && <Popover
3131
content={tips}
3232
align={{offset: [0, 3]}}
3333
overlayClassName={'jade-custom-popover'}
3434
>
35-
<QuestionCircleOutlined className='jade-panel-header-popover-content'/>
35+
<QuestionCircleOutlined className="jade-panel-header-popover-content"/>
3636
</Popover>
37+
}
3738
{
3839
editable ? (<>
3940
<Button disabled={shapeStatus.disabled}
@@ -52,7 +53,7 @@ export const JadePanelHeader = ({text, tips, shapeStatus, onClick, editable = tr
5253

5354
JadePanelHeader.propTypes = {
5455
text: PropTypes.string.isRequired,
55-
tips: PropTypes.object.isRequired,
56+
tips: PropTypes.object,
5657
shapeStatus: PropTypes.object.isRequired,
5758
onClick: PropTypes.func,
5859
editable: PropTypes.bool,

framework/elsa/fit-elsa-react/src/components/end/EndInputForm.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
import PropTypes from 'prop-types';
1010
import ArrayUtil from '@/components/util/ArrayUtil.js';
1111
import {Checkbox, Collapse, Form} from 'antd';
12-
import {Trans, useTranslation} from 'react-i18next';
12+
import {useTranslation} from 'react-i18next';
1313
import {useDispatch} from '@/components/DefaultRoot.jsx';
1414
import {JadePanelHeader} from '@/components/common/JadePanelHeader.jsx';
1515
import {JadeCollapse} from '@/components/common/JadeCollapse.jsx';
@@ -27,10 +27,6 @@ const {Panel} = Collapse;
2727
const _EndInputForm = ({inputParams, shapeStatus}) => {
2828
const dispatch = useDispatch();
2929
const {t} = useTranslation();
30-
const tips =
31-
<div className={'jade-font-size'} style={{lineHeight: '1.2'}}>
32-
<Trans i18nKey='endOutputPopover' components={{p: <p/>}}/>
33-
</div>;
3430
const enableLog = inputParams.find(item => item.name === 'enableLog');
3531

3632
// item被修改.
@@ -53,7 +49,7 @@ const _EndInputForm = ({inputParams, shapeStatus}) => {
5349
return (<>
5450
<JadeCollapse defaultActiveKey={['Output variable']}>
5551
<Panel
56-
header={<JadePanelHeader text={'output'} tips={tips} shapeStatus={shapeStatus} onClick={addItem}/>}
52+
header={<JadePanelHeader text={'output'} shapeStatus={shapeStatus} onClick={addItem}/>}
5753
className='jade-panel'
5854
key='Output variable'
5955
>

framework/elsa/fit-elsa-react/src/components/end/OutputVariable.jsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ const _OutputVariable = ({inputParams, shapeStatus}) => {
3939
dispatch({type: 'editOutputVariable', id: id, changes: changes});
4040
};
4141

42-
43-
const tips =
44-
<div className={'jade-font-size'} style={{lineHeight: '1.2'}}>
45-
<Trans i18nKey="endOutputPopover" components={{p: <p/>}}/>
46-
</div>;
47-
4842
return (
4943
<div>
5044
<JadeCollapse
@@ -56,13 +50,6 @@ const _OutputVariable = ({inputParams, shapeStatus}) => {
5650
<div
5751
style={{display: 'flex', alignItems: 'center', justifyContent: 'flex-start'}}>
5852
<span className="jade-panel-header-font">{t('output')}</span>
59-
<Popover
60-
content={tips}
61-
align={{offset: [0, 3]}}
62-
overlayClassName={'jade-custom-popover'}
63-
>
64-
<QuestionCircleOutlined className="jade-panel-header-popover-content"/>
65-
</Popover>
6653
</div>
6754
}
6855
className="jade-panel"

framework/elsa/fit-elsa-react/src/components/loopNode/loopComponent.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {ChangeFlowMetaReducer} from '@/components/common/reducers/commonReducers
99
import {ChangePluginByMetaDataReducer, DeletePluginReducer, UpdateInputReducer, UpdateRadioInfoReducer} from '@/components/loopNode/reducers/reducers.js';
1010
import {defaultComponent} from '@/components/defaultComponent.js';
1111
import {v4 as uuidv4} from 'uuid';
12-
import {DATA_TYPES, FROM_TYPE} from '@/common/Consts.js';
12+
import {DATA_TYPES, DEFAULT_LOOP_NODE_CONTEXT, FROM_TYPE} from '@/common/Consts.js';
1313

1414
export const loopComponent = (jadeConfig, shape) => {
1515
const self = defaultComponent(jadeConfig);
@@ -50,6 +50,7 @@ export const loopComponent = (jadeConfig, shape) => {
5050
from: FROM_TYPE.INPUT,
5151
value: {},
5252
},
53+
DEFAULT_LOOP_NODE_CONTEXT,
5354
],
5455
outputParams: [],
5556
};

framework/elsa/fit-elsa-react/src/components/loopNode/loopNodeState.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const loopNodeState = (id, x, y, width, height, parent, drawer) => {
2121
self.flowMeta.jober.type = 'STORE_JOBER';
2222
const loopNodeEntity = {
2323
uniqueName: "",
24-
params: [{"name": "args"}, {"name": "config"}, {"name": "toolInfo"}],
24+
params: [{"name": "args"}, {"name": "config"}, {"name": "toolInfo"}, {"name": "context"}],
2525
return: {type: "array"}
2626
};
2727

framework/elsa/fit-elsa-react/src/en_US.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
"llmOutputPopover": "Content generated after the foundation model is executed.",
112112
"modeSelect": "Mode",
113113
"directlyOutputTheResult": "Directly output result",
114-
"endOutputPopover": "<p>These variables will be output after the bot calls the workflow. </p>\n<p>In variable return mode, the bot summarizes these variables and replies to the user.</p>\n<p> In direct answer mode, the bot replies only variables that can be used when the card is configured.</p>",
115114
"conditionBranch": "Condition Branch",
116115
"addBranch": "Add Branch",
117116
"compareObject": "Compared Object",

framework/elsa/fit-elsa-react/src/flow/compatibility/compatibilityProcessors.js

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
DATA_TYPES,
1111
DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT,
1212
DEFAULT_LLM_KNOWLEDGE_BASES,
13-
DEFAULT_LLM_REFERENCE_OUTPUT,
13+
DEFAULT_LLM_REFERENCE_OUTPUT, DEFAULT_LOOP_NODE_CONTEXT,
1414
DEFAULT_MAX_MEMORY_ROUNDS,
1515
END_NODE_TYPE,
1616
FLOW_TYPE,
@@ -49,6 +49,8 @@ export const pageCompatibilityProcessor = (pageData, graph) => {
4949
return knowledgeRetrievalCompatibilityProcessor(shapeData, g, self);
5050
case 'questionClassificationNodeCondition':
5151
return questionClassificationCompatibilityProcessor(shapeData, g, self);
52+
case 'loopNodeState':
53+
return loopNodeCompatibilityProcessor(shapeData, g, self);
5254
default:
5355
return shapeCompatibilityProcessor(shapeData, g, self);
5456
}
@@ -185,6 +187,30 @@ export const questionClassificationCompatibilityProcessor = (shapeData, graph, p
185187
return self;
186188
};
187189

190+
/**
191+
* 循环节点兼容性处理器.
192+
*
193+
* @override
194+
*/
195+
export const loopNodeCompatibilityProcessor = (shapeData, graph, pageHandler) => {
196+
const self = shapeCompatibilityProcessor(shapeData, graph, pageHandler);
197+
198+
/**
199+
* @override
200+
*/
201+
const process = self.process;
202+
self.process = () => {
203+
process.apply(self);
204+
const jober = self.shapeData.flowMeta.jober;
205+
if (!jober.entity.params.exist(param => param.name === 'context')) {
206+
jober.entity.params.push({name: 'context'});
207+
jober.converter.entity.inputParams.push(DEFAULT_LOOP_NODE_CONTEXT);
208+
}
209+
};
210+
211+
return self;
212+
};
213+
188214

189215
/**
190216
* 开始节点兼容性处理器.
@@ -281,43 +307,9 @@ export const endNodeCompatibilityProcessor = (shapeData, graph, pageHandler) =>
281307
if (inputParam.from !== FROM_TYPE.EXPAND) {
282308
return;
283309
}
284-
285-
// const values = inputParam.value;
286-
//
287-
// // 第一个引用若不是大模型,则后续的所有大模型节点enableLog都是false.
288-
// // 若第一个引用是对大模型的引用,遍历,后续【连续】的对大模型节点的引用.
289310
const llmNodes = self.pageProcessor.getShapes(sd => sd.type === 'llmNodeState').map((n, i) => {
290311
return {index: i, data: n};
291312
});
292-
//
293-
// let indexes = []; // 记录所有需要输出日志的大模型的下标.
294-
// for (let i = 0; i < values.length; i++) {
295-
// const input = values[i];
296-
//
297-
// // 不是reference,或referenceKey不存在,退出循环.
298-
// if (input.from !== 'Reference' || !input.referenceKey) {
299-
// break;
300-
// }
301-
//
302-
// // 引用的不是大模型,退出循环.
303-
// const node = llmNodes.find(n => n.data.id === input.referenceNode);
304-
// if (!node) {
305-
// break;
306-
// }
307-
//
308-
// // 当前大模型节点的index小于indexes中的值,跳出循环.
309-
// if (indexes.length > 0 && node.index < indexes[indexes.length - 1]) {
310-
// break;
311-
// }
312-
//
313-
// const chainNodes = self.pageProcessor.getNodesBetween(node.data, self.shapeData);
314-
// if (chainNodes.contains(n => n.type === 'conditionNodeCondition' || n.type === 'manualCheckNodeState')) {
315-
// break;
316-
// }
317-
//
318-
// indexes.push(node.index);
319-
// }
320-
321313
updateLlmFlowMetas(llmNodes);
322314
};
323315

framework/elsa/fit-elsa-react/src/flow/jadeFlowPage.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66

7-
import {copyPasteHelper, ElsaCopyHandler, page, shapeDataHelper, sleep, uuid, PAGE_OPERATION_MODE} from '@fit-elsa/elsa-core';
7+
import {copyPasteHelper, ElsaCopyHandler, page, PAGE_OPERATION_MODE, shapeDataHelper, sleep, uuid} from '@fit-elsa/elsa-core';
88
import {SYSTEM_ACTION, VIRTUAL_CONTEXT_NODE} from '@/common/Consts.js';
99
import {conditionRunner, inactiveNodeRunner, standardRunner} from '@/flow/runners.js';
1010
import {message} from 'antd';
@@ -617,6 +617,22 @@ export const jadeFlowPage = (div, graph, name, id) => {
617617
return beDeletedShapes;
618618
};
619619

620+
/**
621+
* @override
622+
*/
623+
const reorganizeNodes = self.reorganizeNodes;
624+
self.reorganizeNodes = (scale, nodes = self.sm.getShapes(s => s.isTypeof('jadeNode')), lines = self.sm.getShapes(s => s.isTypeof('jadeEvent'))) => {
625+
lines.sort((a, b) => {
626+
if (a.fromShape !== b.fromShape) {
627+
return 0;
628+
}
629+
const aFromConnector = a.definedFromConnector;
630+
const bFromConnector = b.definedFromConnector;
631+
return aFromConnector.localeCompare(bFromConnector);
632+
});
633+
reorganizeNodes.apply(self, [scale, nodes, lines]);
634+
};
635+
620636
return self;
621637
};
622638

framework/elsa/fit-elsa-react/src/shapes/systemEnv.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*--------------------------------------------------------------------------------------------*/
66

77
import {rectangle} from '@fit-elsa/elsa-core';
8-
import {VIRTUAL_CONTEXT_NODE} from '@/common/Consts.js';
8+
import {DATA_TYPES, VIRTUAL_CONTEXT_NODE, VIRTUAL_CONTEXT_NODE_VARIABLES} from '@/common/Consts.js';
99
import {emptyStatusManager} from '@/components/base/emptyStatusManager.js';
1010

1111
/**
@@ -25,13 +25,13 @@ export const systemEnv = (id, x, y, width, height, parent) => {
2525
self.width = 0;
2626
self.height = 0;
2727
self.virtualNodeInfoList = [
28-
{observableId: 'instanceId', value: 'instanceId', type: 'String'},
29-
{observableId: 'appId', value: 'appId', type: 'String'},
30-
{observableId: 'memories', value: 'memories', type: 'Array'},
31-
{observableId: 'useMemory', value: 'useMemory', type: 'Boolean'},
32-
{observableId: 'userId', value: 'userId', type: 'String'},
33-
{observableId: 'fileUrls', value: 'fileUrls', type: 'Array'},
34-
{observableId: 'chatId', value: 'chatId', type: 'String'},
28+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID, value: VIRTUAL_CONTEXT_NODE_VARIABLES.INSTANCE_ID, type: DATA_TYPES.STRING},
29+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.APP_ID, value: VIRTUAL_CONTEXT_NODE_VARIABLES.APP_ID, type: DATA_TYPES.STRING},
30+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.MEMORIES, value: VIRTUAL_CONTEXT_NODE_VARIABLES.MEMORIES, type: DATA_TYPES.ARRAY},
31+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.USE_MEMORY, value: VIRTUAL_CONTEXT_NODE_VARIABLES.USE_MEMORY, type: DATA_TYPES.BOOLEAN},
32+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.USER_ID, value: VIRTUAL_CONTEXT_NODE_VARIABLES.USER_ID, type: DATA_TYPES.STRING},
33+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.FILE_URLS, value: VIRTUAL_CONTEXT_NODE_VARIABLES.FILE_URLS, type: DATA_TYPES.ARRAY},
34+
{observableId: VIRTUAL_CONTEXT_NODE_VARIABLES.CHAT_ID, value: VIRTUAL_CONTEXT_NODE_VARIABLES.CHAT_ID, type: DATA_TYPES.STRING},
3535
];
3636
self.statusManager = emptyStatusManager(self);
3737

0 commit comments

Comments
 (0)