Skip to content

Commit

Permalink
loop support reference parent variable
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Oct 25, 2024
1 parent a5a71cd commit 6379645
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/service/core/workflow/dispatch/loop/runLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
return Promise.reject('Input array length cannot be greater than 50');
}

const runNodes = runtimeNodes.filter((node) => childrenNodeIdList.includes(node.nodeId));

const outputValueArr = [];
const loopDetail: ChatHistoryItemResType[] = [];
let assistantResponses: AIChatItemValueItemType[] = [];
Expand All @@ -43,7 +41,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
for await (const item of loopInputArray) {
const response = await dispatchWorkFlow({
...props,
runtimeNodes: runNodes.map((node) =>
runtimeNodes: runtimeNodes.map((node) =>
node.flowNodeType === FlowNodeTypeEnum.loopStart
? {
...node,
Expand Down
3 changes: 2 additions & 1 deletion projects/app/src/web/core/workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ export const computedNodeInputReference = ({
if (!node) {
return;
}
const parentId = node.parentNodeId;
let sourceNodes: FlowNodeItemType[] = [];
// 根据 edge 获取所有的 source 节点(source节点会继续向前递归获取)
const findSourceNode = (nodeId: string) => {
const targetEdges = edges.filter((item) => item.target === nodeId);
const targetEdges = edges.filter((item) => item.target === nodeId || item.target === parentId);
targetEdges.forEach((edge) => {
const sourceNode = nodes.find((item) => item.nodeId === edge.source);
if (!sourceNode) return;
Expand Down

0 comments on commit 6379645

Please sign in to comment.