mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00

* feat: stop toolCall and rename some field. (#46) * perf: node delete tip;pay tip * fix: toolCall cannot save child answer * feat: stop tool * fix: team modal * fix feckbackMoal auth bug (#47) * 简单的支持提示词运行tool。优化workflow模板 (#49) * remove templates * fix: request body undefined * feat: prompt tool run * feat: workflow tamplates modal * perf: plugin start * 4.7 (#50) * fix docker-compose download url (#994) original code is a bad url with '404 NOT FOUND' return. fix docker-compose download url, add 'v' before docker-compose version * Update ai_settings.md (#1000) * Update configuration.md * Update configuration.md * Fix history in classifyQuestion and extract modules (#1012) * Fix history in classifyQuestion and extract modules * Add chatValue2RuntimePrompt import and update text formatting * flow controller to packages * fix: rerank select * modal ui * perf: modal code path * point not sufficient * feat: http url support variable * fix http key * perf: prompt * perf: ai setting modal * simple edit ui --------- Co-authored-by: entorick <entorick11@qq.com> Co-authored-by: liujianglc <liujianglc@163.com> Co-authored-by: Fengrui Liu <liufengrui.work@bytedance.com> * fix team share redirect to login (#51) * feat: support openapi import plugins (#48) * feat: support openapi import plugins * feat: import from url * fix: add body params parse * fix build * fix * fix * fix * tool box ui (#52) * fix: training queue * feat: simple edit tool select * perf: simple edit dataset prompt * fix: chatbox tool ux * feat: quote prompt module * perf: plugin tools sign * perf: model avatar * tool selector ui * feat: max histories * perf: http plugin import (#53) * perf: plugin http import * chatBox ui * perf: name * fix: Node template card (#54) * fix: ts * setting modal * package * package * feat: add plugins search (#57) * feat: add plugins search * perf: change http plugin header input * Yjl (#56) * perf: prompt tool call * perf: chat box ux * doc * doc * price tip * perf: tool selector * ui' * fix: vector queue * fix: empty tool and empty response * fix: empty msg * perf: pg index * perf: ui tip * doc * tool tip --------- Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com> Co-authored-by: entorick <entorick11@qq.com> Co-authored-by: liujianglc <liujianglc@163.com> Co-authored-by: Fengrui Liu <liufengrui.work@bytedance.com> Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
207 lines
6.8 KiB
TypeScript
207 lines
6.8 KiB
TypeScript
import React, { useState, useMemo } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
import { Box, Flex, Button, IconButton, Input, Textarea } from '@chakra-ui/react';
|
|
import { DeleteIcon } from '@chakra-ui/icons';
|
|
import { delDatasetById } from '@/web/core/dataset/api';
|
|
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
|
|
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
|
|
import { useConfirm } from '@/web/common/hooks/useConfirm';
|
|
import { useForm } from 'react-hook-form';
|
|
import { compressImgFileAndUpload } from '@/web/common/file/controller';
|
|
import type { DatasetItemType } from '@fastgpt/global/core/dataset/type.d';
|
|
import Avatar from '@/components/Avatar';
|
|
import MyTooltip from '@/components/MyTooltip';
|
|
import { useTranslation } from 'next-i18next';
|
|
import PermissionRadio from '@/components/support/permission/Radio';
|
|
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
import { useRequest } from '@/web/common/hooks/useRequest';
|
|
import { MongoImageTypeEnum } from '@fastgpt/global/common/file/image/constants';
|
|
import MySelect from '@fastgpt/web/components/common/MySelect';
|
|
import AIModelSelector from '@/components/Select/AIModelSelector';
|
|
|
|
const Info = ({ datasetId }: { datasetId: string }) => {
|
|
const { t } = useTranslation();
|
|
const { datasetDetail, loadDatasets, updateDataset } = useDatasetStore();
|
|
const { getValues, setValue, register, handleSubmit } = useForm<DatasetItemType>({
|
|
defaultValues: datasetDetail
|
|
});
|
|
const { datasetModelList, vectorModelList } = useSystemStore();
|
|
|
|
const router = useRouter();
|
|
|
|
const [refresh, setRefresh] = useState(false);
|
|
|
|
const { openConfirm, ConfirmModal } = useConfirm({
|
|
content: t('core.dataset.Delete Confirm'),
|
|
type: 'delete'
|
|
});
|
|
|
|
const { File, onOpen: onOpenSelectFile } = useSelectFile({
|
|
fileType: '.jpg,.png',
|
|
multiple: false
|
|
});
|
|
|
|
/* 点击删除 */
|
|
const { mutate: onclickDelete, isLoading: isDeleting } = useRequest({
|
|
mutationFn: () => {
|
|
return delDatasetById(datasetId);
|
|
},
|
|
onSuccess() {
|
|
router.replace(`/dataset/list`);
|
|
},
|
|
successToast: t('common.Delete Success'),
|
|
errorToast: t('common.Delete Failed')
|
|
});
|
|
|
|
const { mutate: onclickSave, isLoading: isSaving } = useRequest({
|
|
mutationFn: (data: DatasetItemType) => {
|
|
return updateDataset({
|
|
id: datasetId,
|
|
...data
|
|
});
|
|
},
|
|
onSuccess() {
|
|
loadDatasets();
|
|
},
|
|
successToast: t('common.Update Success'),
|
|
errorToast: t('common.Update Failed')
|
|
});
|
|
|
|
const { mutate: onSelectFile, isLoading: isSelecting } = useRequest({
|
|
mutationFn: (e: File[]) => {
|
|
const file = e[0];
|
|
if (!file) return Promise.resolve(null);
|
|
return compressImgFileAndUpload({
|
|
type: MongoImageTypeEnum.datasetAvatar,
|
|
file,
|
|
maxW: 300,
|
|
maxH: 300
|
|
});
|
|
},
|
|
onSuccess(src: string | null) {
|
|
if (src) {
|
|
setValue('avatar', src);
|
|
setRefresh((state) => !state);
|
|
}
|
|
},
|
|
errorToast: t('common.avatar.Select Failed')
|
|
});
|
|
|
|
const btnLoading = useMemo(() => isDeleting || isSaving, [isDeleting, isSaving]);
|
|
|
|
return (
|
|
<Box py={5} px={[5, 10]}>
|
|
<Flex mt={5} w={'100%'} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.dataset.Dataset ID')}
|
|
</Box>
|
|
<Box flex={1}>{datasetDetail._id}</Box>
|
|
</Flex>
|
|
|
|
<Flex mt={5} w={'100%'} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.dataset.Avatar')}
|
|
</Box>
|
|
<Box flex={[1, '0 0 300px']}>
|
|
<MyTooltip label={t('common.avatar.Select Avatar')}>
|
|
<Avatar
|
|
m={'auto'}
|
|
src={getValues('avatar')}
|
|
w={['32px', '40px']}
|
|
h={['32px', '40px']}
|
|
cursor={'pointer'}
|
|
onClick={onOpenSelectFile}
|
|
/>
|
|
</MyTooltip>
|
|
</Box>
|
|
</Flex>
|
|
<Flex mt={8} w={'100%'} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.dataset.Name')}
|
|
</Box>
|
|
<Input flex={[1, '0 0 300px']} maxLength={30} {...register('name')} />
|
|
</Flex>
|
|
<Flex mt={8} w={'100%'} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.ai.model.Vector Model')}
|
|
</Box>
|
|
<Box flex={[1, '0 0 300px']}>{getValues('vectorModel').name}</Box>
|
|
</Flex>
|
|
<Flex mt={8} w={'100%'} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.Max Token')}
|
|
</Box>
|
|
<Box flex={[1, '0 0 300px']}>{getValues('vectorModel').maxToken}</Box>
|
|
</Flex>
|
|
<Flex mt={6} alignItems={'center'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('core.ai.model.Dataset Agent Model')}
|
|
</Box>
|
|
<Box flex={[1, '0 0 300px']}>
|
|
<AIModelSelector
|
|
w={'100%'}
|
|
value={getValues('agentModel').model}
|
|
list={datasetModelList.map((item) => ({
|
|
label: item.name,
|
|
value: item.model
|
|
}))}
|
|
onchange={(e) => {
|
|
const agentModel = datasetModelList.find((item) => item.model === e);
|
|
if (!agentModel) return;
|
|
setValue('agentModel', agentModel);
|
|
setRefresh((state) => !state);
|
|
}}
|
|
/>
|
|
</Box>
|
|
</Flex>
|
|
|
|
<Flex mt={8} alignItems={'center'} w={'100%'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']}>{t('common.Intro')}</Box>
|
|
<Textarea flex={[1, '0 0 300px']} {...register('intro')} placeholder={t('common.Intro')} />
|
|
</Flex>
|
|
{datasetDetail.isOwner && (
|
|
<Flex mt={5} alignItems={'center'} w={'100%'} flexWrap={'wrap'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}>
|
|
{t('user.Permission')}
|
|
</Box>
|
|
<Box>
|
|
<PermissionRadio
|
|
value={getValues('permission')}
|
|
onChange={(e) => {
|
|
setValue('permission', e);
|
|
setRefresh(!refresh);
|
|
}}
|
|
/>
|
|
</Box>
|
|
</Flex>
|
|
)}
|
|
|
|
<Flex mt={5} w={'100%'} alignItems={'flex-end'}>
|
|
<Box flex={['0 0 90px', '0 0 160px']} w={0}></Box>
|
|
<Button
|
|
isLoading={btnLoading}
|
|
mr={4}
|
|
w={'100px'}
|
|
onClick={handleSubmit((data) => onclickSave(data))}
|
|
>
|
|
{t('common.Save')}
|
|
</Button>
|
|
{datasetDetail.isOwner && (
|
|
<IconButton
|
|
isLoading={btnLoading}
|
|
icon={<DeleteIcon />}
|
|
aria-label={''}
|
|
variant={'whiteDanger'}
|
|
size={'smSquare'}
|
|
onClick={openConfirm(onclickDelete)}
|
|
/>
|
|
)}
|
|
</Flex>
|
|
<File onSelect={onSelectFile} />
|
|
<ConfirmModal />
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default React.memo(Info);
|