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
b3c2bf12
Unverified
Commit
b3c2bf12
authored
Aug 22, 2023
by
zxhlyh
Committed by
GitHub
Aug 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/model providers (#951)
parent
9d5299e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
13 deletions
+33
-13
index.tsx
...pp/components/header/account-setting/model-page/index.tsx
+31
-12
QuotaCard.tsx
...eader/account-setting/model-page/model-item/QuotaCard.tsx
+2
-1
No files found.
web/app/components/header/account-setting/model-page/index.tsx
View file @
b3c2bf12
import
{
useState
}
from
'react'
import
{
useState
}
from
'react'
import
useSWR
from
'swr'
import
useSWR
from
'swr'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
useContext
}
from
'use-context-selector'
import
type
{
import
type
{
BackendModel
,
BackendModel
,
FormValue
,
FormValue
,
...
@@ -30,23 +31,13 @@ import { ModelType } from '@/app/components/header/account-setting/model-page/de
...
@@ -30,23 +31,13 @@ import { ModelType } from '@/app/components/header/account-setting/model-page/de
import
{
useEventEmitterContextContext
}
from
'@/context/event-emitter'
import
{
useEventEmitterContextContext
}
from
'@/context/event-emitter'
import
{
useProviderContext
}
from
'@/context/provider-context'
import
{
useProviderContext
}
from
'@/context/provider-context'
import
Tooltip
from
'@/app/components/base/tooltip'
import
Tooltip
from
'@/app/components/base/tooltip'
import
I18n
from
'@/context/i18n'
const
MODEL_CARD_LIST
=
[
const
MODEL_CARD_LIST
=
[
config
.
openai
,
config
.
openai
,
config
.
anthropic
,
config
.
anthropic
,
]
]
const
MODEL_LIST
=
[
config
.
azure_openai
,
config
.
replicate
,
config
.
huggingface_hub
,
config
.
minimax
,
config
.
spark
,
config
.
tongyi
,
config
.
wenxin
,
config
.
chatglm
,
]
const
titleClassName
=
`
const
titleClassName
=
`
flex items-center h-9 text-sm font-medium text-gray-900
flex items-center h-9 text-sm font-medium text-gray-900
`
`
...
@@ -61,6 +52,7 @@ type DeleteModel = {
...
@@ -61,6 +52,7 @@ type DeleteModel = {
const
ModelPage
=
()
=>
{
const
ModelPage
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
locale
}
=
useContext
(
I18n
)
const
{
const
{
updateModelList
,
updateModelList
,
embeddingsDefaultModel
,
embeddingsDefaultModel
,
...
@@ -79,6 +71,33 @@ const ModelPage = () => {
...
@@ -79,6 +71,33 @@ const ModelPage = () => {
const
[
deleteModel
,
setDeleteModel
]
=
useState
<
DeleteModel
&
{
providerKey
:
ProviderEnum
}
>
()
const
[
deleteModel
,
setDeleteModel
]
=
useState
<
DeleteModel
&
{
providerKey
:
ProviderEnum
}
>
()
const
[
modalMode
,
setModalMode
]
=
useState
(
'add'
)
const
[
modalMode
,
setModalMode
]
=
useState
(
'add'
)
let
modelList
=
[]
if
(
locale
===
'en'
)
{
modelList
=
[
config
.
azure_openai
,
config
.
replicate
,
config
.
huggingface_hub
,
config
.
minimax
,
config
.
spark
,
config
.
tongyi
,
config
.
wenxin
,
config
.
chatglm
,
]
}
else
{
modelList
=
[
config
.
huggingface_hub
,
config
.
minimax
,
config
.
spark
,
config
.
azure_openai
,
config
.
replicate
,
config
.
tongyi
,
config
.
wenxin
,
config
.
chatglm
,
]
}
const
handleOpenModal
=
(
newModelModalConfig
:
ProviderConfigModal
|
undefined
,
editValue
?:
FormValue
)
=>
{
const
handleOpenModal
=
(
newModelModalConfig
:
ProviderConfigModal
|
undefined
,
editValue
?:
FormValue
)
=>
{
if
(
newModelModalConfig
)
{
if
(
newModelModalConfig
)
{
setShowModal
(
true
)
setShowModal
(
true
)
...
@@ -284,7 +303,7 @@ const ModelPage = () => {
...
@@ -284,7 +303,7 @@ const ModelPage = () => {
}
}
</
div
>
</
div
>
{
{
MODEL_LIST
.
slice
(
0
,
showMoreModel
?
MODEL_LIST
.
length
:
3
).
map
((
model
,
index
)
=>
(
modelList
.
slice
(
0
,
showMoreModel
?
modelList
.
length
:
3
).
map
((
model
,
index
)
=>
(
<
ModelItem
<
ModelItem
key=
{
index
}
key=
{
index
}
modelItem=
{
model
.
item
}
modelItem=
{
model
.
item
}
...
...
web/app/components/header/account-setting/model-page/model-item/QuotaCard.tsx
View file @
b3c2bf12
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
formatNumber
}
from
'@/utils/format'
type
QuotaCardProps
=
{
type
QuotaCardProps
=
{
remainTokens
:
number
remainTokens
:
number
...
@@ -17,7 +18,7 @@ const QuotaCard: FC<QuotaCardProps> = ({
...
@@ -17,7 +18,7 @@ const QuotaCard: FC<QuotaCardProps> = ({
{
t
(
'common.modelProvider.item.freeQuota'
)
}
{
t
(
'common.modelProvider.item.freeQuota'
)
}
</
div
>
</
div
>
<
div
className=
'flex items-center h-5 text-sm font-medium text-gray-700'
>
<
div
className=
'flex items-center h-5 text-sm font-medium text-gray-700'
>
{
remainTokens
}
{
formatNumber
(
remainTokens
)
}
<
div
className=
'ml-1 font-normal'
>
Tokens
</
div
>
<
div
className=
'ml-1 font-normal'
>
Tokens
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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