feat: model share market
This commit is contained in:
@@ -13,7 +13,9 @@ import {
|
||||
SliderMark,
|
||||
Tooltip,
|
||||
Button,
|
||||
Select
|
||||
Select,
|
||||
Grid,
|
||||
Switch
|
||||
} from '@chakra-ui/react';
|
||||
import { QuestionOutlineIcon } from '@chakra-ui/icons';
|
||||
import type { ModelSchema } from '@/types/mongoSchema';
|
||||
@@ -25,10 +27,12 @@ import { useConfirm } from '@/hooks/useConfirm';
|
||||
const ModelEditForm = ({
|
||||
formHooks,
|
||||
canTrain,
|
||||
isOwner,
|
||||
handleDelModel
|
||||
}: {
|
||||
formHooks: UseFormReturn<ModelSchema>;
|
||||
canTrain: boolean;
|
||||
isOwner: boolean;
|
||||
handleDelModel: () => void;
|
||||
}) => {
|
||||
const { openConfirm, ConfirmChild } = useConfirm({
|
||||
@@ -40,27 +44,26 @@ const ModelEditForm = ({
|
||||
return (
|
||||
<>
|
||||
<Card p={4}>
|
||||
<Flex justifyContent={'space-between'} alignItems={'center'}>
|
||||
<Box fontWeight={'bold'}>基本信息</Box>
|
||||
</Flex>
|
||||
<Box fontWeight={'bold'}>基本信息</Box>
|
||||
<FormControl mt={4}>
|
||||
<Flex alignItems={'center'}>
|
||||
<Box flex={'0 0 80px'} w={0}>
|
||||
名称:
|
||||
</Box>
|
||||
<Input
|
||||
isDisabled={!isOwner}
|
||||
{...register('name', {
|
||||
required: '展示名称不能为空'
|
||||
})}
|
||||
></Input>
|
||||
</Flex>
|
||||
<Flex alignItems={'center'} mt={5}>
|
||||
<Box flex={'0 0 80px'} w={0}>
|
||||
modelId:
|
||||
</Box>
|
||||
<Box>{getValues('_id')}</Box>
|
||||
</Flex>
|
||||
</FormControl>
|
||||
<Flex alignItems={'center'} mt={5}>
|
||||
<Box flex={'0 0 80px'} w={0}>
|
||||
modelId:
|
||||
</Box>
|
||||
<Box>{getValues('_id')}</Box>
|
||||
</Flex>
|
||||
<Flex alignItems={'center'} mt={5}>
|
||||
<Box flex={'0 0 80px'} w={0}>
|
||||
模型类型:
|
||||
@@ -79,17 +82,25 @@ const ModelEditForm = ({
|
||||
元/1K tokens(包括上下文和回答)
|
||||
</Box>
|
||||
</Flex>
|
||||
<Flex mt={5} alignItems={'center'}>
|
||||
<Box flex={'0 0 150px'}>删除模型和数据集</Box>
|
||||
<Button
|
||||
colorScheme={'gray'}
|
||||
variant={'outline'}
|
||||
size={'sm'}
|
||||
onClick={openConfirm(handleDelModel)}
|
||||
>
|
||||
删除模型
|
||||
</Button>
|
||||
<Flex alignItems={'center'} mt={5}>
|
||||
<Box flex={'0 0 80px'} w={0}>
|
||||
收藏人数:
|
||||
</Box>
|
||||
<Box>{getValues('share.collection')}人</Box>
|
||||
</Flex>
|
||||
{isOwner && (
|
||||
<Flex mt={5} alignItems={'center'}>
|
||||
<Box flex={'0 0 150px'}>删除模型和知识库</Box>
|
||||
<Button
|
||||
colorScheme={'gray'}
|
||||
variant={'outline'}
|
||||
size={'sm'}
|
||||
onClick={openConfirm(handleDelModel)}
|
||||
>
|
||||
删除模型
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
</Card>
|
||||
<Card p={4}>
|
||||
<Box fontWeight={'bold'}>模型效果</Box>
|
||||
@@ -110,6 +121,7 @@ const ModelEditForm = ({
|
||||
max={10}
|
||||
step={1}
|
||||
value={getValues('temperature')}
|
||||
isDisabled={!isOwner}
|
||||
onChange={(e) => {
|
||||
setValue('temperature', e);
|
||||
setRefresh(!refresh);
|
||||
@@ -139,7 +151,10 @@ const ModelEditForm = ({
|
||||
<FormControl mt={4}>
|
||||
<Flex alignItems={'center'}>
|
||||
<Box flex={'0 0 70px'}>搜索模式</Box>
|
||||
<Select {...register('search.mode', { required: '搜索模式不能为空' })}>
|
||||
<Select
|
||||
isDisabled={!isOwner}
|
||||
{...register('search.mode', { required: '搜索模式不能为空' })}
|
||||
>
|
||||
{Object.entries(ModelVectorSearchModeMap).map(([key, { text }]) => (
|
||||
<option key={key} value={key}>
|
||||
{text}
|
||||
@@ -154,15 +169,73 @@ const ModelEditForm = ({
|
||||
<Textarea
|
||||
rows={6}
|
||||
maxLength={-1}
|
||||
{...register('systemPrompt')}
|
||||
isDisabled={!isOwner}
|
||||
placeholder={
|
||||
canTrain
|
||||
? '训练的模型会根据知识库内容,生成一部分系统提示词,因此在对话时需要消耗更多的 tokens。你可以增加提示词,让效果更符合预期。例如: \n1. 请根据知识库内容回答用户问题。\n2. 知识库是电影《铃芽之旅》的内容,根据知识库内容回答。无关问题,拒绝回复!'
|
||||
: '模型默认的 prompt 词,通过调整该内容,可以生成一个限定范围的模型。\n注意,改功能会影响对话的整体朝向!'
|
||||
}
|
||||
{...register('systemPrompt')}
|
||||
/>
|
||||
</Box>
|
||||
</Card>
|
||||
{isOwner && (
|
||||
<Card p={4} gridColumnStart={[1, 1]} gridColumnEnd={[2, 3]}>
|
||||
<Box fontWeight={'bold'}>分享设置</Box>
|
||||
|
||||
<Grid gridTemplateColumns={['1fr', '1fr 410px']} gridGap={5}>
|
||||
<Box>
|
||||
<Flex mt={5} alignItems={'center'}>
|
||||
<Box mr={3}>模型分享:</Box>
|
||||
<Switch
|
||||
isChecked={getValues('share.isShare')}
|
||||
onChange={() => {
|
||||
setValue('share.isShare', !getValues('share.isShare'));
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
/>
|
||||
<Box ml={12} mr={3}>
|
||||
分享模型细节:
|
||||
</Box>
|
||||
<Switch
|
||||
isChecked={getValues('share.isShareDetail')}
|
||||
onChange={() => {
|
||||
setValue('share.isShareDetail', !getValues('share.isShareDetail'));
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
<Box mt={5}>
|
||||
<Box>模型介绍</Box>
|
||||
<Textarea
|
||||
mt={1}
|
||||
rows={6}
|
||||
maxLength={150}
|
||||
{...register('share.intro')}
|
||||
placeholder={'介绍模型的功能、场景等,吸引更多人来使用!最多150字。'}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
textAlign={'justify'}
|
||||
fontSize={'sm'}
|
||||
border={'1px solid #f4f4f4'}
|
||||
borderRadius={'sm'}
|
||||
p={3}
|
||||
>
|
||||
<Box fontWeight={'bold'}>Tips</Box>
|
||||
<Box mt={1} as={'ul'} pl={4}>
|
||||
<li>
|
||||
开启模型分享后,你的模型将会出现在共享市场,可供 FastGpt
|
||||
所有用户使用。用户使用时不会消耗你的 tokens,而是消耗使用者的 tokens。
|
||||
</li>
|
||||
<li>开启分享详情后,其他用户可以查看该模型的特有数据:温度、提示词和数据集。</li>
|
||||
</Box>
|
||||
</Box>
|
||||
</Grid>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* <Card p={4}>
|
||||
<Box fontWeight={'bold'}>安全策略</Box>
|
||||
<FormControl mt={2}>
|
||||
|
||||
Reference in New Issue
Block a user