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
56977214
authored
Jul 05, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model
parent
63d1657f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
21 deletions
+26
-21
client/public/docs/chatProblem.md
+1
-0
client/src/constants/model.ts
+16
-11
client/src/pages/api/system/getModels.ts
+1
-0
client/src/pages/model/components/detail/components/Settings.tsx
+4
-6
client/src/pages/number/components/BillTable.tsx
+1
-1
client/src/types/user.d.ts
+1
-1
client/src/utils/adapt.ts
+2
-2
No files found.
client/public/docs/chatProblem.md
View file @
56977214
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
| 知识库 - 索引 | 0.001 |
| 知识库 - 索引 | 0.001 |
| chatgpt - 对话 | 0.015 |
| chatgpt - 对话 | 0.015 |
| chatgpt16K - 对话 | 0.03 |
| chatgpt16K - 对话 | 0.03 |
| 窝牛 GPT4 不稳定 - 对话 | 0.015 |
| gpt4 - 对话 | 0.45 |
| gpt4 - 对话 | 0.45 |
| 文件拆分 | 0.03 |
| 文件拆分 | 0.03 |
...
...
client/src/constants/model.ts
View file @
56977214
import
{
getSystemModelList
}
from
'@/api/system'
;
import
type
{
ShareChatEditType
}
from
'@/types/model'
;
import
type
{
ShareChatEditType
}
from
'@/types/model'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
...
@@ -10,7 +9,8 @@ export enum OpenAiChatEnum {
...
@@ -10,7 +9,8 @@ export enum OpenAiChatEnum {
'GPT35'
=
'gpt-3.5-turbo'
,
'GPT35'
=
'gpt-3.5-turbo'
,
'GPT3516k'
=
'gpt-3.5-turbo-16k'
,
'GPT3516k'
=
'gpt-3.5-turbo-16k'
,
'GPT4'
=
'gpt-4'
,
'GPT4'
=
'gpt-4'
,
'GPT432k'
=
'gpt-4-32k'
'GPT432k'
=
'gpt-4-32k'
,
'GPT4LOW'
=
'gpt-4-0314'
}
}
export
type
ChatModelType
=
`
${
OpenAiChatEnum
}
`
;
export
type
ChatModelType
=
`
${
OpenAiChatEnum
}
`
;
...
@@ -25,6 +25,14 @@ export type ChatModelItemType = {
...
@@ -25,6 +25,14 @@ export type ChatModelItemType = {
};
};
export
const
ChatModelMap
=
{
export
const
ChatModelMap
=
{
[
OpenAiChatEnum
.
GPT4LOW
]:
{
chatModel
:
OpenAiChatEnum
.
GPT4LOW
,
name
:
'窝牛Gpt4不稳定'
,
contextMaxToken
:
4000
,
systemMaxToken
:
2400
,
maxTemperature
:
1.2
,
price
:
1.5
},
[
OpenAiChatEnum
.
GPT35
]:
{
[
OpenAiChatEnum
.
GPT35
]:
{
chatModel
:
OpenAiChatEnum
.
GPT35
,
chatModel
:
OpenAiChatEnum
.
GPT35
,
name
:
'Gpt35-4k'
,
name
:
'Gpt35-4k'
,
...
@@ -59,15 +67,12 @@ export const ChatModelMap = {
...
@@ -59,15 +67,12 @@ export const ChatModelMap = {
}
}
};
};
let
chatModelList
:
ChatModelItemType
[]
=
[];
export
const
chatModelList
:
ChatModelItemType
[]
=
[
export
const
getChatModelList
=
async
()
=>
{
ChatModelMap
[
OpenAiChatEnum
.
GPT3516k
],
if
(
chatModelList
.
length
>
0
)
{
ChatModelMap
[
OpenAiChatEnum
.
GPT35
],
return
chatModelList
;
ChatModelMap
[
OpenAiChatEnum
.
GPT4LOW
],
}
ChatModelMap
[
OpenAiChatEnum
.
GPT4
]
const
list
=
await
getSystemModelList
();
];
chatModelList
=
list
;
return
list
;
};
export
const
defaultModel
:
ModelSchema
=
{
export
const
defaultModel
:
ModelSchema
=
{
_id
:
'modelId'
,
_id
:
'modelId'
,
...
...
client/src/pages/api/system/getModels.ts
View file @
56977214
...
@@ -9,6 +9,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -9,6 +9,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT3516k
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT3516k
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT35
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT35
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT4LOW
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT4
]);
chatModelList
.
push
(
ChatModelMap
[
OpenAiChatEnum
.
GPT4
]);
jsonRes
(
res
,
{
jsonRes
(
res
,
{
...
...
client/src/pages/model/components/detail/components/Settings.tsx
View file @
56977214
...
@@ -21,7 +21,7 @@ import { useSelectFile } from '@/hooks/useSelectFile';
...
@@ -21,7 +21,7 @@ import { useSelectFile } from '@/hooks/useSelectFile';
import
{
compressImg
}
from
'@/utils/file'
;
import
{
compressImg
}
from
'@/utils/file'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
useConfirm
}
from
'@/hooks/useConfirm'
;
import
{
useConfirm
}
from
'@/hooks/useConfirm'
;
import
{
ChatModelMap
,
getC
hatModelList
}
from
'@/constants/model'
;
import
{
ChatModelMap
,
c
hatModelList
}
from
'@/constants/model'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
{
formatPrice
}
from
'@/utils/user'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
...
@@ -185,8 +185,6 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -185,8 +185,6 @@ const Settings = ({ modelId }: { modelId: string }) => {
}
}
});
});
const { data: chatModelList = [] } = useQuery(['initChatModelList'], getChatModelList);
return (
return (
<Box
<Box
pb={3}
pb={3}
...
@@ -240,7 +238,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -240,7 +238,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
对话模型
对话模型
</Box>
</Box>
<MySelect
<MySelect
width={['
90%', '28
0px']}
width={['
100%', '30
0px']}
value={getValues('chat.chatModel')}
value={getValues('chat.chatModel')}
list={chatModelList.map((item) => ({
list={chatModelList.map((item) => ({
id: item.chatModel,
id: item.chatModel,
...
@@ -265,7 +263,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -265,7 +263,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
{ label: '严谨', value: 0 },
{ label: '严谨', value: 0 },
{ label: '发散', value: 10 }
{ label: '发散', value: 10 }
]}
]}
width={['9
0%', '26
0px']}
width={['9
5%', '28
0px']}
min={0}
min={0}
max={10}
max={10}
activeVal={getValues('chat.temperature')}
activeVal={getValues('chat.temperature')}
...
@@ -286,7 +284,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
...
@@ -286,7 +284,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
{ label: '100', value: 100 },
{ label: '100', value: 100 },
{ label: `
$
{
tokenLimit
}
`, value: tokenLimit }
{ label: `
$
{
tokenLimit
}
`, value: tokenLimit }
]}
]}
width={['9
0%', '26
0px']}
width={['9
5%', '28
0px']}
min={100}
min={100}
max={tokenLimit}
max={tokenLimit}
step={50}
step={50}
...
...
client/src/pages/number/components/BillTable.tsx
View file @
56977214
...
@@ -40,7 +40,7 @@ const BillTable = () => {
...
@@ -40,7 +40,7 @@ const BillTable = () => {
<
Tr
>
<
Tr
>
<
Th
>
时间
</
Th
>
<
Th
>
时间
</
Th
>
<
Th
>
类型
</
Th
>
<
Th
>
类型
</
Th
>
<
Th
>
底层
模型
</
Th
>
<
Th
>
模型
</
Th
>
<
Th
>
内容长度
</
Th
>
<
Th
>
内容长度
</
Th
>
<
Th
>
Tokens 长度
</
Th
>
<
Th
>
Tokens 长度
</
Th
>
<
Th
>
金额
</
Th
>
<
Th
>
金额
</
Th
>
...
...
client/src/types/user.d.ts
View file @
56977214
...
@@ -19,7 +19,7 @@ export interface UserUpdateParams {
...
@@ -19,7 +19,7 @@ export interface UserUpdateParams {
export
interface
UserBillType
{
export
interface
UserBillType
{
id
:
string
;
id
:
string
;
time
:
Date
;
time
:
Date
;
modelName
:
BillSchema
[
'modelName'
]
;
modelName
:
string
;
type
:
BillSchema
[
'type'
];
type
:
BillSchema
[
'type'
];
textLen
:
number
;
textLen
:
number
;
tokenLen
:
number
;
tokenLen
:
number
;
...
...
client/src/utils/adapt.ts
View file @
56977214
import
{
formatPrice
}
from
'./user'
;
import
{
formatPrice
}
from
'./user'
;
import
dayjs
from
'dayjs'
;
import
type
{
BillSchema
}
from
'../types/mongoSchema'
;
import
type
{
BillSchema
}
from
'../types/mongoSchema'
;
import
type
{
UserBillType
}
from
'@/types/user'
;
import
type
{
UserBillType
}
from
'@/types/user'
;
import
{
ChatItemType
}
from
'@/types/chat'
;
import
{
ChatItemType
}
from
'@/types/chat'
;
import
{
ChatCompletionRequestMessageRoleEnum
}
from
'openai'
;
import
{
ChatCompletionRequestMessageRoleEnum
}
from
'openai'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
type
{
MessageItemType
}
from
'@/pages/api/openapi/v1/chat/completions'
;
import
type
{
MessageItemType
}
from
'@/pages/api/openapi/v1/chat/completions'
;
import
{
ChatModelMap
,
OpenAiChatEnum
}
from
'@/constants/model'
;
export
const
adaptBill
=
(
bill
:
BillSchema
):
UserBillType
=>
{
export
const
adaptBill
=
(
bill
:
BillSchema
):
UserBillType
=>
{
return
{
return
{
id
:
bill
.
_id
,
id
:
bill
.
_id
,
type
:
bill
.
type
,
type
:
bill
.
type
,
modelName
:
bill
.
modelName
,
modelName
:
ChatModelMap
[
bill
.
modelName
as
`
${
OpenAiChatEnum
}
`
]?.
name
||
bill
.
modelName
,
time
:
bill
.
time
,
time
:
bill
.
time
,
textLen
:
bill
.
textLen
,
textLen
:
bill
.
textLen
,
tokenLen
:
bill
.
tokenLen
,
tokenLen
:
bill
.
tokenLen
,
...
...
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