loop node dynamic height (#3092)

* loop node dynamic height

* fix

* fix
This commit is contained in:
heheer
2024-11-08 12:10:15 +08:00
committed by GitHub
parent 7a933f73b6
commit 5b2cc097b0
11 changed files with 176 additions and 118 deletions

View File

@@ -5,7 +5,7 @@ import { StoreNodeItemType } from '../type/node';
import { StoreEdgeItemType } from '../type/edge';
import { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';
import { VARIABLE_NODE_ID } from '../constants';
import { isReferenceValue, isReferenceValueArray } from '../utils';
import { isReferenceValueFormat } from '../utils';
import { FlowNodeOutputItemType, ReferenceValueType } from '../type/io';
import { ChatItemType, NodeOutputItemType } from '../../../core/chat/type';
import { ChatItemValueTypeEnum, ChatRoleEnum } from '../../../core/chat/constants';
@@ -244,7 +244,7 @@ export const getReferenceVariableValue = ({
const nodeIds = nodes.map((node) => node.nodeId);
// handle single reference value
if (isReferenceValue(value, nodeIds)) {
if (isReferenceValueFormat(value)) {
const sourceNodeId = value[0];
const outputId = value[1];
@@ -261,7 +261,11 @@ export const getReferenceVariableValue = ({
}
// handle reference array
if (isReferenceValueArray(value, nodeIds)) {
if (
Array.isArray(value) &&
value.length > 0 &&
value.every((item) => isReferenceValueFormat(item))
) {
const result = value.map<any>((val) => {
return getReferenceVariableValue({
value: val,
@@ -270,7 +274,7 @@ export const getReferenceVariableValue = ({
});
});
return result.flat();
return result.flat().filter((item) => item !== undefined);
}
return value;