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
783f7a9b
Commit
783f7a9b
authored
Mar 07, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: question classifer support run
parent
425e162a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
45 deletions
+109
-45
panel.tsx
...p/components/workflow/nodes/question-classifier/panel.tsx
+76
-45
use-config.ts
...mponents/workflow/nodes/question-classifier/use-config.ts
+33
-0
No files found.
web/app/components/workflow/nodes/question-classifier/panel.tsx
View file @
783f7a9b
...
...
@@ -8,7 +8,8 @@ import AdvancedSetting from './components/advanced-setting'
import
type
{
QuestionClassifierNodeType
}
from
'./types'
import
Field
from
'@/app/components/workflow/nodes/_base/components/field'
import
ModelParameterModal
from
'@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import
type
{
NodePanelProps
}
from
'@/app/components/workflow/types'
import
{
InputVarType
,
type
NodePanelProps
}
from
'@/app/components/workflow/types'
import
BeforeRunForm
from
'@/app/components/workflow/nodes/_base/components/before-run-form'
const
i18nPrefix
=
'workflow.nodes.questionClassifiers'
...
...
@@ -27,11 +28,19 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
handleTopicsChange
,
handleInstructionChange
,
handleMemoryChange
,
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
handleRun
,
handleStop
,
query
,
setQuery
,
}
=
useConfig
(
id
,
data
)
const
model
=
inputs
.
model
return
(
<
div
>
<
div
className=
'mt-2 px-4 space-y-4'
>
<
Field
title=
{
t
(
`${i18nPrefix}.inputVars`
)
}
...
...
@@ -78,6 +87,28 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
/>
</
Field
>
</
div
>
{
isShowSingleRun
&&
(
<
BeforeRunForm
nodeName=
{
inputs
.
title
}
onHide=
{
hideSingleRun
}
forms=
{
[
{
inputs
:
[{
label
:
t
(
`${i18nPrefix}.inputVars`
)
!
,
variable
:
'query'
,
type
:
InputVarType
.
paragraph
,
required
:
true
,
}],
values
:
{
query
},
onChange
:
keyValue
=>
setQuery
((
keyValue
as
any
).
query
),
},
]
}
runningStatus=
{
runningStatus
}
onRun=
{
handleRun
}
onStop=
{
handleStop
}
/>
)
}
</
div
>
)
}
...
...
web/app/components/workflow/nodes/question-classifier/use-config.ts
View file @
783f7a9b
...
...
@@ -3,6 +3,7 @@ import produce from 'immer'
import
type
{
Memory
,
ValueSelector
}
from
'../../types'
import
type
{
QuestionClassifierNodeType
}
from
'./types'
import
useNodeCrud
from
'@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import
useOneStepRun
from
'@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
const
useConfig
=
(
id
:
string
,
payload
:
QuestionClassifierNodeType
)
=>
{
const
{
inputs
,
setInputs
}
=
useNodeCrud
<
QuestionClassifierNodeType
>
(
id
,
payload
)
...
...
@@ -52,6 +53,31 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => {
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
// single run
const
{
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
handleRun
,
handleStop
,
runInputData
,
setRunInputData
,
}
=
useOneStepRun
<
QuestionClassifierNodeType
>
({
id
,
data
:
inputs
,
defaultRunInputData
:
{
query
:
'Negative or positive sentiment?'
,
},
})
const
query
=
runInputData
.
query
const
setQuery
=
useCallback
((
newQuery
:
string
)
=>
{
setRunInputData
({
...
runInputData
,
query
:
newQuery
,
})
},
[
runInputData
,
setRunInputData
])
return
{
inputs
,
handleModelChanged
,
...
...
@@ -60,6 +86,13 @@ const useConfig = (id: string, payload: QuestionClassifierNodeType) => {
handleTopicsChange
:
handleClassesChange
,
handleInstructionChange
,
handleMemoryChange
,
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
handleRun
,
handleStop
,
query
,
setQuery
,
}
}
...
...
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