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
90c8d9d2
Commit
90c8d9d2
authored
Mar 05, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service
parent
a30b6acc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
13 deletions
+76
-13
hooks.ts
web/app/components/workflow/block-selector/hooks.ts
+13
-0
tabs.tsx
web/app/components/workflow/block-selector/tabs.tsx
+4
-2
index.tsx
web/app/components/workflow/index.tsx
+33
-11
workflow.ts
web/i18n/en-US/workflow.ts
+13
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+13
-0
No files found.
web/app/components/workflow/block-selector/hooks.ts
0 → 100644
View file @
90c8d9d2
import
{
useTranslation
}
from
'react-i18next'
import
{
BLOCKS
}
from
'./constants'
export
const
useBlocks
=
()
=>
{
const
{
t
}
=
useTranslation
()
return
BLOCKS
.
map
((
block
)
=>
{
return
{
...
block
,
title
:
t
(
`workflow.blocks.
${
block
.
type
}
`
),
}
})
}
web/app/components/workflow/block-selector/tabs.tsx
View file @
90c8d9d2
...
...
@@ -3,13 +3,14 @@ import {
memo
,
useState
,
}
from
'react'
import
{
groupBy
}
from
'lodash-es'
import
BlockIcon
from
'../block-icon'
import
type
{
BlockEnum
}
from
'../types'
import
{
BLOCK_CLASSIFICATIONS
,
BLOCK_GROUP_BY_CLASSIFICATION
,
TABS
,
}
from
'./constants'
import
{
useBlocks
}
from
'./hooks'
export
type
TabsProps
=
{
onSelect
:
(
type
:
BlockEnum
)
=>
void
...
...
@@ -18,6 +19,7 @@ const Tabs: FC<TabsProps> = ({
onSelect
,
})
=>
{
const
[
activeTab
,
setActiveTab
]
=
useState
(
TABS
[
0
].
key
)
const
blocks
=
useBlocks
()
return
(
<
div
>
...
...
@@ -52,7 +54,7 @@ const Tabs: FC<TabsProps> = ({
)
}
{
BLOCK_GROUP_BY_CLASSIFICATION
[
classification
].
map
(
block
=>
(
groupBy
(
blocks
,
'classification'
)
[
classification
].
map
(
block
=>
(
<
div
key=
{
block
.
type
}
className=
'flex items-center px-3 h-8 rounded-lg hover:bg-gray-50 cursor-pointer'
...
...
web/app/components/workflow/index.tsx
View file @
90c8d9d2
import
type
{
FC
}
from
'react'
import
{
memo
,
useMemo
,
}
from
'react'
import
{
useParams
}
from
'next/navigation'
import
useSWR
from
'swr'
...
...
@@ -112,21 +113,42 @@ const WorkflowWrap: FC<WorkflowProps> = ({
edges
,
})
=>
{
const
appId
=
useParams
().
appId
const
{
isLoading
,
error
}
=
useSWR
(
`/apps/
${
appId
}
/workflows/draft`
,
fetchWorkflowDraft
)
const
{
data
,
isLoading
,
error
}
=
useSWR
(
`/apps/
${
appId
}
/workflows/draft`
,
fetchWorkflowDraft
)
const
startNode
=
{
id
:
`
${
Date
.
now
()}
`
,
data
:
NodeInitialData
.
start
,
position
:
{
x
:
100
,
y
:
100
,
},
}
const
nodesData
=
useMemo
(()
=>
{
if
(
nodes
)
return
nodes
if
(
data
)
return
data
.
graph
.
nodes
return
[
startNode
]
},
[
data
,
nodes
])
const
edgesData
=
useMemo
(()
=>
{
if
(
edges
)
return
edges
if
(
data
)
return
data
.
graph
.
edges
return
[]
},
[
data
,
nodes
])
if
(
error
)
{
syncWorkflowDraft
({
url
:
`/apps/
${
appId
}
/workflows/draft`
,
params
:
{
graph
:
{
nodes
:
[{
id
:
`
${
Date
.
now
()}
`
,
data
:
NodeInitialData
.
start
,
position
:
{
x
:
100
,
y
:
100
,
},
}],
nodes
:
[
startNode
],
edges
:
[],
},
features
:
{},
...
...
@@ -144,8 +166,8 @@ const WorkflowWrap: FC<WorkflowProps> = ({
<
ReactFlowProvider
>
<
FeaturesProvider
>
<
Workflow
nodes=
{
nodes
}
edges=
{
edges
}
nodes=
{
nodes
Data
}
edges=
{
edges
Data
}
/>
</
FeaturesProvider
>
</
ReactFlowProvider
>
...
...
web/i18n/en-US/workflow.ts
View file @
90c8d9d2
const
translation
=
{
blocks
:
{
'start'
:
'Start'
,
'end'
:
'End'
,
'direct-answer'
:
'Direct Answer'
,
'llm'
:
'LLM'
,
'knowledge-retrieval'
:
'Knowledge Retrieval'
,
'question-classifier'
:
'Question Classifier'
,
'if-else'
:
'IF/ELSE'
,
'code'
:
'Code'
,
'template-transform'
:
'Templating Transform'
,
'http-request'
:
'HTTP Request'
,
'variable-assigner'
:
'Variable Assigner'
,
},
nodes
:
{
common
:
{
outputVars
:
'Output Variables'
,
...
...
web/i18n/zh-Hans/workflow.ts
View file @
90c8d9d2
const
translation
=
{
blocks
:
{
'start'
:
'开始'
,
'end'
:
'结束'
,
'direct-answer'
:
'直接回答'
,
'llm'
:
'LLM'
,
'knowledge-retrieval'
:
'知识检索'
,
'question-classifier'
:
'问题分类器'
,
'if-else'
:
'条件分支'
,
'code'
:
'代码'
,
'template-transform'
:
'模板转换'
,
'http-request'
:
'HTTP 请求'
,
'variable-assigner'
:
'变量赋值'
,
},
nodes
:
{
common
:
{
outputVars
:
'输出变量'
,
...
...
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