Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
e384893a
authored
May 03, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: select chat model
parent
00a99261
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
src/constants/model.ts
+13
-0
src/pages/model/detail/components/ModelEditForm.tsx
+9
-3
src/utils/user.ts
+1
-1
No files found.
src/constants/model.ts
View file @
e384893a
...
@@ -11,20 +11,31 @@ export enum OpenAiChatEnum {
...
@@ -11,20 +11,31 @@ export enum OpenAiChatEnum {
export
type
ChatModelType
=
`
${
OpenAiChatEnum
}
`
;
export
type
ChatModelType
=
`
${
OpenAiChatEnum
}
`
;
export
type
ChatModelItemType
=
{
chatModel
:
ChatModelType
;
name
:
string
;
contextMaxToken
:
number
;
maxTemperature
:
number
;
price
:
number
;
};
export
const
ChatModelMap
=
{
export
const
ChatModelMap
=
{
[
OpenAiChatEnum
.
GPT35
]:
{
[
OpenAiChatEnum
.
GPT35
]:
{
chatModel
:
OpenAiChatEnum
.
GPT35
,
name
:
'ChatGpt'
,
name
:
'ChatGpt'
,
contextMaxToken
:
4096
,
contextMaxToken
:
4096
,
maxTemperature
:
1.5
,
maxTemperature
:
1.5
,
price
:
3
price
:
3
},
},
[
OpenAiChatEnum
.
GPT4
]:
{
[
OpenAiChatEnum
.
GPT4
]:
{
chatModel
:
OpenAiChatEnum
.
GPT4
,
name
:
'Gpt4'
,
name
:
'Gpt4'
,
contextMaxToken
:
8000
,
contextMaxToken
:
8000
,
maxTemperature
:
1.5
,
maxTemperature
:
1.5
,
price
:
30
price
:
30
},
},
[
OpenAiChatEnum
.
GPT432k
]:
{
[
OpenAiChatEnum
.
GPT432k
]:
{
chatModel
:
OpenAiChatEnum
.
GPT432k
,
name
:
'Gpt4-32k'
,
name
:
'Gpt4-32k'
,
contextMaxToken
:
32000
,
contextMaxToken
:
32000
,
maxTemperature
:
1.5
,
maxTemperature
:
1.5
,
...
@@ -32,6 +43,8 @@ export const ChatModelMap = {
...
@@ -32,6 +43,8 @@ export const ChatModelMap = {
}
}
};
};
export
const
chatModelList
:
ChatModelItemType
[]
=
[
ChatModelMap
[
OpenAiChatEnum
.
GPT35
]];
export
enum
ModelStatusEnum
{
export
enum
ModelStatusEnum
{
running
=
'running'
,
running
=
'running'
,
training
=
'training'
,
training
=
'training'
,
...
...
src/pages/model/detail/components/ModelEditForm.tsx
View file @
e384893a
...
@@ -21,7 +21,7 @@ import {
...
@@ -21,7 +21,7 @@ import {
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
{
UseFormReturn
}
from
'react-hook-form'
;
import
{
UseFormReturn
}
from
'react-hook-form'
;
import
{
ChatModelMap
,
ModelVectorSearchModeMap
}
from
'@/constants/model'
;
import
{
ChatModelMap
,
ModelVectorSearchModeMap
,
chatModelList
}
from
'@/constants/model'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
useConfirm
}
from
'@/hooks/useConfirm'
;
import
{
useConfirm
}
from
'@/hooks/useConfirm'
;
import
{
useSelectFile
}
from
'@/hooks/useSelectFile'
;
import
{
useSelectFile
}
from
'@/hooks/useSelectFile'
;
...
@@ -110,14 +110,20 @@ const ModelEditForm = ({
...
@@ -110,14 +110,20 @@ const ModelEditForm = ({
<
Box
flex=
{
'0 0 80px'
}
w=
{
0
}
>
<
Box
flex=
{
'0 0 80px'
}
w=
{
0
}
>
对话模型:
对话模型:
</
Box
>
</
Box
>
<
Box
>
{
ChatModelMap
[
getValues
(
'chat.chatModel'
)].
name
}
</
Box
>
<
Select
isDisabled=
{
!
isOwner
}
{
...
register
('
chat
.
chatModel
')}
>
{
chatModelList
.
map
((
item
)
=>
(
<
option
key=
{
item
.
chatModel
}
value=
{
item
.
chatModel
}
>
{
item
.
name
}
</
option
>
))
}
</
Select
>
</
Flex
>
</
Flex
>
<
Flex
alignItems=
{
'center'
}
mt=
{
5
}
>
<
Flex
alignItems=
{
'center'
}
mt=
{
5
}
>
<
Box
flex=
{
'0 0 80px'
}
w=
{
0
}
>
<
Box
flex=
{
'0 0 80px'
}
w=
{
0
}
>
价格:
价格:
</
Box
>
</
Box
>
<
Box
>
<
Box
>
{
formatPrice
(
ChatModelMap
[
getValues
(
'chat.chatModel'
)].
price
,
1000
)
}
{
formatPrice
(
ChatModelMap
[
getValues
(
'chat.chatModel'
)]
?
.
price
,
1000
)
}
元/1K tokens(包括上下文和回答)
元/1K tokens(包括上下文和回答)
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
...
...
src/utils/user.ts
View file @
e384893a
...
@@ -14,6 +14,6 @@ export const clearToken = () => {
...
@@ -14,6 +14,6 @@ export const clearToken = () => {
/**
/**
* 把数据库读取到的price,转化成元
* 把数据库读取到的price,转化成元
*/
*/
export
const
formatPrice
=
(
val
:
number
,
multiple
=
1
)
=>
{
export
const
formatPrice
=
(
val
=
0
,
multiple
=
1
)
=>
{
return
Number
(((
val
/
PRICE_SCALE
)
*
multiple
).
toFixed
(
10
));
return
Number
(((
val
/
PRICE_SCALE
)
*
multiple
).
toFixed
(
10
));
};
};
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