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
e65a2a40
Unverified
Commit
e65a2a40
authored
Jan 23, 2024
by
zxhlyh
Committed by
GitHub
Jan 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: model-parameter-modal slider (#2135)
parent
741079f3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
index.tsx
...tting/model-provider-page/model-parameter-modal/index.tsx
+14
-8
parameter-item.tsx
...el-provider-page/model-parameter-modal/parameter-item.tsx
+6
-0
No files found.
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx
View file @
e65a2a40
...
...
@@ -69,6 +69,8 @@ const stopParameerRule: ModelParameterRule = {
zh_Hans
:
'输入序列并按 Tab 键'
,
},
}
const
PROVIDER_WITH_PRESET_TONE
=
[
'openai'
,
'azure_openai'
]
const
ModelParameterModal
:
FC
<
ModelParameterModalProps
>
=
({
isAdvancedMode
,
modelId
,
...
...
@@ -105,10 +107,11 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
const
remvoedCustomeTone
=
TONE_LIST
.
slice
(
0
,
-
1
)
const
CUSTOM_TONE_ID
=
4
const
tone
=
remvoedCustomeTone
.
find
((
tone
)
=>
{
return
tone
.
config
?.
temperature
===
completionParams
.
temperature
&&
tone
.
config
?.
top_p
===
completionParams
.
top_p
&&
tone
.
config
?.
presence_penalty
===
completionParams
.
presence_penalty
&&
tone
.
config
?.
frequency_penalty
===
completionParams
.
frequency_penalty
const
config
:
Record
<
string
,
any
>
=
tone
.
config
||
{}
return
Object
.
keys
(
config
).
every
((
key
)
=>
{
return
config
[
key
]
===
completionParams
[
key
]
})
})
return
tone
?
tone
.
id
:
CUSTOM_TONE_ID
}
...
...
@@ -122,14 +125,11 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
})[
toneId
]
||
''
// set completionParams by toneId
const
handleToneChange
=
(
id
:
number
)
=>
{
if
(
id
===
4
)
return
// custom tone
const
tone
=
TONE_LIST
.
find
(
tone
=>
tone
.
id
===
id
)
if
(
tone
)
{
setToneId
(
id
)
onCompletionParamsChange
({
...
tone
.
config
,
max_tokens
:
completionParams
.
max_tokens
,
})
}
}
...
...
@@ -173,6 +173,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
const
handleInitialParams
=
()
=>
{
const
newCompletionParams
=
{
...
completionParams
}
const
defaultParams
:
Record
<
string
,
any
>
=
{}
if
(
parameterRules
.
length
)
{
parameterRules
.
forEach
((
parameterRule
)
=>
{
if
(
!
newCompletionParams
[
parameterRule
.
name
])
{
...
...
@@ -181,8 +182,13 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
else
delete
newCompletionParams
[
parameterRule
.
name
]
}
if
(
!
isNullOrUndefined
(
parameterRule
.
default
))
defaultParams
[
parameterRule
.
name
]
=
parameterRule
.
default
})
if
(
PROVIDER_WITH_PRESET_TONE
.
includes
(
provider
))
TONE_LIST
[
3
].
config
=
defaultParams
as
any
onCompletionParamsChange
(
newCompletionParams
)
}
}
...
...
@@ -305,7 +311,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
<
div
className=
'mt-5'
><
Loading
/></
div
>
)
}
{
[
'openai'
,
'azure_openai'
]
.
includes
(
provider
)
&&
!
isLoading
&&
!!
parameterRules
.
length
&&
(
{
PROVIDER_WITH_PRESET_TONE
.
includes
(
provider
)
&&
!
isLoading
&&
!!
parameterRules
.
length
&&
(
<
div
className=
'mt-5 mb-4'
>
<
div
className=
"mb-3 text-sm text-gray-900"
>
{
t
(
'appDebug.modelConfig.setTone'
)
}
</
div
>
<
Radio
.
Group
className=
{
cn
(
'!rounded-lg'
,
toneTabBgClassName
)
}
value=
{
toneId
}
onChange=
{
handleToneChange
}
>
...
...
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/parameter-item.tsx
View file @
e65a2a40
...
...
@@ -67,6 +67,12 @@ const ParameterItem: FC<ParameterItemProps> = ({
}
const
handleSlideChange
=
(
num
:
number
)
=>
{
if
(
!
isNullOrUndefined
(
parameterRule
.
max
)
&&
num
>
parameterRule
.
max
!
)
return
handleInputChange
(
parameterRule
.
max
)
if
(
!
isNullOrUndefined
(
parameterRule
.
min
)
&&
num
<
parameterRule
.
min
!
)
return
handleInputChange
(
parameterRule
.
min
)
handleInputChange
(
num
)
}
...
...
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