Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f7a82034
authored
Sep 28, 2024
by
heheer
Committed by
GitHub
Sep 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:variable not update in nested workflow runs (#2830)
parent
d95f71e9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
3 deletions
+21
-3
packages/global/core/workflow/runtime/constants.ts
+2
-1
packages/global/core/workflow/runtime/type.d.ts
+1
-0
packages/service/core/workflow/dispatch/agent/runTool/index.ts
+3
-1
packages/service/core/workflow/dispatch/index.ts
+8
-0
packages/service/core/workflow/dispatch/loop/runLoop.ts
+7
-1
No files found.
packages/global/core/workflow/runtime/constants.ts
View file @
f7a82034
...
@@ -25,7 +25,8 @@ export enum DispatchNodeResponseKeyEnum {
...
@@ -25,7 +25,8 @@ export enum DispatchNodeResponseKeyEnum {
rewriteHistories
=
'rewriteHistories'
,
// If have the response, workflow histories will be rewrite
rewriteHistories
=
'rewriteHistories'
,
// If have the response, workflow histories will be rewrite
interactive
=
'INTERACTIVE'
,
// is interactive
interactive
=
'INTERACTIVE'
,
// is interactive
runTimes
=
'runTimes'
// run times
runTimes
=
'runTimes'
,
// run times
newVariables
=
'newVariables'
// new variables
}
}
export
const
needReplaceReferenceInputTypeList
=
[
export
const
needReplaceReferenceInputTypeList
=
[
...
...
packages/global/core/workflow/runtime/type.d.ts
View file @
f7a82034
...
@@ -196,6 +196,7 @@ export type DispatchNodeResultType<T = {}> = {
...
@@ -196,6 +196,7 @@ export type DispatchNodeResultType<T = {}> = {
[
DispatchNodeResponseKeyEnum
.
assistantResponses
]?:
AIChatItemValueItemType
[];
// Assistant response(Store to db)
[
DispatchNodeResponseKeyEnum
.
assistantResponses
]?:
AIChatItemValueItemType
[];
// Assistant response(Store to db)
[
DispatchNodeResponseKeyEnum
.
rewriteHistories
]?:
ChatItemType
[];
[
DispatchNodeResponseKeyEnum
.
rewriteHistories
]?:
ChatItemType
[];
[
DispatchNodeResponseKeyEnum
.
runTimes
]?:
number
;
[
DispatchNodeResponseKeyEnum
.
runTimes
]?:
number
;
[
DispatchNodeResponseKeyEnum
.
newVariables
]?:
Record
<
string
,
any
>
;
}
&
T
;
}
&
T
;
/* Single node props */
/* Single node props */
...
...
packages/service/core/workflow/dispatch/agent/runTool/index.ts
View file @
f7a82034
...
@@ -184,6 +184,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
...
@@ -184,6 +184,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
// flat child tool response
// flat child tool response
const
childToolResponse
=
dispatchFlowResponse
.
map
((
item
)
=>
item
.
flowResponses
).
flat
();
const
childToolResponse
=
dispatchFlowResponse
.
map
((
item
)
=>
item
.
flowResponses
).
flat
();
const
newVariables
=
dispatchFlowResponse
[
dispatchFlowResponse
.
length
-
1
]?.
newVariables
;
// concat tool usage
// concat tool usage
const
totalPointsUsage
=
const
totalPointsUsage
=
...
@@ -219,6 +220,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
...
@@ -219,6 +220,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
tokens
:
totalTokens
tokens
:
totalTokens
},
},
...
flatUsages
...
flatUsages
]
],
[
DispatchNodeResponseKeyEnum
.
newVariables
]:
newVariables
};
};
};
};
packages/service/core/workflow/dispatch/index.ts
View file @
f7a82034
...
@@ -555,6 +555,14 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
...
@@ -555,6 +555,14 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
dispatchRes
[
item
.
key
]
=
valueTypeFormat
(
item
.
defaultValue
,
item
.
valueType
);
dispatchRes
[
item
.
key
]
=
valueTypeFormat
(
item
.
defaultValue
,
item
.
valueType
);
});
});
// Update new variables
if
(
dispatchRes
[
DispatchNodeResponseKeyEnum
.
newVariables
])
{
variables
=
{
...
variables
,
...
dispatchRes
[
DispatchNodeResponseKeyEnum
.
newVariables
]
};
}
return
{
return
{
node
,
node
,
runStatus
:
'run'
,
runStatus
:
'run'
,
...
...
packages/service/core/workflow/dispatch/loop/runLoop.ts
View file @
f7a82034
...
@@ -38,6 +38,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
...
@@ -38,6 +38,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
const
loopDetail
:
ChatHistoryItemResType
[]
=
[];
const
loopDetail
:
ChatHistoryItemResType
[]
=
[];
let
assistantResponses
:
AIChatItemValueItemType
[]
=
[];
let
assistantResponses
:
AIChatItemValueItemType
[]
=
[];
let
totalPoints
=
0
;
let
totalPoints
=
0
;
let
newVariables
:
Record
<
string
,
any
>
=
{};
for
await
(
const
item
of
loopInputArray
)
{
for
await
(
const
item
of
loopInputArray
)
{
const
response
=
await
dispatchWorkFlow
({
const
response
=
await
dispatchWorkFlow
({
...
@@ -72,6 +73,10 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
...
@@ -72,6 +73,10 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
assistantResponses
.
push
(...
response
.
assistantResponses
);
assistantResponses
.
push
(...
response
.
assistantResponses
);
totalPoints
=
response
.
flowUsages
.
reduce
((
acc
,
usage
)
=>
acc
+
usage
.
totalPoints
,
0
);
totalPoints
=
response
.
flowUsages
.
reduce
((
acc
,
usage
)
=>
acc
+
usage
.
totalPoints
,
0
);
newVariables
=
{
...
newVariables
,
...
response
.
newVariables
};
}
}
return
{
return
{
...
@@ -88,6 +93,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
...
@@ -88,6 +93,7 @@ export const dispatchLoop = async (props: Props): Promise<Response> => {
moduleName
:
name
moduleName
:
name
}
}
],
],
[
NodeOutputKeyEnum
.
loopArray
]:
outputValueArr
[
NodeOutputKeyEnum
.
loopArray
]:
outputValueArr
,
[
DispatchNodeResponseKeyEnum
.
newVariables
]:
newVariables
};
};
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment