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
072f5caa
Commit
072f5caa
authored
Mar 07, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
783f7a9b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
26 deletions
+44
-26
custom-connection-line.tsx
web/app/components/workflow/custom-connection-line.tsx
+1
-1
index.tsx
web/app/components/workflow/index.tsx
+32
-21
item.tsx
...onents/workflow/nodes/_base/components/next-step/item.tsx
+4
-2
utils.ts
web/app/components/workflow/utils.ts
+4
-1
workflow.ts
web/i18n/en-US/workflow.ts
+1
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+2
-1
No files found.
web/app/components/workflow/custom-connection-line.tsx
View file @
072f5caa
...
...
@@ -26,7 +26,7 @@ const CustomConnectionLine = ({ fromX, fromY, toX, toY }: ConnectionLineComponen
d=
{
edgePath
}
/>
<
rect
x=
{
toX
-
2
}
x=
{
toX
}
y=
{
toY
-
4
}
width=
{
2
}
height=
{
8
}
...
...
web/app/components/workflow/index.tsx
View file @
072f5caa
...
...
@@ -138,15 +138,17 @@ const WorkflowWrap: FC<WorkflowProps> = ({
useStore
.
setState
({
draftUpdatedAt
:
data
.
updated_at
})
},
[
data
])
const
startNode
=
{
id
:
`
${
Date
.
now
()}
`
,
type
:
'custom'
,
data
:
nodesInitialData
.
start
,
position
:
{
x
:
100
,
y
:
100
,
},
}
const
startNode
=
useMemo
(()
=>
{
return
{
id
:
`
${
Date
.
now
()}
`
,
type
:
'custom'
,
data
:
nodesInitialData
.
start
,
position
:
{
x
:
100
,
y
:
100
,
},
}
},
[
nodesInitialData
])
const
nodesData
=
useMemo
(()
=>
{
if
(
nodes
)
...
...
@@ -156,7 +158,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
return
data
.
graph
.
nodes
return
[
startNode
]
},
[
data
,
nodes
])
},
[
data
,
nodes
,
startNode
])
const
edgesData
=
useMemo
(()
=>
{
if
(
edges
)
return
edges
...
...
@@ -165,7 +167,7 @@ const WorkflowWrap: FC<WorkflowProps> = ({
return
data
.
graph
.
edges
return
[]
},
[
data
,
nod
es
])
},
[
data
,
edg
es
])
const
handleFetchCollectionList
=
async
()
=>
{
const
toolsets
=
await
fetchCollectionList
()
...
...
@@ -183,16 +185,22 @@ const WorkflowWrap: FC<WorkflowProps> = ({
handleFetchCollectionList
()
},
[])
if
(
error
&&
appDetail
)
{
syncWorkflowDraft
({
url
:
`/apps/
${
appDetail
.
id
}
/workflows/draft`
,
params
:
{
graph
:
{
nodes
:
[
startNode
],
edges
:
[],
},
features
:
{},
},
if
(
error
&&
!
error
.
bodyUsed
&&
appDetail
)
{
error
.
json
().
then
((
err
:
any
)
=>
{
if
(
err
.
code
===
'draft_workflow_not_exist'
)
{
syncWorkflowDraft
({
url
:
`/apps/
${
appDetail
.
id
}
/workflows/draft`
,
params
:
{
graph
:
{
nodes
:
[
startNode
],
edges
:
[],
},
features
:
{},
},
}).
then
((
res
)
=>
{
useStore
.
setState
({
draftUpdatedAt
:
res
.
updated_at
})
})
}
})
}
...
...
@@ -204,6 +212,9 @@ const WorkflowWrap: FC<WorkflowProps> = ({
)
}
if
(
!
data
)
return
null
const
features
=
data
?.
features
||
{}
const
initialFeatures
:
FeaturesData
=
{
opening
:
{
...
...
web/app/components/workflow/nodes/_base/components/next-step/item.tsx
View file @
072f5caa
...
...
@@ -2,6 +2,7 @@ import {
memo
,
useCallback
,
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
type
{
CommonNodeType
,
OnSelectBlock
,
...
...
@@ -23,6 +24,7 @@ const Item = ({
branchName
,
data
,
}:
ItemProps
)
=>
{
const
{
t
}
=
useTranslation
()
const
{
handleNodeChange
}
=
useWorkflow
()
const
handleSelect
=
useCallback
<
OnSelectBlock
>
((
type
,
toolDefaultValue
)
=>
{
handleNodeChange
(
nodeId
,
type
,
sourceHandle
,
toolDefaultValue
)
...
...
@@ -35,10 +37,10 @@ const Item = ({
${open && '!bg-gray-100 !flex'}
`
}
>
Change
{
t
(
'workflow.panel.change'
)
}
</
Button
>
)
},
[])
},
[
t
])
return
(
<
div
...
...
web/app/components/workflow/utils.ts
View file @
072f5caa
...
...
@@ -144,10 +144,13 @@ export const getLayoutByDagre = (nodes: Node[], edges: Edge[]) => {
export
const
canRunBySingle
=
(
nodeType
:
BlockEnum
)
=>
{
return
nodeType
===
BlockEnum
.
LLM
||
nodeType
===
BlockEnum
.
KnowledgeRetrieval
||
nodeType
===
BlockEnum
.
IfElse
||
nodeType
===
BlockEnum
.
Code
||
nodeType
===
BlockEnum
.
TemplateTransform
||
nodeType
===
BlockEnum
.
QuestionClassifier
||
nodeType
===
BlockEnum
.
HttpRequest
||
nodeType
===
BlockEnum
.
Tool
}
export
const
getVariables
=
()
=>
{
}
web/i18n/en-US/workflow.ts
View file @
072f5caa
...
...
@@ -70,6 +70,7 @@ const translation = {
checklist
:
'Checklist'
,
checklistTip
:
'Make sure all issues are resolved before publishing'
,
organizeBlocks
:
'Organize blocks'
,
change
:
'Change'
,
},
nodes
:
{
common
:
{
...
...
web/i18n/zh-Hans/workflow.ts
View file @
072f5caa
...
...
@@ -40,7 +40,7 @@ const translation = {
blocks
:
{
'start'
:
'开始'
,
'end'
:
'结束'
,
'direct-answer'
:
'直接回
答
'
,
'direct-answer'
:
'直接回
复
'
,
'llm'
:
'LLM'
,
'knowledge-retrieval'
:
'知识检索'
,
'question-classifier'
:
'问题分类器'
,
...
...
@@ -70,6 +70,7 @@ const translation = {
checklist
:
'检查清单'
,
checklistTip
:
'发布前确保所有问题均已解决'
,
organizeBlocks
:
'整理节点'
,
change
:
'更改'
,
},
nodes
:
{
common
:
{
...
...
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