mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-25 06:14:06 +00:00
feat: select chat model
This commit is contained in:
@@ -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 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const chatModelList: ChatModelItemType[] = [ChatModelMap[OpenAiChatEnum.GPT35]];
|
||||||
|
|
||||||
export enum ModelStatusEnum {
|
export enum ModelStatusEnum {
|
||||||
running = 'running',
|
running = 'running',
|
||||||
training = 'training',
|
training = 'training',
|
||||||
|
@@ -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 = ({
|
|||||||
<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>
|
||||||
|
@@ -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));
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user