Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
9bca3f8f
Commit
9bca3f8f
authored
Mar 13, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: code support output var list
parent
0d2366b4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
25 deletions
+36
-25
output-var-list.tsx
...kflow/nodes/_base/components/variable/output-var-list.tsx
+3
-2
utils.ts
...ponents/workflow/nodes/_base/components/variable/utils.ts
+14
-0
var-reference-picker.tsx
.../nodes/_base/components/variable/var-reference-picker.tsx
+1
-1
var-reference-popup.tsx
...w/nodes/_base/components/variable/var-reference-popup.tsx
+2
-2
var-type-picker.tsx
...kflow/nodes/_base/components/variable/var-type-picker.tsx
+2
-1
use-output-var-list.ts
...ponents/workflow/nodes/_base/hooks/use-output-var-list.ts
+4
-2
types.ts
web/app/components/workflow/nodes/code/types.ts
+2
-9
types.ts
web/app/components/workflow/types.ts
+8
-8
No files found.
web/app/components/workflow/nodes/_base/components/variable/output-var-list.tsx
View file @
9bca3f8f
...
...
@@ -2,9 +2,10 @@
import
type
{
FC
}
from
'react'
import
React
,
{
useCallback
}
from
'react'
import
produce
from
'immer'
import
type
{
OutputVar
,
OutputVarType
}
from
'../../../code/types'
import
type
{
OutputVar
}
from
'../../../code/types'
import
RemoveButton
from
'../remove-button'
import
VarTypePicker
from
'./var-type-picker'
import
type
{
VarType
}
from
'@/app/components/workflow/types'
type
Props
=
{
readonly
:
boolean
...
...
@@ -39,7 +40,7 @@ const OutputVarList: FC<Props> = ({
return
(
value
:
string
)
=>
{
const
key
=
list
[
index
].
variable
const
newOutputs
=
produce
(
outputs
,
(
draft
)
=>
{
draft
[
key
].
type
=
value
as
Output
VarType
draft
[
key
].
type
=
value
as
VarType
})
onChange
(
newOutputs
)
}
...
...
web/app/components/workflow/nodes/_base/components/variable/utils.ts
View file @
9bca3f8f
import
type
{
CodeNodeType
}
from
'../../../code/types'
import
{
BlockEnum
,
InputVarType
,
VarType
}
from
'@/app/components/workflow/types'
import
type
{
StartNodeType
}
from
'@/app/components/workflow/nodes/start/types'
import
type
{
NodeOutPutVar
}
from
'@/app/components/workflow/types'
...
...
@@ -40,6 +41,19 @@ const formatItem = (item: any): NodeOutPutVar => {
res
.
vars
=
KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT
break
}
case
BlockEnum
.
Code
:
{
const
{
outputs
,
}
=
data
as
CodeNodeType
res
.
vars
=
Object
.
keys
(
outputs
).
map
((
key
)
=>
{
return
{
variable
:
key
,
type
:
outputs
[
key
].
type
,
}
})
break
}
}
return
res
...
...
web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx
View file @
9bca3f8f
...
...
@@ -95,7 +95,7 @@ const VarReferencePicker: FC<Props> = ({
<
Variable02
className=
'w-3.5 h-3.5'
/>
<
div
className=
'ml-0.5 text-xs font-medium'
>
{
varName
}
</
div
>
</
div
>
<
div
className=
'ml-0.5 text-xs font-normal text-gray-500'
>
{
getVarType
()
}
</
div
>
<
div
className=
'ml-0.5 text-xs font-normal text-gray-500
capitalize
'
>
{
getVarType
()
}
</
div
>
</>
)
}
</
div
>
...
...
web/app/components/workflow/nodes/_base/components/variable/var-reference-popup.tsx
View file @
9bca3f8f
...
...
@@ -30,7 +30,7 @@ const Item: FC<ItemProps> = ({
itemData
,
onChange
,
})
=>
{
const
isObj
=
itemData
.
type
===
VarType
.
object
const
isObj
=
itemData
.
type
===
VarType
.
object
&&
itemData
.
children
&&
itemData
.
children
.
length
>
0
const
itemRef
=
useRef
(
null
)
const
isItemHovering
=
useHover
(
itemRef
)
const
handleChosen
=
(
e
:
React
.
MouseEvent
)
=>
{
...
...
@@ -78,7 +78,7 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
<
div
className=
'absolute right-[248px] top-[-2px] bg-white rounded-lg border border-gray-200 shadow-lg space-y-1'
>
<
div
className=
'flex items-center h-[22px] px-3 text-xs font-normal text-gray-700'
><
span
className=
'text-gray-500'
>
{
title
}
.
</
span
>
{
currObjPath
.
join
(
'.'
)
}
</
div
>
{
data
.
map
((
v
,
i
)
=>
(
data
?
.
map
((
v
,
i
)
=>
(
<
Item
key=
{
i
}
nodeId=
{
nodeId
}
...
...
web/app/components/workflow/nodes/_base/components/variable/var-type-picker.tsx
View file @
9bca3f8f
...
...
@@ -9,6 +9,7 @@ import {
}
from
'@/app/components/base/portal-to-follow-elem'
import
{
Check
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
ChevronDown
}
from
'@/app/components/base/icons/src/vender/line/arrows'
import
{
VarType
}
from
'@/app/components/workflow/types'
type
Props
=
{
className
?:
string
...
...
@@ -17,7 +18,7 @@ type Props = {
onChange
:
(
value
:
string
)
=>
void
}
const
TYPES
=
[
'string'
,
'number'
]
const
TYPES
=
[
VarType
.
string
,
VarType
.
number
,
VarType
.
arrayNumber
,
VarType
.
arrayString
,
VarType
.
object
]
const
VarReferencePicker
:
FC
<
Props
>
=
({
readonly
,
className
,
...
...
web/app/components/workflow/nodes/_base/hooks/use-output-var-list.ts
View file @
9bca3f8f
import
{
useCallback
}
from
'react'
import
produce
from
'immer'
import
{
type
OutputVar
,
OutputVarType
}
from
'../../code/types'
import
{
type
OutputVar
}
from
'../../code/types'
import
{
VarType
}
from
'@/app/components/workflow/types'
type
Params
<
T
>
=
{
inputs
:
T
setInputs
:
(
newInputs
:
T
)
=>
void
...
...
@@ -23,7 +25,7 @@ function useOutputVarList<T>({
draft
[
varKey
]
=
{
...
draft
[
varKey
],
[
`var-
${
Object
.
keys
(
draft
[
varKey
]).
length
+
1
}
`
]:
{
type
:
Output
VarType
.
string
,
type
:
VarType
.
string
,
children
:
null
,
},
}
...
...
web/app/components/workflow/nodes/code/types.ts
View file @
9bca3f8f
import
type
{
CommonNodeType
,
Variable
}
from
'@/app/components/workflow/types'
import
type
{
CommonNodeType
,
Var
Type
,
Var
iable
}
from
'@/app/components/workflow/types'
export
enum
CodeLanguage
{
python3
=
'python3'
,
...
...
@@ -6,15 +6,8 @@ export enum CodeLanguage {
json
=
'json'
,
}
export
enum
OutputVarType
{
string
=
'string'
,
number
=
'number'
,
boolean
=
'boolean'
,
object
=
'object'
,
}
export
type
OutputVar
=
Record
<
string
,
{
type
:
Output
VarType
type
:
VarType
children
:
null
// support nest in the future,
}
>
...
...
web/app/components/workflow/types.ts
View file @
9bca3f8f
...
...
@@ -119,14 +119,14 @@ export type Memory = {
}
export
enum
VarType
{
string
=
'
S
tring'
,
number
=
'
N
umber'
,
boolean
=
'
B
oolean'
,
object
=
'
O
bject'
,
array
=
'
A
rray'
,
arrayString
=
'
A
rray[string]'
,
arrayNumber
=
'
A
rray[number]'
,
arrayObject
=
'
A
rray[object]'
,
string
=
'
s
tring'
,
number
=
'
n
umber'
,
boolean
=
'
b
oolean'
,
object
=
'
o
bject'
,
array
=
'
a
rray'
,
arrayString
=
'
a
rray[string]'
,
arrayNumber
=
'
a
rray[number]'
,
arrayObject
=
'
a
rray[object]'
,
}
export
type
Var
=
{
...
...
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