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
88633376
authored
May 06, 2024
by
heheer
Committed by
GitHub
May 06, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: reference input of updateVariable node (#1367)
* fix: reference input of updateVariable node * fix
parent
59bd2a47
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
50 additions
and
40 deletions
+50
-40
packages/global/core/workflow/runtime/constants.ts
+1
-1
packages/global/core/workflow/template/constants.ts
+12
-12
packages/global/core/workflow/template/system/ifElse/index.ts
+1
-1
packages/global/core/workflow/template/system/laf.ts
+1
-1
packages/global/core/workflow/template/system/variableUpdate/index.tsx
+8
-2
packages/global/core/workflow/template/system/variableUpdate/type.d.ts
+2
-0
projects/app/src/components/core/workflow/Flow/nodes/NodeVariableUpdate.tsx
+22
-20
projects/app/src/pages/api/core/chat/chatTest.ts
+1
-1
projects/app/src/pages/api/v1/chat/completions.ts
+1
-1
projects/app/src/web/common/api/fetch.ts
+1
-1
No files found.
packages/global/core/workflow/runtime/constants.ts
View file @
88633376
...
...
@@ -10,7 +10,7 @@ export enum SseResponseEventEnum {
toolParams
=
'toolParams'
,
// tool params return
toolResponse
=
'toolResponse'
,
// tool response return
flowResponses
=
'flowResponses'
,
// sse response request
variables
=
'v
ariables'
updateVariables
=
'updateV
ariables'
}
export
enum
DispatchNodeResponseKeyEnum
{
...
...
packages/global/core/workflow/template/constants.ts
View file @
88633376
...
...
@@ -19,9 +19,9 @@ import { RunPluginModule } from './system/runPlugin';
import
{
AiQueryExtension
}
from
'./system/queryExtension'
;
import
type
{
FlowNodeTemplateType
}
from
'../type'
;
import
{
l
afModule
}
from
'./system/laf'
;
import
{
i
fElseNode
}
from
'./system/ifElse/index'
;
import
{
v
ariableUpdateNode
}
from
'./system/variableUpdate'
;
import
{
L
afModule
}
from
'./system/laf'
;
import
{
I
fElseNode
}
from
'./system/ifElse/index'
;
import
{
V
ariableUpdateNode
}
from
'./system/variableUpdate'
;
/* app flow module templates */
export
const
appSystemModuleTemplates
:
FlowNodeTemplateType
[]
=
[
...
...
@@ -38,9 +38,9 @@ export const appSystemModuleTemplates: FlowNodeTemplateType[] = [
ContextExtractModule
,
HttpModule468
,
AiQueryExtension
,
l
afModule
,
i
fElseNode
,
v
ariableUpdateNode
L
afModule
,
I
fElseNode
,
V
ariableUpdateNode
];
/* plugin flow module templates */
export
const
pluginSystemModuleTemplates
:
FlowNodeTemplateType
[]
=
[
...
...
@@ -57,9 +57,9 @@ export const pluginSystemModuleTemplates: FlowNodeTemplateType[] = [
ContextExtractModule
,
HttpModule468
,
AiQueryExtension
,
l
afModule
,
i
fElseNode
,
v
ariableUpdateNode
L
afModule
,
I
fElseNode
,
V
ariableUpdateNode
];
/* all module */
...
...
@@ -82,7 +82,7 @@ export const moduleTemplatesFlat: FlowNodeTemplateType[] = [
PluginOutputModule
,
RunPluginModule
,
AiQueryExtension
,
l
afModule
,
i
fElseNode
,
v
ariableUpdateNode
L
afModule
,
I
fElseNode
,
V
ariableUpdateNode
];
packages/global/core/workflow/template/system/ifElse/index.ts
View file @
88633376
...
...
@@ -12,7 +12,7 @@ import {
import
{
FlowNodeTemplateType
}
from
'../../../type'
;
import
{
getHandleConfig
}
from
'../../utils'
;
export
const
i
fElseNode
:
FlowNodeTemplateType
=
{
export
const
I
fElseNode
:
FlowNodeTemplateType
=
{
id
:
FlowNodeTypeEnum
.
ifElseNode
,
templateType
:
FlowNodeTemplateTypeEnum
.
tools
,
flowNodeType
:
FlowNodeTypeEnum
.
ifElseNode
,
...
...
packages/global/core/workflow/template/system/laf.ts
View file @
88633376
...
...
@@ -14,7 +14,7 @@ import { Input_Template_DynamicInput } from '../input';
import
{
Output_Template_AddOutput
}
from
'../output'
;
import
{
getHandleConfig
}
from
'../utils'
;
export
const
l
afModule
:
FlowNodeTemplateType
=
{
export
const
L
afModule
:
FlowNodeTemplateType
=
{
id
:
FlowNodeTypeEnum
.
lafModule
,
templateType
:
FlowNodeTemplateTypeEnum
.
externalCall
,
flowNodeType
:
FlowNodeTypeEnum
.
lafModule
,
...
...
packages/global/core/workflow/template/system/variableUpdate/index.tsx
View file @
88633376
...
...
@@ -7,7 +7,7 @@ import {
}
from
'../../../constants'
;
import
{
getHandleConfig
}
from
'../../utils'
;
export
const
v
ariableUpdateNode
:
FlowNodeTemplateType
=
{
export
const
V
ariableUpdateNode
:
FlowNodeTemplateType
=
{
id
:
FlowNodeTypeEnum
.
variableUpdate
,
templateType
:
FlowNodeTemplateTypeEnum
.
tools
,
flowNodeType
:
FlowNodeTypeEnum
.
variableUpdate
,
...
...
@@ -28,7 +28,13 @@ export const variableUpdateNode: FlowNodeTemplateType = {
key
:
true
,
valueType
:
true
},
value
:
[]
value
:
[
{
variable
:
[
''
,
''
],
value
:
''
,
renderType
:
FlowNodeInputTypeEnum
.
input
}
]
}
],
outputs
:
[]
...
...
packages/global/core/workflow/template/system/variableUpdate/type.d.ts
View file @
88633376
import
{
FlowNodeInputTypeEnum
}
from
'core/workflow/node/constant'
;
export
type
TUpdateListItem
=
{
variable
?:
ReferenceValueProps
;
value
?:
ReferenceValueProps
;
...
...
projects/app/src/components/core/workflow/Flow/nodes/NodeVariableUpdate.tsx
View file @
88633376
...
...
@@ -30,6 +30,7 @@ import { SmallAddIcon } from '@chakra-ui/icons';
import
MyTooltip
from
'@fastgpt/web/components/common/MyTooltip'
;
import
{
ReferenceValueProps
}
from
'@fastgpt/global/core/workflow/type/io'
;
import
{
ReferSelector
,
useReference
}
from
'./render/RenderInput/templates/Reference'
;
import
{
getWorkflowGlobalVariables
}
from
'@/web/core/workflow/utils'
;
const
NodeVariableUpdate
=
({
data
,
selected
}:
NodeProps
<
FlowNodeItemType
>
)
=>
{
const
{
inputs
=
[],
nodeId
}
=
data
;
...
...
@@ -37,6 +38,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
const
onChangeNode
=
useContextSelector
(
WorkflowContext
,
(
v
)
=>
v
.
onChangeNode
);
const
nodes
=
useContextSelector
(
WorkflowContext
,
(
v
)
=>
v
.
nodes
);
const
nodeList
=
useContextSelector
(
WorkflowContext
,
(
v
)
=>
v
.
nodeList
);
const
updateList
=
useMemo
(
()
=>
...
...
@@ -84,10 +86,10 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
const
variable
=
updateItem
.
variable
;
const
variableNodeId
=
variable
?.[
0
];
const
variableNode
=
nodes
.
find
((
node
)
=>
node
.
id
===
variableNodeId
);
if
(
!
variableNode
)
return
'any'
;
const
variableInput
=
variableNode
.
data
.
outputs
.
find
(
(
output
)
=>
output
.
id
===
variable
?.[
1
]
);
const
systemVariables
=
getWorkflowGlobalVariables
(
nodeList
,
t
)
;
const
variableInput
=
!
variableNode
?
systemVariables
.
find
((
item
)
=>
item
.
key
===
variable
?.[
1
])
:
variableNode
?.
data
.
outputs
.
find
((
output
)
=>
output
.
id
===
variable
?.[
1
]
);
if
(
!
variableInput
)
return
'any'
;
return
variableInput
.
valueType
;
})();
...
...
@@ -95,9 +97,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
const
renderTypeData
=
menuList
.
find
((
item
)
=>
item
.
renderType
===
updateItem
.
renderType
);
const
handleUpdate
=
(
newValue
:
any
)
=>
{
onUpdateList
(
updateList
.
map
((
update
,
i
)
=>
i
===
index
?
{
...
update
,
value
:
[
''
,
newValue
]
}
:
update
)
updateList
.
map
((
update
,
i
)
=>
(
i
===
index
?
{
...
update
,
value
:
newValue
}
:
update
))
);
};
return
(
...
...
@@ -123,20 +123,22 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
}
}
/>
<
Box
flex=
{
1
}
/>
<
MyIcon
className=
"delete"
name=
{
'delete'
}
w=
{
'14px'
}
color=
{
'myGray.600'
}
cursor=
{
'pointer'
}
ml=
{
2
}
_hover=
{
{
color
:
'red.500'
}
}
onClick=
{
()
=>
{
onUpdateList
(
updateList
.
filter
((
_
,
i
)
=>
i
!==
index
));
}
}
/>
{
updateList
.
length
>
1
&&
(
<
MyIcon
className=
"delete"
name=
{
'delete'
}
w=
{
'14px'
}
color=
{
'myGray.600'
}
cursor=
{
'pointer'
}
ml=
{
2
}
_hover=
{
{
color
:
'red.500'
}
}
onClick=
{
()
=>
{
onUpdateList
(
updateList
.
filter
((
_
,
i
)
=>
i
!==
index
));
}
}
/>
)
}
</
Flex
>
<
Flex
mt=
{
2
}
w=
{
'full'
}
alignItems=
{
'center'
}
>
<
Flex
mt=
{
2
}
w=
{
'full'
}
alignItems=
{
'center'
}
className=
"nodrag"
>
<
Flex
w=
{
'60px'
}
flex=
{
0
}
>
<
Box
>
{
t
(
'core.workflow.value'
)
}
</
Box
>
<
MyTooltip
...
...
projects/app/src/pages/api/core/chat/chatTest.ts
View file @
88633376
...
...
@@ -101,7 +101,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
responseWrite
({
res
,
event
:
SseResponseEventEnum
.
v
ariables
,
event
:
SseResponseEventEnum
.
updateV
ariables
,
data
:
JSON
.
stringify
(
newVariables
)
});
res
.
end
();
...
...
projects/app/src/pages/api/v1/chat/completions.ts
View file @
88633376
...
...
@@ -290,7 +290,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
});
responseWrite
({
res
,
event
:
SseResponseEventEnum
.
v
ariables
,
event
:
SseResponseEventEnum
.
updateV
ariables
,
data
:
JSON
.
stringify
(
newVariables
)
});
...
...
projects/app/src/web/common/api/fetch.ts
View file @
88633376
...
...
@@ -201,7 +201,7 @@ export const streamFetch = ({
});
}
else
if
(
event
===
SseResponseEventEnum
.
flowResponses
&&
Array
.
isArray
(
parseJson
))
{
responseData
=
parseJson
;
}
else
if
(
event
===
SseResponseEventEnum
.
v
ariables
)
{
}
else
if
(
event
===
SseResponseEventEnum
.
updateV
ariables
)
{
newVariables
=
parseJson
;
}
else
if
(
event
===
SseResponseEventEnum
.
error
)
{
if
(
parseJson
.
statusText
===
TeamErrEnum
.
aiPointsNotEnough
)
{
...
...
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