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
6409b2e6
Commit
6409b2e6
authored
Jul 14, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support model changed provider changed
parent
bb7a02c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
index.tsx
web/app/components/app/configuration/config-model/index.tsx
+8
-8
index.tsx
web/app/components/app/configuration/index.tsx
+4
-2
No files found.
web/app/components/app/configuration/config-model/index.tsx
View file @
6409b2e6
...
@@ -17,7 +17,7 @@ import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/aler
...
@@ -17,7 +17,7 @@ import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/aler
export
type
IConifgModelProps
=
{
export
type
IConifgModelProps
=
{
mode
:
string
mode
:
string
modelId
:
string
modelId
:
string
setModelId
:
(
id
:
string
)
=>
void
setModelId
:
(
id
:
string
,
provider
:
ProviderType
)
=>
void
completionParams
:
CompletionParams
completionParams
:
CompletionParams
onCompletionParamsChange
:
(
newParams
:
CompletionParams
)
=>
void
onCompletionParamsChange
:
(
newParams
:
CompletionParams
)
=>
void
disabled
:
boolean
disabled
:
boolean
...
@@ -29,14 +29,14 @@ const options = [
...
@@ -29,14 +29,14 @@ const options = [
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
chat
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
chat
},
// 8k version
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
chat
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
chat
,
provide
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
chat
,
provide
r
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
chat
,
provide
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
chat
,
provide
r
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-3.5-turbo'
,
name
:
'gpt-3.5-turbo'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-3.5-turbo-16k'
,
name
:
'gpt-3.5-turbo-16k'
,
type
:
AppType
.
completion
},
{
id
:
'text-davinci-003'
,
name
:
'text-davinci-003'
,
type
:
AppType
.
completion
},
{
id
:
'text-davinci-003'
,
name
:
'text-davinci-003'
,
type
:
AppType
.
completion
},
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
completion
},
// 8k version
{
id
:
'gpt-4'
,
name
:
'gpt-4'
,
type
:
AppType
.
completion
},
// 8k version
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
completion
,
provide
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-instant-1'
,
name
:
'claude-instant-1'
,
type
:
AppType
.
completion
,
provide
r
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
completion
,
provide
:
ProviderType
.
anthropic
},
// set 30k
{
id
:
'claude-2'
,
name
:
'claude-2'
,
type
:
AppType
.
completion
,
provide
r
:
ProviderType
.
anthropic
},
// set 30k
]
]
const
getMaxToken
=
(
modelId
:
string
)
=>
{
const
getMaxToken
=
(
modelId
:
string
)
=>
{
...
@@ -126,7 +126,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
...
@@ -126,7 +126,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
hideOption
()
hideOption
()
},
triggerRef
)
},
triggerRef
)
const
handleSelectModel
=
(
id
:
string
)
=>
{
const
handleSelectModel
=
(
id
:
string
,
provider
=
ProviderType
.
openai
)
=>
{
return
()
=>
{
return
()
=>
{
if
(
id
===
'gpt-4'
&&
!
canUseGPT4
)
{
if
(
id
===
'gpt-4'
&&
!
canUseGPT4
)
{
hideConfig
()
hideConfig
()
...
@@ -144,7 +144,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
...
@@ -144,7 +144,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
max_tokens
:
4000
,
max_tokens
:
4000
,
})
})
}
}
setModelId
(
id
)
setModelId
(
id
,
provider
)
}
}
}
}
...
@@ -241,7 +241,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
...
@@ -241,7 +241,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
{
isShowOption
&&
(
{
isShowOption
&&
(
<
div
className=
{
cn
(
isChatApp
?
'min-w-[159px]'
:
'w-[179px]'
,
'absolute right-0 bg-gray-50 rounded-lg shadow'
)
}
>
<
div
className=
{
cn
(
isChatApp
?
'min-w-[159px]'
:
'w-[179px]'
,
'absolute right-0 bg-gray-50 rounded-lg shadow'
)
}
>
{
availableModels
.
map
(
item
=>
(
{
availableModels
.
map
(
item
=>
(
<
div
key=
{
item
.
id
}
onClick=
{
handleSelectModel
(
item
.
id
)
}
className=
"flex items-center h-9 px-3 rounded-lg cursor-pointer hover:bg-gray-100"
>
<
div
key=
{
item
.
id
}
onClick=
{
handleSelectModel
(
item
.
id
,
item
.
provider
)
}
className=
"flex items-center h-9 px-3 rounded-lg cursor-pointer hover:bg-gray-100"
>
<
ModelIcon
className=
'shrink-0 mr-2'
/>
<
ModelIcon
className=
'shrink-0 mr-2'
/>
<
div
className=
"text-sm gray-900 whitespace-nowrap"
>
{
item
.
name
}
</
div
>
<
div
className=
"text-sm gray-900 whitespace-nowrap"
>
{
item
.
name
}
</
div
>
</
div
>
</
div
>
...
...
web/app/components/app/configuration/index.tsx
View file @
6409b2e6
...
@@ -16,6 +16,7 @@ import ConfigModel from '@/app/components/app/configuration/config-model'
...
@@ -16,6 +16,7 @@ import ConfigModel from '@/app/components/app/configuration/config-model'
import
Config
from
'@/app/components/app/configuration/config'
import
Config
from
'@/app/components/app/configuration/config'
import
Debug
from
'@/app/components/app/configuration/debug'
import
Debug
from
'@/app/components/app/configuration/debug'
import
Confirm
from
'@/app/components/base/confirm'
import
Confirm
from
'@/app/components/base/confirm'
import
{
ProviderType
}
from
'@/types/app'
import
type
{
AppDetailResponse
}
from
'@/models/app'
import
type
{
AppDetailResponse
}
from
'@/models/app'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
fetchTenantInfo
}
from
'@/service/common'
import
{
fetchTenantInfo
}
from
'@/service/common'
...
@@ -67,7 +68,7 @@ const Configuration: FC = () => {
...
@@ -67,7 +68,7 @@ const Configuration: FC = () => {
frequency_penalty
:
1
,
// -2-2
frequency_penalty
:
1
,
// -2-2
})
})
const
[
modelConfig
,
doSetModelConfig
]
=
useState
<
ModelConfig
>
({
const
[
modelConfig
,
doSetModelConfig
]
=
useState
<
ModelConfig
>
({
provider
:
'openai'
,
provider
:
ProviderType
.
openai
,
model_id
:
'gpt-3.5-turbo'
,
model_id
:
'gpt-3.5-turbo'
,
configs
:
{
configs
:
{
prompt_template
:
''
,
prompt_template
:
''
,
...
@@ -84,8 +85,9 @@ const Configuration: FC = () => {
...
@@ -84,8 +85,9 @@ const Configuration: FC = () => {
doSetModelConfig
(
newModelConfig
)
doSetModelConfig
(
newModelConfig
)
}
}
const
setModelId
=
(
modelId
:
string
)
=>
{
const
setModelId
=
(
modelId
:
string
,
provider
:
ProviderType
)
=>
{
const
newModelConfig
=
produce
(
modelConfig
,
(
draft
:
any
)
=>
{
const
newModelConfig
=
produce
(
modelConfig
,
(
draft
:
any
)
=>
{
draft
.
provider
=
provider
draft
.
model_id
=
modelId
draft
.
model_id
=
modelId
})
})
setModelConfig
(
newModelConfig
)
setModelConfig
(
newModelConfig
)
...
...
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