This commit is contained in:
archer
2023-07-05 18:12:00 +08:00
parent 63d1657f9b
commit 569772148f
7 changed files with 26 additions and 21 deletions

View File

@@ -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 |

View File

@@ -1,4 +1,3 @@
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 {
'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 = {
}; };
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 = {
} }
}; };
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',

View File

@@ -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, {

View File

@@ -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, getChatModelList } from '@/constants/model'; import { ChatModelMap, chatModelList } 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 }) => {
} }
}); });
const { data: chatModelList = [] } = useQuery(['initChatModelList'], getChatModelList);
return ( return (
<Box <Box
pb={3} pb={3}
@@ -240,7 +238,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
</Box> </Box>
<MySelect <MySelect
width={['90%', '280px']} width={['100%', '300px']}
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 }) => {
{ label: '严谨', value: 0 }, { label: '严谨', value: 0 },
{ label: '发散', value: 10 } { label: '发散', value: 10 }
]} ]}
width={['90%', '260px']} width={['95%', '280px']}
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 }) => {
{ label: '100', value: 100 }, { label: '100', value: 100 },
{ label: `${tokenLimit}`, value: tokenLimit } { label: `${tokenLimit}`, value: tokenLimit }
]} ]}
width={['90%', '260px']} width={['95%', '280px']}
min={100} min={100}
max={tokenLimit} max={tokenLimit}
step={50} step={50}

View File

@@ -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>

View File

@@ -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;

View File

@@ -1,17 +1,17 @@
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,