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
bb87a350
Commit
bb87a350
authored
Feb 20, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: question classify panel
parent
c441a848
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletion
+68
-1
panel.tsx
...p/components/workflow/nodes/question-classifier/panel.tsx
+36
-1
use-config.ts
...mponents/workflow/nodes/question-classifier/use-config.ts
+32
-0
No files found.
web/app/components/workflow/nodes/question-classifier/panel.tsx
View file @
bb87a350
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
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.llm'
const
Panel
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
// const readOnly = false
const
{
inputs
,
handleModelChanged
,
handleCompletionParamsChange
,
}
=
useConfig
(
mockData
)
const
model
=
inputs
.
model
return
(
<
div
>
start panel inputs
</
div
>
<
div
className=
'mt-2 px-4 space-y-4'
>
<
Field
title=
{
t
(
`${i18nPrefix}.model`
)
}
>
<
ModelParameterModal
popupClassName=
'!w-[387px]'
isAdvancedMode=
{
true
}
mode=
{
model
?.
mode
}
provider=
{
model
?.
provider
}
completionParams=
{
model
.
completion_params
}
modelId=
{
model
.
name
}
setModel=
{
handleModelChanged
}
onCompletionParamsChange=
{
handleCompletionParamsChange
}
hideDebugWithMultipleModel
debugWithMultipleModel=
{
false
}
/>
</
Field
>
</
div
>
)
}
...
...
web/app/components/workflow/nodes/question-classifier/use-config.ts
0 → 100644
View file @
bb87a350
import
{
useCallback
,
useState
}
from
'react'
import
produce
from
'immer'
import
type
{
QuestionClassifierNodeType
}
from
'./types'
const
useConfig
=
(
initInputs
:
QuestionClassifierNodeType
)
=>
{
const
[
inputs
,
setInputs
]
=
useState
<
QuestionClassifierNodeType
>
(
initInputs
)
// model
const
handleModelChanged
=
useCallback
((
model
:
{
provider
:
string
;
modelId
:
string
;
mode
?:
string
})
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
model
.
provider
=
model
.
provider
draft
.
model
.
name
=
model
.
modelId
draft
.
model
.
mode
=
model
.
mode
!
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
const
handleCompletionParamsChange
=
useCallback
((
newParams
:
Record
<
string
,
any
>
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
model
.
completion_params
=
newParams
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
return
{
inputs
,
handleModelChanged
,
handleCompletionParamsChange
,
}
}
export
default
useConfig
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