@@ -237,7 +236,7 @@ const CollectionCard = () => {
>
-
+
{
offset={[-70, 5]}
Button={
{
{
{
label: (
-
+
{t('common:core.dataset.collection.Sync')}
),
@@ -331,7 +334,7 @@ const CollectionCard = () => {
{
label: (
-
+
{t('common:Move')}
),
@@ -341,7 +344,7 @@ const CollectionCard = () => {
{
label: (
-
+
{t('common:Rename')}
),
@@ -365,7 +368,7 @@ const CollectionCard = () => {
{t('common:common.Delete')}
diff --git a/projects/app/src/pages/dataset/detail/components/DataCard.tsx b/projects/app/src/pages/dataset/detail/components/DataCard.tsx
index 93deb5ea2..88884ec2d 100644
--- a/projects/app/src/pages/dataset/detail/components/DataCard.tsx
+++ b/projects/app/src/pages/dataset/detail/components/DataCard.tsx
@@ -47,7 +47,7 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem';
import TagsPopOver from './CollectionCard/TagsPopOver';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyDivider from '@fastgpt/web/components/common/MyDivider';
-import index from '../../../index';
+import Markdown from '@/components/Markdown';
const DataCard = () => {
const BoxRef = useRef(null);
@@ -232,6 +232,7 @@ const DataCard = () => {
setEditDataId(item._id);
}}
>
+ {/* Data tag */}
{
ID:{item._id}
-
- {/* {item.forbid ? (
-
- {datasetT('Disabled')}
-
- ) : (
-
- {datasetT('Enabled')}
-
- )}
- {
- e.stopPropagation();
- }}
- h={'12px'}
- >
- {
- e.stopPropagation();
- onUpdate({
- dataId: item._id,
- forbid: !e.target.checked
- });
- }}
- />
- */}
-
-
- {item.q}
-
- {item.a}
- {/* Mask */}
+ {/* Data content */}
+
+
+ {!!item.a && (
+ <>
+
+
+ >
+ )}
+
+
+ {/* Mask */}
+
-
-
- {item.q.length + (item.a?.length || 0)}
-
- {canWrite && (
- }
- variant={'whiteDanger'}
- size={'xsSquare'}
- aria-label={'delete'}
- onClick={(e) => {
- e.stopPropagation();
- openConfirm(async () => {
- try {
- await delOneDatasetDataById(item._id);
- getData(pageNum);
- } catch (error) {
- toast({
- title: getErrText(error),
- status: 'error'
- });
- }
- })();
- }}
- />
- )}
+ name="common/text/t"
+ w={'14px'}
+ mr={1}
+ />
+ {item.q.length + (item.a?.length || 0)}
-
+ {canWrite && (
+ }
+ variant={'whiteDanger'}
+ size={'xsSquare'}
+ aria-label={'delete'}
+ onClick={(e) => {
+ e.stopPropagation();
+ openConfirm(async () => {
+ try {
+ await delOneDatasetDataById(item._id);
+ getData(pageNum);
+ } catch (error) {
+ toast({
+ title: getErrText(error),
+ status: 'error'
+ });
+ }
+ })();
+ }}
+ />
+ )}
+
))}
diff --git a/projects/app/src/pages/dataset/detail/components/Info.tsx b/projects/app/src/pages/dataset/detail/components/Info.tsx
index 42d4df4f1..7cd49a79a 100644
--- a/projects/app/src/pages/dataset/detail/components/Info.tsx
+++ b/projects/app/src/pages/dataset/detail/components/Info.tsx
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { useRouter } from 'next/router';
-import { Box, Flex, Button, IconButton, Input, Textarea, HStack } from '@chakra-ui/react';
-import { DeleteIcon } from '@chakra-ui/icons';
+import { Box, Flex, Input } from '@chakra-ui/react';
import { delDatasetById } from '@/web/core/dataset/api';
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
@@ -9,7 +8,6 @@ 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 '@fastgpt/web/components/common/Avatar';
-import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useTranslation } from 'next-i18next';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { useRequest, useRequest2 } from '@fastgpt/web/hooks/useRequest';
@@ -56,7 +54,6 @@ const Info = ({ datasetId }: { datasetId: string }) => {
defaultValues: datasetDetail
});
- const avatar = watch('avatar');
const vectorModel = watch('vectorModel');
const agentModel = watch('agentModel');
const defaultPermission = watch('defaultPermission');
@@ -77,8 +74,20 @@ const Info = ({ datasetId }: { datasetId: string }) => {
multiple: false
});
- const { mutate: onSave, isLoading: isSaving } = useRequest({
- mutationFn: (data: DatasetItemType) => {
+ /* 点击删除 */
+ const { mutate: onclickDelete, isLoading: isDeleting } = useRequest({
+ mutationFn: () => {
+ return delDatasetById(datasetId);
+ },
+ onSuccess() {
+ router.replace(`/dataset/list`);
+ },
+ successToast: t('common:common.Delete Success'),
+ errorToast: t('common:common.Delete Failed')
+ });
+
+ const { runAsync: onSave, loading: isSaving } = useRequest2(
+ (data: DatasetItemType) => {
return updateDataset({
id: datasetId,
agentModel: data.agentModel,
@@ -86,12 +95,14 @@ const Info = ({ datasetId }: { datasetId: string }) => {
defaultPermission: data.defaultPermission
});
},
- successToast: t('common:common.Update Success'),
- errorToast: t('common:common.Update Failed')
- });
+ {
+ successToast: t('common:common.Update Success'),
+ errorToast: t('common:common.Update Failed')
+ }
+ );
- const { mutate: onSelectFile, isLoading: isSelecting } = useRequest({
- mutationFn: (e: File[]) => {
+ const { runAsync: onSelectFile, loading: isSelecting } = useRequest2(
+ (e: File[]) => {
const file = e[0];
if (!file) return Promise.resolve(null);
return compressImgFileAndUpload({
@@ -101,37 +112,41 @@ const Info = ({ datasetId }: { datasetId: string }) => {
maxH: 300
});
},
- onSuccess(src: string | null) {
- if (src) {
- setValue('avatar', src);
- }
- },
- errorToast: t('common:common.avatar.Select Failed')
- });
+ {
+ onSuccess(src: string | null) {
+ if (src) {
+ setValue('avatar', src);
+ }
+ },
+ errorToast: t('common:common.avatar.Select Failed')
+ }
+ );
- const { mutate: onRebuilding, isLoading: isRebuilding } = useRequest({
- mutationFn: (vectorModel: VectorModelItemType) => {
+ const { runAsync: onRebuilding, loading: isRebuilding } = useRequest2(
+ (vectorModel: VectorModelItemType) => {
return postRebuildEmbedding({
datasetId,
vectorModel: vectorModel.model
});
},
- onSuccess() {
- refetchDatasetTraining();
- loadDatasetDetail(datasetId);
- },
- successToast: t('dataset:rebuild_embedding_start_tip'),
- errorToast: t('common:common.Update Failed')
- });
+ {
+ onSuccess() {
+ refetchDatasetTraining();
+ loadDatasetDetail(datasetId);
+ },
+ successToast: t('dataset:rebuild_embedding_start_tip'),
+ errorToast: t('common:common.Update Failed')
+ }
+ );
- const { runAsync: onEditBaseInfo } = useRequest2((data) => updateDataset(data), {
- manual: true,
+ const { runAsync: onEditBaseInfo } = useRequest2(updateDataset, {
+ onSuccess() {
+ setEditedDataset(undefined);
+ },
successToast: t('common:common.Update Success'),
errorToast: t('common:common.Update Failed')
});
- const totalLoading = isSelecting || isSaving || isRebuilding;
-
return (
@@ -225,7 +240,7 @@ const Info = ({ datasetId }: { datasetId: string }) => {
if (!vectorModel) return;
return onOpenConfirmRebuild(() => {
setValue('vectorModel', vectorModel);
- onRebuilding(vectorModel);
+ return onRebuilding(vectorModel);
})();
}}
/>
@@ -260,7 +275,6 @@ const Info = ({ datasetId }: { datasetId: string }) => {
setValue('agentModel', agentModel);
return handleSubmit((data) => onSave({ ...data, agentModel: agentModel }))();
}}
- isDisabled={totalLoading}
/>
@@ -311,7 +325,6 @@ const Info = ({ datasetId }: { datasetId: string }) => {
fontSize={'mini'}
per={defaultPermission}
defaultPer={DatasetDefaultPermissionVal}
- isDisabled={totalLoading}
onChange={(v) => {
setValue('defaultPermission', v);
return handleSubmit((data) => onSave({ ...data, defaultPermission: v }))();
@@ -349,18 +362,15 @@ const Info = ({ datasetId }: { datasetId: string }) => {
{
- setEditedDataset(undefined);
- }}
- onEdit={async (data) => {
- await onEditBaseInfo({
+ onClose={() => setEditedDataset(undefined)}
+ onEdit={(data) =>
+ onEditBaseInfo({
id: editedDataset.id,
name: data.name,
intro: data.intro,
avatar: data.avatar
- });
- setEditedDataset(undefined);
- }}
+ })
+ }
/>
)}
diff --git a/projects/app/src/pages/dataset/detail/components/NavBar.tsx b/projects/app/src/pages/dataset/detail/components/NavBar.tsx
index fb4c328e3..4fd981e5c 100644
--- a/projects/app/src/pages/dataset/detail/components/NavBar.tsx
+++ b/projects/app/src/pages/dataset/detail/components/NavBar.tsx
@@ -115,7 +115,7 @@ const NavBar = ({ currentTab }: { currentTab: TabEnum }) => {
w={'100%'}
list={tabList}
value={currentTab}
- activatedColor="blue.700"
+ activeColor="primary.700"
onChange={setCurrentTab}
inlineStyles={{
fontSize: '1rem',
@@ -193,7 +193,7 @@ const NavBar = ({ currentTab }: { currentTab: TabEnum }) => {
) : (
-
+
m={'auto'}
w={'full'}
diff --git a/projects/app/src/pages/dataset/detail/components/Test.tsx b/projects/app/src/pages/dataset/detail/components/Test.tsx
index 58c4768d1..a19ebf099 100644
--- a/projects/app/src/pages/dataset/detail/components/Test.tsx
+++ b/projects/app/src/pages/dataset/detail/components/Test.tsx
@@ -4,7 +4,7 @@ import { useDatasetStore } from '@/web/core/dataset/store/dataset';
import { useSearchTestStore, SearchTestStoreItemType } from '@/web/core/dataset/store/searchTest';
import { postSearchText } from '@/web/core/dataset/api';
import MyIcon from '@fastgpt/web/components/common/Icon';
-import { useRequest } from '@fastgpt/web/hooks/useRequest';
+import { useRequest, useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
import { getErrText } from '@fastgpt/global/common/error/utils';
import { useToast } from '@fastgpt/web/hooks/useToast';
@@ -48,7 +48,6 @@ type FormType = {
const Test = ({ datasetId }: { datasetId: string }) => {
const { t } = useTranslation();
- const theme = useTheme();
const { toast } = useToast();
const { llmModelList } = useSystemStore();
const datasetDetail = useContextSelector(DatasetPageContext, (v) => v.datasetDetail);
@@ -86,40 +85,42 @@ const Test = ({ datasetId }: { datasetId: string }) => {
onClose: onCloseSelectMode
} = useDisclosure();
- const { mutate: onTextTest, isLoading: textTestIsLoading } = useRequest({
- mutationFn: ({ inputText, searchParams }: FormType) =>
+ const { runAsync: onTextTest, loading: textTestIsLoading } = useRequest2(
+ ({ inputText, searchParams }: FormType) =>
postSearchText({ datasetId, text: inputText.trim(), ...searchParams }),
- onSuccess(res: SearchTestResponse) {
- if (!res || res.list.length === 0) {
- return toast({
- status: 'warning',
- title: t('common:dataset.test.noResult')
+ {
+ onSuccess(res: SearchTestResponse) {
+ if (!res || res.list.length === 0) {
+ return toast({
+ status: 'warning',
+ title: t('common:dataset.test.noResult')
+ });
+ }
+
+ const testItem: SearchTestStoreItemType = {
+ id: nanoid(),
+ datasetId,
+ text: getValues('inputText').trim(),
+ time: new Date(),
+ results: res.list,
+ duration: res.duration,
+ searchMode: res.searchMode,
+ usingReRank: res.usingReRank,
+ limit: res.limit,
+ similarity: res.similarity,
+ queryExtensionModel: res.queryExtensionModel
+ };
+ pushDatasetTestItem(testItem);
+ setDatasetTestItem(testItem);
+ },
+ onError(err) {
+ toast({
+ title: getErrText(err),
+ status: 'error'
});
}
-
- const testItem: SearchTestStoreItemType = {
- id: nanoid(),
- datasetId,
- text: getValues('inputText').trim(),
- time: new Date(),
- results: res.list,
- duration: res.duration,
- searchMode: res.searchMode,
- usingReRank: res.usingReRank,
- limit: res.limit,
- similarity: res.similarity,
- queryExtensionModel: res.queryExtensionModel
- };
- pushDatasetTestItem(testItem);
- setDatasetTestItem(testItem);
- },
- onError(err) {
- toast({
- title: getErrText(err),
- status: 'error'
- });
}
- });
+ );
const onSelectFile = async (files: File[]) => {
const file = files[0];
@@ -329,6 +330,7 @@ const TestHistories = React.memo(function TestHistories({
() => datasetTestList.filter((item) => item.datasetId === datasetId),
[datasetId, datasetTestList]
);
+
return (
<>
diff --git a/projects/app/src/pages/dataset/detail/index.tsx b/projects/app/src/pages/dataset/detail/index.tsx
index 072cf7825..fa9ea4fb3 100644
--- a/projects/app/src/pages/dataset/detail/index.tsx
+++ b/projects/app/src/pages/dataset/detail/index.tsx
@@ -1,8 +1,7 @@
import React from 'react';
import { useRouter } from 'next/router';
-import { Box, Flex } from '@chakra-ui/react';
+import { Box, Flex, FlexProps } from '@chakra-ui/react';
import { useToast } from '@fastgpt/web/hooks/useToast';
-import { useQuery } from '@tanstack/react-query';
import { getErrText } from '@fastgpt/global/common/error/utils';
import dynamic from 'next/dynamic';
import PageContainer from '@/components/PageContainer';
@@ -36,6 +35,13 @@ export enum TabEnum {
}
type Props = { datasetId: string; currentTab: TabEnum };
+const sliderStyles: FlexProps = {
+ bg: 'white',
+ borderRadius: 'md',
+ overflowY: 'scroll',
+ boxShadow: 2
+};
+
const Detail = ({ datasetId, currentTab }: Props) => {
const { t } = useTranslation();
const { toast } = useToast();
@@ -64,20 +70,10 @@ const Detail = ({ datasetId, currentTab }: Props) => {
{isPc ? (
-
-
+
+
{currentTab !== TabEnum.import && }
-
+
{currentTab === TabEnum.collectionCard && (
@@ -88,27 +84,24 @@ const Detail = ({ datasetId, currentTab }: Props) => {
{currentTab === TabEnum.import && }
- {currentTab !== TabEnum.import && (
-
- {currentTab === TabEnum.dataCard ? (
+
+ {/* Slider */}
+ <>
+ {currentTab === TabEnum.dataCard && (
+
- ) : (
+
+ )}
+ {[TabEnum.collectionCard, TabEnum.test].includes(currentTab) && (
+
- )}
-
- )}
+
+ )}
+ >
) : (
-
+
{!!datasetDetail._id && (
diff --git a/projects/app/src/web/core/dataset/api.ts b/projects/app/src/web/core/dataset/api.ts
index c881601c2..81d758d0d 100644
--- a/projects/app/src/web/core/dataset/api.ts
+++ b/projects/app/src/web/core/dataset/api.ts
@@ -120,7 +120,7 @@ export const putDatasetCollectionById = (data: UpdateDatasetCollectionParams) =>
export const delDatasetCollectionById = (params: { id: string }) =>
DELETE(`/core/dataset/collection/delete`, params);
export const postLinkCollectionSync = (collectionId: string) =>
- POST<`${DatasetCollectionSyncResultEnum}`>(`/core/dataset/collection/sync/link`, {
+ POST(`/core/dataset/collection/sync/link`, {
collectionId
});
|