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
14d71fb5
Commit
14d71fb5
authored
Mar 12, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: var picker get vars
parent
a0315074
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
31 additions
and
0 deletions
+31
-0
var-list.tsx
...nts/workflow/nodes/_base/components/variable/var-list.tsx
+3
-0
var-reference-picker.tsx
.../nodes/_base/components/variable/var-reference-picker.tsx
+5
-0
panel.tsx
web/app/components/workflow/nodes/code/panel.tsx
+1
-0
panel.tsx
web/app/components/workflow/nodes/end/panel.tsx
+2
-0
condition-item.tsx
...ents/workflow/nodes/if-else/components/condition-item.tsx
+3
-0
condition-list.tsx
...ents/workflow/nodes/if-else/components/condition-list.tsx
+4
-0
panel.tsx
web/app/components/workflow/nodes/if-else/panel.tsx
+1
-0
panel.tsx
...p/components/workflow/nodes/knowledge-retrieval/panel.tsx
+1
-0
panel.tsx
web/app/components/workflow/nodes/llm/panel.tsx
+2
-0
panel.tsx
...p/components/workflow/nodes/question-classifier/panel.tsx
+1
-0
input-var-list.tsx
...ponents/workflow/nodes/tool/components/input-var-list.tsx
+3
-0
panel.tsx
web/app/components/workflow/nodes/tool/panel.tsx
+1
-0
index.tsx
...low/nodes/variable-assigner/components/var-list/index.tsx
+3
-0
panel.tsx
...app/components/workflow/nodes/variable-assigner/panel.tsx
+1
-0
No files found.
web/app/components/workflow/nodes/_base/components/variable/var-list.tsx
View file @
14d71fb5
...
@@ -7,12 +7,14 @@ import VarReferencePicker from './var-reference-picker'
...
@@ -7,12 +7,14 @@ import VarReferencePicker from './var-reference-picker'
import
type
{
ValueSelector
,
Variable
}
from
'@/app/components/workflow/types'
import
type
{
ValueSelector
,
Variable
}
from
'@/app/components/workflow/types'
type
Props
=
{
type
Props
=
{
nodeId
:
string
readonly
:
boolean
readonly
:
boolean
list
:
Variable
[]
list
:
Variable
[]
onChange
:
(
list
:
Variable
[])
=>
void
onChange
:
(
list
:
Variable
[])
=>
void
}
}
const
VarList
:
FC
<
Props
>
=
({
const
VarList
:
FC
<
Props
>
=
({
nodeId
,
readonly
,
readonly
,
list
,
list
,
onChange
,
onChange
,
...
@@ -57,6 +59,7 @@ const VarList: FC<Props> = ({
...
@@ -57,6 +59,7 @@ const VarList: FC<Props> = ({
className=
'w-[120px] h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
className=
'w-[120px] h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
type=
'text'
/>
type=
'text'
/>
<
VarReferencePicker
<
VarReferencePicker
nodeId=
{
nodeId
}
readonly=
{
readonly
}
readonly=
{
readonly
}
isShowNodeName
isShowNodeName
className=
'grow'
className=
'grow'
...
...
web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx
View file @
14d71fb5
...
@@ -13,9 +13,11 @@ import {
...
@@ -13,9 +13,11 @@ import {
PortalToFollowElemContent
,
PortalToFollowElemContent
,
PortalToFollowElemTrigger
,
PortalToFollowElemTrigger
,
}
from
'@/app/components/base/portal-to-follow-elem'
}
from
'@/app/components/base/portal-to-follow-elem'
import
{
useWorkflow
}
from
'@/app/components/workflow/hooks'
type
Props
=
{
type
Props
=
{
className
?:
string
className
?:
string
nodeId
:
string
isShowNodeName
:
boolean
isShowNodeName
:
boolean
readonly
:
boolean
readonly
:
boolean
value
:
ValueSelector
value
:
ValueSelector
...
@@ -35,12 +37,15 @@ export const getNodeInfoById = (id: string) => {
...
@@ -35,12 +37,15 @@ export const getNodeInfoById = (id: string) => {
}
}
const
VarReferencePicker
:
FC
<
Props
>
=
({
const
VarReferencePicker
:
FC
<
Props
>
=
({
nodeId
,
readonly
,
readonly
,
className
,
className
,
isShowNodeName
,
isShowNodeName
,
value
,
value
,
onChange
,
onChange
,
})
=>
{
})
=>
{
const
{
getTreeLeafNodes
,
getBeforeNodesInSameBranch
}
=
useWorkflow
()
// console.log(getBeforeNodesInSameBranch(nodeId), getTreeLeafNodes())
const
[
open
,
setOpen
]
=
useState
(
false
)
const
[
open
,
setOpen
]
=
useState
(
false
)
const
hasValue
=
value
.
length
>
0
const
hasValue
=
value
.
length
>
0
const
node
=
hasValue
?
getNodeInfoById
(
value
[
0
])
:
null
const
node
=
hasValue
?
getNodeInfoById
(
value
[
0
])
:
null
...
...
web/app/components/workflow/nodes/code/panel.tsx
View file @
14d71fb5
...
@@ -64,6 +64,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
...
@@ -64,6 +64,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
>
>
<
VarList
<
VarList
readonly=
{
readOnly
}
readonly=
{
readOnly
}
nodeId=
{
id
}
list=
{
inputs
.
variables
}
list=
{
inputs
.
variables
}
onChange=
{
handleVarListChange
}
onChange=
{
handleVarListChange
}
/>
/>
...
...
web/app/components/workflow/nodes/end/panel.tsx
View file @
14d71fb5
...
@@ -80,6 +80,7 @@ const Panel: FC<NodePanelProps<EndNodeType>> = ({
...
@@ -80,6 +80,7 @@ const Panel: FC<NodePanelProps<EndNodeType>> = ({
===
EndVarType
.
structured
===
EndVarType
.
structured
?
(
?
(
<
VarList
<
VarList
nodeId=
{
id
}
readonly=
{
readOnly
}
readonly=
{
readOnly
}
list=
{
outputs
.
structured_variables
!
}
list=
{
outputs
.
structured_variables
!
}
onChange=
{
handleVarListChange
}
onChange=
{
handleVarListChange
}
...
@@ -88,6 +89,7 @@ const Panel: FC<NodePanelProps<EndNodeType>> = ({
...
@@ -88,6 +89,7 @@ const Panel: FC<NodePanelProps<EndNodeType>> = ({
:
(
:
(
<
VarReferencePicker
<
VarReferencePicker
isShowNodeName
isShowNodeName
nodeId=
{
id
}
readonly=
{
readOnly
}
readonly=
{
readOnly
}
value=
{
outputs
.
plain_text_selector
!
}
value=
{
outputs
.
plain_text_selector
!
}
onChange=
{
handelPlainTextSelectorChange
}
onChange=
{
handelPlainTextSelectorChange
}
...
...
web/app/components/workflow/nodes/if-else/components/condition-item.tsx
View file @
14d71fb5
...
@@ -65,6 +65,7 @@ const getOperators = (type: string) => {
...
@@ -65,6 +65,7 @@ const getOperators = (type: string) => {
type
ItemProps
=
{
type
ItemProps
=
{
readonly
:
boolean
readonly
:
boolean
nodeId
:
string
payload
:
Condition
payload
:
Condition
onChange
:
(
newItem
:
Condition
)
=>
void
onChange
:
(
newItem
:
Condition
)
=>
void
canRemove
:
boolean
canRemove
:
boolean
...
@@ -76,6 +77,7 @@ type ItemProps = {
...
@@ -76,6 +77,7 @@ type ItemProps = {
const
Item
:
FC
<
ItemProps
>
=
({
const
Item
:
FC
<
ItemProps
>
=
({
readonly
,
readonly
,
nodeId
,
payload
,
payload
,
onChange
,
onChange
,
canRemove
,
canRemove
,
...
@@ -132,6 +134,7 @@ const Item: FC<ItemProps> = ({
...
@@ -132,6 +134,7 @@ const Item: FC<ItemProps> = ({
<
div
className=
'flex items-center space-x-1'
>
<
div
className=
'flex items-center space-x-1'
>
<
VarReferencePicker
<
VarReferencePicker
nodeId=
{
nodeId
}
readonly=
{
readonly
}
readonly=
{
readonly
}
isShowNodeName
isShowNodeName
className=
'grow'
className=
'grow'
...
...
web/app/components/workflow/nodes/if-else/components/condition-list.tsx
View file @
14d71fb5
...
@@ -7,6 +7,7 @@ import Item from './condition-item'
...
@@ -7,6 +7,7 @@ import Item from './condition-item'
import
type
{
Condition
,
LogicalOperator
}
from
'@/app/components/workflow/nodes/if-else/types'
import
type
{
Condition
,
LogicalOperator
}
from
'@/app/components/workflow/nodes/if-else/types'
type
Props
=
{
type
Props
=
{
nodeId
:
string
className
?:
string
className
?:
string
readonly
:
boolean
readonly
:
boolean
list
:
Condition
[]
list
:
Condition
[]
...
@@ -18,6 +19,7 @@ type Props = {
...
@@ -18,6 +19,7 @@ type Props = {
const
ConditionList
:
FC
<
Props
>
=
({
const
ConditionList
:
FC
<
Props
>
=
({
className
,
className
,
readonly
,
readonly
,
nodeId
,
list
,
list
,
onChange
,
onChange
,
logicalOperator
,
logicalOperator
,
...
@@ -50,6 +52,7 @@ const ConditionList: FC<Props> = ({
...
@@ -50,6 +52,7 @@ const ConditionList: FC<Props> = ({
<
div
className=
{
cn
(
className
,
'space-y-2'
)
}
>
<
div
className=
{
cn
(
className
,
'space-y-2'
)
}
>
<
Item
<
Item
readonly=
{
readonly
}
readonly=
{
readonly
}
nodeId=
{
nodeId
}
payload=
{
list
[
0
]
}
payload=
{
list
[
0
]
}
onChange=
{
handleItemChange
(
0
)
}
onChange=
{
handleItemChange
(
0
)
}
canRemove=
{
canRemove
}
canRemove=
{
canRemove
}
...
@@ -63,6 +66,7 @@ const ConditionList: FC<Props> = ({
...
@@ -63,6 +66,7 @@ const ConditionList: FC<Props> = ({
<
Item
<
Item
key=
{
item
.
id
}
key=
{
item
.
id
}
readonly=
{
readonly
}
readonly=
{
readonly
}
nodeId=
{
nodeId
}
payload=
{
item
}
payload=
{
item
}
onChange=
{
handleItemChange
(
i
+
1
)
}
onChange=
{
handleItemChange
(
i
+
1
)
}
canRemove=
{
canRemove
}
canRemove=
{
canRemove
}
...
...
web/app/components/workflow/nodes/if-else/panel.tsx
View file @
14d71fb5
...
@@ -33,6 +33,7 @@ const Panel: FC<NodePanelProps<IfElseNodeType>> = ({
...
@@ -33,6 +33,7 @@ const Panel: FC<NodePanelProps<IfElseNodeType>> = ({
<
ConditionList
<
ConditionList
className=
'mt-2'
className=
'mt-2'
readonly=
{
readOnly
}
readonly=
{
readOnly
}
nodeId=
{
id
}
list=
{
inputs
.
conditions
}
list=
{
inputs
.
conditions
}
onChange=
{
handleConditionsChange
}
onChange=
{
handleConditionsChange
}
logicalOperator=
{
inputs
.
logical_operator
}
logicalOperator=
{
inputs
.
logical_operator
}
...
...
web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx
View file @
14d71fb5
...
@@ -45,6 +45,7 @@ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
...
@@ -45,6 +45,7 @@ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
title=
{
t
(
`${i18nPrefix}.queryVariable`
)
}
title=
{
t
(
`${i18nPrefix}.queryVariable`
)
}
>
>
<
VarReferencePicker
<
VarReferencePicker
nodeId=
{
id
}
readonly=
{
readOnly
}
readonly=
{
readOnly
}
isShowNodeName
isShowNodeName
value=
{
inputs
.
query_variable_selector
}
value=
{
inputs
.
query_variable_selector
}
...
...
web/app/components/workflow/nodes/llm/panel.tsx
View file @
14d71fb5
...
@@ -134,6 +134,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
...
@@ -134,6 +134,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
>
>
<
VarList
<
VarList
readonly=
{
readOnly
}
readonly=
{
readOnly
}
nodeId=
{
id
}
list=
{
inputs
.
variables
}
list=
{
inputs
.
variables
}
onChange=
{
handleVarListChange
}
onChange=
{
handleVarListChange
}
/>
/>
...
@@ -146,6 +147,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
...
@@ -146,6 +147,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
>
>
<
VarReferencePicker
<
VarReferencePicker
readonly=
{
readOnly
}
readonly=
{
readOnly
}
nodeId=
{
id
}
isShowNodeName
isShowNodeName
value=
{
inputs
.
context
?.
variable_selector
||
[]
}
value=
{
inputs
.
context
?.
variable_selector
||
[]
}
onChange=
{
handleContextVarChange
}
onChange=
{
handleContextVarChange
}
...
...
web/app/components/workflow/nodes/question-classifier/panel.tsx
View file @
14d71fb5
...
@@ -48,6 +48,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
...
@@ -48,6 +48,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
<
VarReferencePicker
<
VarReferencePicker
readonly=
{
readOnly
}
readonly=
{
readOnly
}
isShowNodeName
isShowNodeName
nodeId=
{
id
}
value=
{
inputs
.
query_variable_selector
}
value=
{
inputs
.
query_variable_selector
}
onChange=
{
handleQueryVarChange
}
onChange=
{
handleQueryVarChange
}
/>
/>
...
...
web/app/components/workflow/nodes/tool/components/input-var-list.tsx
View file @
14d71fb5
...
@@ -11,6 +11,7 @@ import VarReferencePicker from '@/app/components/workflow/nodes/_base/components
...
@@ -11,6 +11,7 @@ import VarReferencePicker from '@/app/components/workflow/nodes/_base/components
type
Props
=
{
type
Props
=
{
readOnly
:
boolean
readOnly
:
boolean
nodeId
:
string
schema
:
CredentialFormSchema
[]
schema
:
CredentialFormSchema
[]
value
:
ToolVarInput
[]
value
:
ToolVarInput
[]
onChange
:
(
value
:
ToolVarInput
[])
=>
void
onChange
:
(
value
:
ToolVarInput
[])
=>
void
...
@@ -18,6 +19,7 @@ type Props = {
...
@@ -18,6 +19,7 @@ type Props = {
const
InputVarList
:
FC
<
Props
>
=
({
const
InputVarList
:
FC
<
Props
>
=
({
readOnly
,
readOnly
,
nodeId
,
schema
,
schema
,
value
,
value
,
onChange
,
onChange
,
...
@@ -72,6 +74,7 @@ const InputVarList: FC<Props> = ({
...
@@ -72,6 +74,7 @@ const InputVarList: FC<Props> = ({
<
VarReferencePicker
<
VarReferencePicker
readonly=
{
readOnly
}
readonly=
{
readOnly
}
isShowNodeName
isShowNodeName
nodeId=
{
nodeId
}
value=
{
varInput
?.
value_selector
||
[]
}
// TODO: support constant value
value=
{
varInput
?.
value_selector
||
[]
}
// TODO: support constant value
onChange=
{
handleChange
(
variable
)
}
onChange=
{
handleChange
(
variable
)
}
/>
/>
...
...
web/app/components/workflow/nodes/tool/panel.tsx
View file @
14d71fb5
...
@@ -73,6 +73,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
...
@@ -73,6 +73,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
>
>
<
InputVarList
<
InputVarList
readOnly=
{
readOnly
}
readOnly=
{
readOnly
}
nodeId=
{
id
}
schema=
{
toolInputVarSchema
as
any
}
schema=
{
toolInputVarSchema
as
any
}
value=
{
inputs
.
tool_inputs
}
value=
{
inputs
.
tool_inputs
}
onChange=
{
setInputVar
}
onChange=
{
setInputVar
}
...
...
web/app/components/workflow/nodes/variable-assigner/components/var-list/index.tsx
View file @
14d71fb5
...
@@ -9,12 +9,14 @@ import type { ValueSelector } from '@/app/components/workflow/types'
...
@@ -9,12 +9,14 @@ import type { ValueSelector } from '@/app/components/workflow/types'
type
Props
=
{
type
Props
=
{
readonly
:
boolean
readonly
:
boolean
nodeId
:
string
list
:
ValueSelector
[]
list
:
ValueSelector
[]
onChange
:
(
list
:
ValueSelector
[])
=>
void
onChange
:
(
list
:
ValueSelector
[])
=>
void
}
}
const
VarList
:
FC
<
Props
>
=
({
const
VarList
:
FC
<
Props
>
=
({
readonly
,
readonly
,
nodeId
,
list
,
list
,
onChange
,
onChange
,
})
=>
{
})
=>
{
...
@@ -51,6 +53,7 @@ const VarList: FC<Props> = ({
...
@@ -51,6 +53,7 @@ const VarList: FC<Props> = ({
<
div
className=
'flex items-center space-x-1'
key=
{
index
}
>
<
div
className=
'flex items-center space-x-1'
key=
{
index
}
>
<
VarReferencePicker
<
VarReferencePicker
readonly=
{
readonly
}
readonly=
{
readonly
}
nodeId=
{
nodeId
}
isShowNodeName
isShowNodeName
className=
'grow'
className=
'grow'
value=
{
item
}
value=
{
item
}
...
...
web/app/components/workflow/nodes/variable-assigner/panel.tsx
View file @
14d71fb5
...
@@ -61,6 +61,7 @@ const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
...
@@ -61,6 +61,7 @@ const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
>
>
<
VarList
<
VarList
readonly=
{
readOnly
}
readonly=
{
readOnly
}
nodeId=
{
id
}
list=
{
inputs
.
variables
}
list=
{
inputs
.
variables
}
onChange=
{
handleVarListChange
}
onChange=
{
handleVarListChange
}
/>
/>
...
...
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