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
fbcc769d
Commit
fbcc769d
authored
Feb 29, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: instructions
parent
65f0378e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
5 deletions
+63
-5
base.tsx
...omponents/workflow/nodes/_base/components/editor/base.tsx
+1
-1
text-editor.tsx
...ts/workflow/nodes/_base/components/editor/text-editor.tsx
+1
-1
advanced-setting.tsx
...nodes/question-classifier/components/advanced-setting.tsx
+41
-0
class-list.tsx
...kflow/nodes/question-classifier/components/class-list.tsx
+1
-1
panel.tsx
...p/components/workflow/nodes/question-classifier/panel.tsx
+7
-2
use-config.ts
...mponents/workflow/nodes/question-classifier/use-config.ts
+8
-0
workflow.ts
web/i18n/en-US/workflow.ts
+2
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+2
-0
No files found.
web/app/components/workflow/nodes/_base/components/editor/base.tsx
View file @
fbcc769d
...
...
@@ -8,7 +8,7 @@ import { Clipboard, ClipboardCheck } from '@/app/components/base/icons/src/vende
import
{
Expand04
}
from
'@/app/components/base/icons/src/vender/solid/arrows'
type
Props
=
{
className
?:
string
title
:
JSX
.
Element
title
:
JSX
.
Element
|
string
headerRight
?:
JSX
.
Element
children
:
JSX
.
Element
minHeight
?:
number
...
...
web/app/components/workflow/nodes/_base/components/editor/text-editor.tsx
View file @
fbcc769d
...
...
@@ -7,7 +7,7 @@ import Base from './base'
type
Props
=
{
value
:
string
onChange
:
(
value
:
string
)
=>
void
title
:
JSX
.
Element
title
:
JSX
.
Element
|
string
headerRight
?:
JSX
.
Element
minHeight
?:
number
onBlur
?:
()
=>
void
...
...
web/app/components/workflow/nodes/question-classifier/components/advanced-setting.tsx
0 → 100644
View file @
fbcc769d
'use client'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
TextEditor
from
'../../_base/components/editor/text-editor'
import
type
{
Memory
}
from
'@/app/components/workflow/types'
const
i18nPrefix
=
'workflow.nodes.questionClassifiers'
type
Props
=
{
instruction
:
string
onInstructionChange
:
(
instruction
:
string
)
=>
void
memory
:
Memory
}
const
AdvancedSetting
:
FC
<
Props
>
=
({
instruction
,
onInstructionChange
,
memory
,
})
=>
{
const
{
t
}
=
useTranslation
()
return
(
<
div
>
<
TextEditor
title=
{
t
(
`${i18nPrefix}.instruction`
)
!
}
value=
{
instruction
}
onChange=
{
onInstructionChange
}
minHeight=
{
160
}
placeholder=
{
t
(
`${i18nPrefix}.instructionPlaceholder`
)
!
}
headerRight=
{
(
<
div
className=
'flex items-center h-full'
>
<
div
className=
'text-xs font-medium text-gray-500'
>
{
instruction
.
length
}
</
div
>
<
div
className=
'mx-3 h-3 w-px bg-gray-200'
></
div
>
</
div
>
)
}
/>
</
div
>
)
}
export
default
React
.
memo
(
AdvancedSetting
)
web/app/components/workflow/nodes/question-classifier/components/class-list.tsx
View file @
fbcc769d
...
...
@@ -34,7 +34,7 @@ const ClassList: FC<Props> = ({
draft
.
push
({
id
:
''
,
name
:
t
(
`
${
i18nPrefix
}
.class`
)
+
(
list
.
length
+
1
),
topic
:
''
})
})
onChange
(
newList
)
},
[
list
,
onChange
])
},
[
list
,
onChange
,
t
])
const
handleRemoveClass
=
useCallback
((
index
:
number
)
=>
{
return
()
=>
{
...
...
web/app/components/workflow/nodes/question-classifier/panel.tsx
View file @
fbcc769d
...
...
@@ -4,9 +4,9 @@ import VarReferencePicker from '../_base/components/variable/var-reference-picke
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
import
ClassList
from
'./components/class-list'
import
AdvancedSetting
from
'./components/advanced-setting'
import
Field
from
'@/app/components/workflow/nodes/_base/components/field'
import
ModelParameterModal
from
'@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
const
i18nPrefix
=
'workflow.nodes.questionClassifiers'
const
Panel
:
FC
=
()
=>
{
...
...
@@ -19,6 +19,7 @@ const Panel: FC = () => {
handleCompletionParamsChange
,
handleQueryVarChange
,
handleTopicsChange
,
handleInstructionChange
,
}
=
useConfig
(
mockData
)
const
model
=
inputs
.
model
...
...
@@ -60,7 +61,11 @@ const Panel: FC = () => {
<
Field
title=
{
t
(
`${i18nPrefix}.advancedSetting`
)
}
>
advancedSetting
<
AdvancedSetting
instruction=
{
inputs
.
instruction
}
onInstructionChange=
{
handleInstructionChange
}
memory=
{
inputs
.
memory
}
/>
</
Field
>
</
div
>
)
...
...
web/app/components/workflow/nodes/question-classifier/use-config.ts
View file @
fbcc769d
...
...
@@ -37,12 +37,20 @@ const useConfig = (initInputs: QuestionClassifierNodeType) => {
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
const
handleInstructionChange
=
useCallback
((
instruction
:
string
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
instruction
=
instruction
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
return
{
inputs
,
handleModelChanged
,
handleCompletionParamsChange
,
handleQueryVarChange
,
handleTopicsChange
,
handleInstructionChange
,
}
}
...
...
web/i18n/en-US/workflow.ts
View file @
fbcc769d
...
...
@@ -133,6 +133,8 @@ const translation = {
advancedSetting
:
'Advanced Setting'
,
topicPlaceholder
:
'Write your topic name'
,
addClass
:
'Add Class'
,
instruction
:
'Instruction'
,
instructionPlaceholder
:
'Write your instruction'
,
},
},
}
...
...
web/i18n/zh-Hans/workflow.ts
View file @
fbcc769d
...
...
@@ -132,6 +132,8 @@ const translation = {
advancedSetting
:
'高级设置'
,
topicPlaceholder
:
'在这里输入你的主题内容'
,
addClass
:
'添加分类'
,
instruction
:
'指令'
,
instructionPlaceholder
:
'在这里输入你的指令'
,
},
},
}
...
...
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