diff --git a/web/src/components/file-status-badge.tsx b/web/src/components/file-status-badge.tsx index b57da5f08..61ebf5c39 100644 --- a/web/src/components/file-status-badge.tsx +++ b/web/src/components/file-status-badge.tsx @@ -26,7 +26,7 @@ const FileStatusBadge: FC = ({ status, name }) => { case RunningStatus.UNSTART: return `bg-[rgba(250,173,20,0.1)] text-state-warning`; default: - return 'bg-gray-500/10 text-white'; + return 'bg-gray-500/10 text-text-secondary'; } }; @@ -45,7 +45,7 @@ const FileStatusBadge: FC = ({ status, name }) => { case RunningStatus.UNSTART: return `bg-[rgba(250,173,20,1)] text-state-warning`; default: - return 'bg-gray-500/10 text-white'; + return `bg-[rgba(117,120,122,1)] text-text-secondary`; } }; diff --git a/web/src/components/list-filter-bar/interface.ts b/web/src/components/list-filter-bar/interface.ts index 52206fc99..8f6cc5757 100644 --- a/web/src/components/list-filter-bar/interface.ts +++ b/web/src/components/list-filter-bar/interface.ts @@ -1,7 +1,7 @@ export type FilterType = { id: string; - label: string; - count: number; + label: string | JSX.Element; + count?: number; }; export type FilterCollection = { diff --git a/web/src/components/parse-configuration/raptor-form-fields.tsx b/web/src/components/parse-configuration/raptor-form-fields.tsx index 4571288c7..2e03526c5 100644 --- a/web/src/components/parse-configuration/raptor-form-fields.tsx +++ b/web/src/components/parse-configuration/raptor-form-fields.tsx @@ -67,19 +67,6 @@ const RaptorFormFields = ({ const { t } = useTranslate('knowledgeConfiguration'); const useRaptor = useWatch({ name: UseRaptorField }); - const changeRaptor = useCallback( - (isUseRaptor: boolean) => { - if (isUseRaptor) { - form.setValue(MaxTokenField, 256); - form.setValue(ThresholdField, 0.1); - form.setValue(MaxCluster, 64); - form.setValue(RandomSeedField, 0); - form.setValue(Prompt, t('promptText')); - } - }, - [form], - ); - const handleGenerate = useCallback(() => { form.setValue(RandomSeedField, random(10000)); }, [form]); @@ -90,10 +77,6 @@ const RaptorFormFields = ({ control={form.control} name={UseRaptorField} render={({ field }) => { - // if (typeof field.value === 'undefined') { - // // default value set - // form.setValue('parser_config.raptor.use_raptor', false); - // } return ( layout === FormLayout.Vertical, [layout]); + const isHorizontal = useMemo(() => layout !== FormLayout.Vertical, [layout]); return ( { return ( - + {children} @@ -58,9 +58,18 @@ const CommandList = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( + /** + * Solve the problem of the scroll wheel not working + * onWheel={(e) => e.stopPropagation()} + onMouseEnter={(e) => e.currentTarget.focus()} + tabIndex={-1} + */ e.stopPropagation()} + onMouseEnter={(e) => e.currentTarget.focus()} + tabIndex={-1} {...props} /> )); diff --git a/web/src/components/ui/tooltip.tsx b/web/src/components/ui/tooltip.tsx index 1ec8529d7..228ce8a60 100644 --- a/web/src/components/ui/tooltip.tsx +++ b/web/src/components/ui/tooltip.tsx @@ -20,7 +20,7 @@ const TooltipContent = React.forwardRef< ref={ref} sideOffset={sideOffset} className={cn( - 'z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-w-[20vw]', + 'z-50 overflow-auto scrollbar-auto rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-w-[20vw]', className, )} {...props} diff --git a/web/src/pages/dataflow-result/components/parse-editer/object-parser.tsx b/web/src/pages/dataflow-result/components/parse-editer/object-parser.tsx index bfb4b33f5..d95d586ca 100644 --- a/web/src/pages/dataflow-result/components/parse-editer/object-parser.tsx +++ b/web/src/pages/dataflow-result/components/parse-editer/object-parser.tsx @@ -48,9 +48,10 @@ export const ObjectContainer = (props: IObjContainerProps) => { useEffect(() => { if (activeEditIndex !== undefined && editDivRef.current) { editDivRef.current.focus(); - editDivRef.current.textContent = content.value; + editDivRef.current.textContent = content.value as string; + editDivRef.current.style.whiteSpace = 'pre-wrap'; } - }, [activeEditIndex, content]); + }, [activeEditIndex, content, editDivRef]); return ( <> diff --git a/web/src/pages/dataset/dataset-overview/hook.ts b/web/src/pages/dataset/dataset-overview/hook.ts index 164910ef3..62453a31e 100644 --- a/web/src/pages/dataset/dataset-overview/hook.ts +++ b/web/src/pages/dataset/dataset-overview/hook.ts @@ -33,7 +33,8 @@ const useFetchFileLogList = () => { const [searchParams] = useSearchParams(); const { searchString, handleInputChange } = useHandleSearchChange(); const { pagination, setPagination } = useGetPaginationWithRouter(); - const { filterValue, handleFilterSubmit } = useHandleFilterSubmit(); + const { filterValue, setFilterValue, handleFilterSubmit } = + useHandleFilterSubmit(); const { id } = useParams(); const [active, setActive] = useState<(typeof LogTabs)[keyof typeof LogTabs]>( LogTabs.FILE_LOGS, @@ -89,6 +90,7 @@ const useFetchFileLogList = () => { active, setActive, filterValue, + setFilterValue, handleFilterSubmit, }; }; diff --git a/web/src/pages/dataset/dataset-overview/index.tsx b/web/src/pages/dataset/dataset-overview/index.tsx index 39a89b80d..40aec8236 100644 --- a/web/src/pages/dataset/dataset-overview/index.tsx +++ b/web/src/pages/dataset/dataset-overview/index.tsx @@ -1,13 +1,14 @@ +import FileStatusBadge from '@/components/file-status-badge'; import { FilterCollection } from '@/components/list-filter-bar/interface'; import SvgIcon from '@/components/svg-icon'; import { useIsDarkTheme } from '@/components/theme-provider'; import { AntToolTip } from '@/components/ui/tooltip'; +import { RunningStatusMap } from '@/constants/knowledge'; import { useFetchDocumentList } from '@/hooks/use-document-request'; -import { t } from 'i18next'; import { CircleQuestionMark } from 'lucide-react'; import { FC, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { RunningStatus, RunningStatusMap } from '../dataset/constant'; +import { RunningStatus } from '../dataset/constant'; import { LogTabs } from './dataset-common'; import { DatasetFilter } from './dataset-filter'; import { useFetchFileLogList, useFetchOverviewTital } from './hook'; @@ -84,34 +85,6 @@ const CardFooterProcess: FC = ({ ); }; -const filters = [ - { - field: 'operation_status', - label: t('knowledgeDetails.status'), - list: Object.values(RunningStatus).map((value) => { - // const value = key as RunningStatus; - console.log(value); - return { - id: value, - label: RunningStatusMap[value].label, - }; - }), - }, - { - field: 'types', - label: t('knowledgeDetails.task'), - list: [ - { - id: 'Parse', - label: 'Parse', - }, - { - id: 'Download', - label: 'Download', - }, - ], - }, -]; const FileLogsPage: FC = () => { const { t } = useTranslation(); @@ -169,10 +142,56 @@ const FileLogsPage: FC = () => { setPagination, active, filterValue, + setFilterValue, handleFilterSubmit, setActive, } = useFetchFileLogList(); + const filters = useMemo(() => { + const filterCollection: FilterCollection[] = [ + { + field: 'operation_status', + label: t('knowledgeDetails.status'), + list: Object.values(RunningStatus).map((value) => { + // const value = key as RunningStatus; + console.log(value); + return { + id: value, + // label: RunningStatusMap[value].label, + label: ( + + ), + }; + }), + }, + // { + // field: 'types', + // label: t('knowledgeDetails.task'), + // list: [ + // { + // id: 'Parse', + // label: 'Parse', + // }, + // { + // id: 'Download', + // label: 'Download', + // }, + // ], + // }, + ]; + if (active === LogTabs.FILE_LOGS) { + return filterCollection; + } + if (active === LogTabs.DATASET_LOGS) { + const list = filterCollection.filter((item, index) => index === 0); + return list; + } + return []; + }, [active, t]); + const tableList = useMemo(() => { console.log('tableList', tableOriginData); if (tableOriginData && tableOriginData.logs?.length) { @@ -187,6 +206,7 @@ const FileLogsPage: FC = () => { }, [tableOriginData]); const changeActiveLogs = (active: (typeof LogTabs)[keyof typeof LogTabs]) => { + setFilterValue({}); setActive(active); }; const handlePaginationChange = (page: number, pageSize: number) => { diff --git a/web/src/pages/dataset/setting/advanced-setting-form.tsx b/web/src/pages/dataset/setting/advanced-setting-form.tsx deleted file mode 100644 index 69f1979df..000000000 --- a/web/src/pages/dataset/setting/advanced-setting-form.tsx +++ /dev/null @@ -1,157 +0,0 @@ -'use client'; - -import { zodResolver } from '@hookform/resolvers/zod'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; - -import { Button } from '@/components/ui/button'; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; -import { FormSlider } from '@/components/ui/slider'; -import { Textarea } from '@/components/ui/textarea'; -import ChunkMethodCard from './chunk-method-card'; - -const formSchema = z.object({ - parser_id: z.string().min(1, { - message: 'Username must be at least 2 characters.', - }), - a: z.number().min(2, { - message: 'Username must be at least 2 characters.', - }), - b: z.string().min(2, { - message: 'Username must be at least 2 characters.', - }), - c: z.number().min(2, { - message: 'Username must be at least 2 characters.', - }), - d: z.string().min(2, { - message: 'Username must be at least 2 characters.', - }), -}); - -export default function AdvancedSettingForm() { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - parser_id: '', - }, - }); - - function onSubmit(values: z.infer) { - console.log(values); - } - - return ( -
- - ( - - Username - - - - - This is your public display name. - - - - )} - /> - - ( - - Username - - - - - This is your public display name. - - - - )} - /> - ( - - Username - - - This is your public display name. - - - - )} - /> - ( - - Username - - - - - This is your public display name. - - - - )} - /> - ( - - Username - - - - - This is your public display name. - - - - )} - /> - - - - ); -} diff --git a/web/src/pages/dataset/setting/basic-setting-form.tsx b/web/src/pages/dataset/setting/basic-setting-form.tsx deleted file mode 100644 index f4b2466e7..000000000 --- a/web/src/pages/dataset/setting/basic-setting-form.tsx +++ /dev/null @@ -1,146 +0,0 @@ -'use client'; - -import { zodResolver } from '@hookform/resolvers/zod'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; - -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { Input } from '@/components/ui/input'; -import { MultiSelect } from '@/components/ui/multi-select'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; -import { useTranslate } from '@/hooks/common-hooks'; -import { Cat, Dog, Fish, Rabbit, Turtle } from 'lucide-react'; -import { useState } from 'react'; - -const frameworksList = [ - { value: 'react', label: 'React', icon: Turtle }, - { value: 'angular', label: 'Angular', icon: Cat }, - { value: 'vue', label: 'Vue', icon: Dog }, - { value: 'svelte', label: 'Svelte', icon: Rabbit }, - { value: 'ember', label: 'Ember', icon: Fish }, -]; - -export default function BasicSettingForm() { - const { t } = useTranslate('knowledgeConfiguration'); - - const formSchema = z.object({ - name: z.string().min(1), - a: z.number().min(2, { - message: 'Username must be at least 2 characters.', - }), - language: z.string().min(1, { - message: 'Username must be at least 2 characters.', - }), - c: z.number().min(2, { - message: 'Username must be at least 2 characters.', - }), - d: z.string().min(2, { - message: 'Username must be at least 2 characters.', - }), - }); - - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - name: '', - language: 'English', - }, - }); - const [selectedFrameworks, setSelectedFrameworks] = useState([ - 'react', - 'angular', - ]); - - function onSubmit(values: z.infer) { - console.log(values); - } - - return ( -
- - ( - - {t('name')} - - - - - - )} - /> - ( - - Username - - - - - - )} - /> - ( - - {t('language')} - - - - )} - /> - ( - - Username - - - - - - )} - /> - - - ); -} diff --git a/web/src/pages/dataset/setting/category-panel.tsx b/web/src/pages/dataset/setting/category-panel.tsx deleted file mode 100644 index 4e96fefcc..000000000 --- a/web/src/pages/dataset/setting/category-panel.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import SvgIcon from '@/components/svg-icon'; -import { useTranslate } from '@/hooks/common-hooks'; -import { useSelectParserList } from '@/hooks/user-setting-hooks'; -import { Col, Divider, Empty, Row, Typography } from 'antd'; -import DOMPurify from 'dompurify'; -import camelCase from 'lodash/camelCase'; -import { useMemo } from 'react'; -import styles from './index.less'; -import { TagTabs } from './tag-tabs'; -import { ImageMap } from './utils'; - -const { Text } = Typography; - -const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => { - const parserList = useSelectParserList(); - const { t } = useTranslate('knowledgeConfiguration'); - - const item = useMemo(() => { - const item = parserList.find((x) => x.value === chunkMethod); - if (item) { - return { - title: item.label, - description: t(camelCase(item.value)), - }; - } - return { title: '', description: '' }; - }, [parserList, chunkMethod, t]); - - const imageList = useMemo(() => { - if (chunkMethod in ImageMap) { - return ImageMap[chunkMethod as keyof typeof ImageMap]; - } - return []; - }, [chunkMethod]); - - return ( -
- {imageList.length > 0 ? ( - <> -
- {`"${item.title}" ${t('methodTitle')}`} -
-

-
{`"${item.title}" ${t('methodExamples')}`}
- {t('methodExamplesDescription')} - - {imageList.map((x) => ( - - - - ))} - -
- {item.title} {t('dialogueExamplesTitle')} -
- - - ) : ( - -

{t('methodEmpty')}

- -
- )} - {chunkMethod === 'tag' && } -
- ); -}; - -export default CategoryPanel; diff --git a/web/src/pages/dataset/setting/chunk-method-card.tsx b/web/src/pages/dataset/setting/chunk-method-card.tsx deleted file mode 100644 index 68114cf28..000000000 --- a/web/src/pages/dataset/setting/chunk-method-card.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import SvgIcon from '@/components/svg-icon'; -import { Card } from '@/components/ui/card'; -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/select'; -import { useTranslate } from '@/hooks/common-hooks'; -import { useSelectParserList } from '@/hooks/user-setting-hooks'; -import { Col, Divider, Empty, Row, Typography } from 'antd'; -import DOMPurify from 'dompurify'; -import camelCase from 'lodash/camelCase'; -import { useMemo } from 'react'; -import { useFormContext } from 'react-hook-form'; -import styles from './index.less'; -import { ImageMap } from './utils'; - -const { Title, Text } = Typography; - -const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => { - const parserList = useSelectParserList(); - const { t } = useTranslate('knowledgeConfiguration'); - - const item = useMemo(() => { - const item = parserList.find((x) => x.value === chunkMethod); - if (item) { - return { - title: item.label, - description: t(camelCase(item.value)), - }; - } - return { title: '', description: '' }; - }, [parserList, chunkMethod, t]); - - const imageList = useMemo(() => { - if (chunkMethod in ImageMap) { - return ImageMap[chunkMethod as keyof typeof ImageMap]; - } - return []; - }, [chunkMethod]); - - return ( -
- {imageList.length > 0 ? ( - <> - - {`"${item.title}" ${t('methodTitle')}`} - -

- {`"${item.title}" ${t('methodExamples')}`} - {t('methodExamplesDescription')} - - {imageList.map((x) => ( - - - - ))} - - - {item.title} {t('dialogueExamplesTitle')} - - - - ) : ( - -

{t('methodEmpty')}

- -
- )} -
- ); -}; - -export default function ChunkMethodCard() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - - return ( - -
- ( - - {t('chunkMethod')} - - - - )} - /> -
- -
- ); -} diff --git a/web/src/pages/dataset/setting/chunk-method-form.tsx b/web/src/pages/dataset/setting/chunk-method-form.tsx deleted file mode 100644 index 26f3e090f..000000000 --- a/web/src/pages/dataset/setting/chunk-method-form.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Button } from '@/components/ui/button'; -import { useFormContext, useWatch } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; - -import { DocumentParserType } from '@/constants/knowledge'; -import { useMemo } from 'react'; -import { AudioConfiguration } from './configuration/audio'; -import { BookConfiguration } from './configuration/book'; -import { EmailConfiguration } from './configuration/email'; -import { KnowledgeGraphConfiguration } from './configuration/knowledge-graph'; -import { LawsConfiguration } from './configuration/laws'; -import { ManualConfiguration } from './configuration/manual'; -import { NaiveConfiguration } from './configuration/naive'; -import { OneConfiguration } from './configuration/one'; -import { PaperConfiguration } from './configuration/paper'; -import { PictureConfiguration } from './configuration/picture'; -import { PresentationConfiguration } from './configuration/presentation'; -import { QAConfiguration } from './configuration/qa'; -import { ResumeConfiguration } from './configuration/resume'; -import { TableConfiguration } from './configuration/table'; -import { TagConfiguration } from './configuration/tag'; -import { SavingButton } from './saving-button'; - -const ConfigurationComponentMap = { - [DocumentParserType.Naive]: NaiveConfiguration, - [DocumentParserType.Qa]: QAConfiguration, - [DocumentParserType.Resume]: ResumeConfiguration, - [DocumentParserType.Manual]: ManualConfiguration, - [DocumentParserType.Table]: TableConfiguration, - [DocumentParserType.Paper]: PaperConfiguration, - [DocumentParserType.Book]: BookConfiguration, - [DocumentParserType.Laws]: LawsConfiguration, - [DocumentParserType.Presentation]: PresentationConfiguration, - [DocumentParserType.Picture]: PictureConfiguration, - [DocumentParserType.One]: OneConfiguration, - [DocumentParserType.Audio]: AudioConfiguration, - [DocumentParserType.Email]: EmailConfiguration, - [DocumentParserType.Tag]: TagConfiguration, - [DocumentParserType.KnowledgeGraph]: KnowledgeGraphConfiguration, -}; - -function EmptyComponent() { - return
; -} - -export function ChunkMethodForm() { - const form = useFormContext(); - const { t } = useTranslation(); - - const finalParserId: DocumentParserType = useWatch({ - control: form.control, - name: 'parser_id', - }); - - const ConfigurationComponent = useMemo(() => { - return finalParserId - ? ConfigurationComponentMap[finalParserId] - : EmptyComponent; - }, [finalParserId]); - - return ( -
-
- -
-
- - -
-
- ); -} diff --git a/web/src/pages/dataset/setting/chunk-method-learn-more.tsx b/web/src/pages/dataset/setting/chunk-method-learn-more.tsx deleted file mode 100644 index 850f90db5..000000000 --- a/web/src/pages/dataset/setting/chunk-method-learn-more.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { Button } from '@/components/ui/button'; -import { cn } from '@/lib/utils'; -import { t } from 'i18next'; -import { X } from 'lucide-react'; -import { useState } from 'react'; -import CategoryPanel from './category-panel'; - -export default ({ - tab = 'generalForm', - parserId, -}: { - tab: 'generalForm' | 'chunkMethodForm'; - parserId: string; -}) => { - const [visible, setVisible] = useState(false); - - return ( -
-
- -
-
- -
{ - setVisible(false); - }} - > - -
-
-
- ); -}; diff --git a/web/src/pages/dataset/setting/configuration-form-container.tsx b/web/src/pages/dataset/setting/configuration-form-container.tsx deleted file mode 100644 index 215f032dd..000000000 --- a/web/src/pages/dataset/setting/configuration-form-container.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { FormContainer, FormContainerProps } from '@/components/form-container'; -import { cn } from '@/lib/utils'; -import { PropsWithChildren } from 'react'; - -export function ConfigurationFormContainer({ - children, - className, -}: FormContainerProps) { - return ( - {children} - ); -} - -export function MainContainer({ children }: PropsWithChildren) { - return
{children}
; -} diff --git a/web/src/pages/dataset/setting/configuration/audio.tsx b/web/src/pages/dataset/setting/configuration/audio.tsx deleted file mode 100644 index f7f372f7a..000000000 --- a/web/src/pages/dataset/setting/configuration/audio.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function AudioConfiguration() { - return ( - - - - - - - <> - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/book.tsx b/web/src/pages/dataset/setting/configuration/book.tsx deleted file mode 100644 index 39f58f03f..000000000 --- a/web/src/pages/dataset/setting/configuration/book.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function BookConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/common-item.tsx b/web/src/pages/dataset/setting/configuration/common-item.tsx deleted file mode 100644 index 1ee6a8ad6..000000000 --- a/web/src/pages/dataset/setting/configuration/common-item.tsx +++ /dev/null @@ -1,287 +0,0 @@ -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { Radio } from '@/components/ui/radio'; -import { RAGFlowSelect } from '@/components/ui/select'; -import { Switch } from '@/components/ui/switch'; -import { useTranslate } from '@/hooks/common-hooks'; -import { ArrowUpRight } from 'lucide-react'; -import { useFormContext } from 'react-hook-form'; -import { - useHasParsedDocument, - useSelectChunkMethodList, - useSelectEmbeddingModelOptions, -} from '../hooks'; - -export function ChunkMethodItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - // const handleChunkMethodSelectChange = useHandleChunkMethodSelectChange(form); - const parserList = useSelectChunkMethodList(); - - return ( - ( - -
- - {t('chunkMethod')} - -
- - - -
-
-
-
- -
-
- )} - /> - ); -} - -export function EmbeddingModelItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - const embeddingModelOptions = useSelectEmbeddingModelOptions(); - const disabled = useHasParsedDocument(); - - return ( - ( - -
- - {t('embeddingModel')} - -
- - - -
-
-
-
- -
-
- )} - /> - ); -} - -export function ParseTypeItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - - return ( - ( - -
- - {t('parseType')} - -
- - -
- {t('builtIn')} - {t('manualSetup')} -
-
-
-
-
-
-
- -
-
- )} - /> - ); -} - -export function DataFlowItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - - return ( - ( - -
-
- - {t('dataFlow')} - -
- {t('buildItFromScratch')} - -
-
- -
- - - -
-
-
-
- -
-
- )} - /> - ); -} - -export function DataExtractKnowledgeItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - - return ( - <> - {' '} - ( - -
- - {t('extractKnowledgeGraph')} - -
- - - -
-
-
-
- -
-
- )} - />{' '} - ( - -
- - {t('useRAPTORToEnhanceRetrieval')} - -
- - - -
-
-
-
- -
-
- )} - /> - - ); -} - -export function TeamItem() { - const { t } = useTranslate('knowledgeConfiguration'); - const form = useFormContext(); - - return ( - ( - -
- - * - {t('team')} - -
- - - -
-
-
-
- -
-
- )} - /> - ); -} diff --git a/web/src/pages/dataset/setting/configuration/email.tsx b/web/src/pages/dataset/setting/configuration/email.tsx deleted file mode 100644 index 03f4cfcad..000000000 --- a/web/src/pages/dataset/setting/configuration/email.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function EmailConfiguration() { - return ( - - - - - - - <> - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/knowledge-graph.tsx b/web/src/pages/dataset/setting/configuration/knowledge-graph.tsx deleted file mode 100644 index 5e2170e97..000000000 --- a/web/src/pages/dataset/setting/configuration/knowledge-graph.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { DelimiterFormField } from '@/components/delimiter-form-field'; -import { EntityTypesFormField } from '@/components/entity-types-form-field'; -import { MaxTokenNumberFormField } from '@/components/max-token-number-from-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function KnowledgeGraphConfiguration() { - return ( - <> - - - - - - <> - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/laws.tsx b/web/src/pages/dataset/setting/configuration/laws.tsx deleted file mode 100644 index 76e819bef..000000000 --- a/web/src/pages/dataset/setting/configuration/laws.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function LawsConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/manual.tsx b/web/src/pages/dataset/setting/configuration/manual.tsx deleted file mode 100644 index da5e24c5a..000000000 --- a/web/src/pages/dataset/setting/configuration/manual.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function ManualConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/naive.tsx b/web/src/pages/dataset/setting/configuration/naive.tsx deleted file mode 100644 index 29b57ef08..000000000 --- a/web/src/pages/dataset/setting/configuration/naive.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { DelimiterFormField } from '@/components/delimiter-form-field'; -import { ExcelToHtmlFormField } from '@/components/excel-to-html-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import { MaxTokenNumberFormField } from '@/components/max-token-number-from-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function NaiveConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/one.tsx b/web/src/pages/dataset/setting/configuration/one.tsx deleted file mode 100644 index bd9c166de..000000000 --- a/web/src/pages/dataset/setting/configuration/one.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function OneConfiguration() { - return ( - - - - - - - - <> - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/paper.tsx b/web/src/pages/dataset/setting/configuration/paper.tsx deleted file mode 100644 index 3157bb141..000000000 --- a/web/src/pages/dataset/setting/configuration/paper.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function PaperConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/picture.tsx b/web/src/pages/dataset/setting/configuration/picture.tsx deleted file mode 100644 index bb908896f..000000000 --- a/web/src/pages/dataset/setting/configuration/picture.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function PictureConfiguration() { - return ( - - - - - - - <> - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/presentation.tsx b/web/src/pages/dataset/setting/configuration/presentation.tsx deleted file mode 100644 index f2a38c2c3..000000000 --- a/web/src/pages/dataset/setting/configuration/presentation.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { - AutoKeywordsFormField, - AutoQuestionsFormField, -} from '@/components/auto-keywords-form-field'; -import { LayoutRecognizeFormField } from '@/components/layout-recognize-form-field'; -import PageRankFormField from '@/components/page-rank-form-field'; -import GraphRagItems from '@/components/parse-configuration/graph-rag-form-fields'; -import RaptorFormFields from '@/components/parse-configuration/raptor-form-fields'; -import { - ConfigurationFormContainer, - MainContainer, -} from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function PresentationConfiguration() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/qa.tsx b/web/src/pages/dataset/setting/configuration/qa.tsx deleted file mode 100644 index 0f5d76f39..000000000 --- a/web/src/pages/dataset/setting/configuration/qa.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import PageRankFormField from '@/components/page-rank-form-field'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function QAConfiguration() { - return ( - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/resume.tsx b/web/src/pages/dataset/setting/configuration/resume.tsx deleted file mode 100644 index a5b3be198..000000000 --- a/web/src/pages/dataset/setting/configuration/resume.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import PageRankFormField from '@/components/page-rank-form-field'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { TagItems } from '../tag-item'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function ResumeConfiguration() { - return ( - - - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/table.tsx b/web/src/pages/dataset/setting/configuration/table.tsx deleted file mode 100644 index 947a633a9..000000000 --- a/web/src/pages/dataset/setting/configuration/table.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import PageRankFormField from '@/components/page-rank-form-field'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function TableConfiguration() { - return ( - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/configuration/tag.tsx b/web/src/pages/dataset/setting/configuration/tag.tsx deleted file mode 100644 index 5e6b3a2b9..000000000 --- a/web/src/pages/dataset/setting/configuration/tag.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import PageRankFormField from '@/components/page-rank-form-field'; -import { ConfigurationFormContainer } from '../configuration-form-container'; -import { ChunkMethodItem, EmbeddingModelItem } from './common-item'; - -export function TagConfiguration() { - return ( - - - - - - - ); -} diff --git a/web/src/pages/dataset/setting/form-schema.ts b/web/src/pages/dataset/setting/form-schema.ts deleted file mode 100644 index 1594ba362..000000000 --- a/web/src/pages/dataset/setting/form-schema.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { z } from 'zod'; - -export const formSchema = z.object({ - name: z.string().min(1, { - message: 'Username must be at least 2 characters.', - }), - description: z.string().min(2, { - message: 'Username must be at least 2 characters.', - }), - // avatar: z.instanceof(File), - avatar: z.any().nullish(), - permission: z.string().optional(), - parser_id: z.string(), - embd_id: z.string(), - parser_config: z - .object({ - layout_recognize: z.string(), - chunk_token_num: z.number(), - delimiter: z.string(), - auto_keywords: z.number().optional(), - auto_questions: z.number().optional(), - html4excel: z.boolean(), - tag_kb_ids: z.array(z.string()).nullish(), - topn_tags: z.number().optional(), - raptor: z - .object({ - use_raptor: z.boolean().optional(), - prompt: z.string().optional(), - max_token: z.number().optional(), - threshold: z.number().optional(), - max_cluster: z.number().optional(), - random_seed: z.number().optional(), - }) - .refine( - (data) => { - if (data.use_raptor && !data.prompt) { - return false; - } - return true; - }, - { - message: 'Prompt is required', - path: ['prompt'], - }, - ), - graphrag: z - .object({ - use_graphrag: z.boolean().optional(), - entity_types: z.array(z.string()).optional(), - method: z.string().optional(), - resolution: z.boolean().optional(), - community: z.boolean().optional(), - }) - .refine( - (data) => { - if ( - data.use_graphrag && - (!data.entity_types || data.entity_types.length === 0) - ) { - return false; - } - return true; - }, - { - message: 'Please enter Entity types', - path: ['entity_types'], - }, - ), - }) - .optional(), - pagerank: z.number(), - // icon: z.array(z.instanceof(File)), -}); diff --git a/web/src/pages/dataset/setting/general-form.tsx b/web/src/pages/dataset/setting/general-form.tsx deleted file mode 100644 index 34be01db7..000000000 --- a/web/src/pages/dataset/setting/general-form.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { AvatarUpload } from '@/components/avatar-upload'; -import { FormContainer } from '@/components/form-container'; -import { Button } from '@/components/ui/button'; -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { Input } from '@/components/ui/input'; -import { useFormContext } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import { PermissionFormField } from './permission-form-field'; -import { GeneralSavingButton } from './saving-button'; - -export function GeneralForm() { - const form = useFormContext(); - const { t } = useTranslation(); - - return ( - <> - - ( - -
- - * - {t('common.name')} - - - - -
-
-
- -
-
- )} - /> - ( - -
- - {t('setting.avatar')} - - - - -
-
-
- -
-
- )} - /> - { - // null initialize empty string - if (typeof field.value === 'object' && !field.value) { - form.setValue('description', ' '); - } - return ( - -
- - {t('flow.description')} - - - - -
-
-
- -
-
- ); - }} - /> - -
-
- - -
- - ); -} diff --git a/web/src/pages/dataset/setting/hooks.ts b/web/src/pages/dataset/setting/hooks.ts deleted file mode 100644 index 3332ca3f5..000000000 --- a/web/src/pages/dataset/setting/hooks.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { LlmModelType } from '@/constants/knowledge'; -import { useSetModalState } from '@/hooks/common-hooks'; - -import { useSelectLlmOptionsByModelType } from '@/hooks/llm-hooks'; -import { useFetchKnowledgeBaseConfiguration } from '@/hooks/use-knowledge-request'; -import { useSelectParserList } from '@/hooks/user-setting-hooks'; -import { useIsFetching } from '@tanstack/react-query'; -import { pick } from 'lodash'; -import { useCallback, useEffect, useState } from 'react'; -import { UseFormReturn } from 'react-hook-form'; -import { z } from 'zod'; -import { formSchema } from './form-schema'; - -// The value that does not need to be displayed in the analysis method Select -const HiddenFields = ['email', 'picture', 'audio']; - -export function useSelectChunkMethodList() { - const parserList = useSelectParserList(); - - return parserList.filter((x) => !HiddenFields.some((y) => y === x.value)); -} - -export function useSelectEmbeddingModelOptions() { - const allOptions = useSelectLlmOptionsByModelType(); - return allOptions[LlmModelType.Embedding]; -} - -export function useHasParsedDocument() { - const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration(); - return knowledgeDetails.chunk_num > 0; -} - -export const useFetchKnowledgeConfigurationOnMount = ( - form: UseFormReturn, any, undefined>, -) => { - const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration(); - - useEffect(() => { - const parser_config = { - ...form.formState?.defaultValues?.parser_config, - ...knowledgeDetails.parser_config, - }; - const formValues = { - ...pick({ ...knowledgeDetails, parser_config: parser_config }, [ - 'description', - 'name', - 'permission', - 'embd_id', - 'parser_id', - 'language', - 'parser_config', - 'pagerank', - 'avatar', - ]), - }; - form.reset(formValues); - }, [form, knowledgeDetails]); - - return knowledgeDetails; -}; - -export const useSelectKnowledgeDetailsLoading = () => - useIsFetching({ queryKey: ['fetchKnowledgeDetail'] }) > 0; - -export const useRenameKnowledgeTag = () => { - const [tag, setTag] = useState(''); - const { - visible: tagRenameVisible, - hideModal: hideTagRenameModal, - showModal: showFileRenameModal, - } = useSetModalState(); - - const handleShowTagRenameModal = useCallback( - (record: string) => { - setTag(record); - showFileRenameModal(); - }, - [showFileRenameModal], - ); - - return { - initialName: tag, - tagRenameVisible, - hideTagRenameModal, - showTagRenameModal: handleShowTagRenameModal, - }; -}; diff --git a/web/src/pages/dataset/setting/index.less b/web/src/pages/dataset/setting/index.less deleted file mode 100644 index 4889e3776..000000000 --- a/web/src/pages/dataset/setting/index.less +++ /dev/null @@ -1,45 +0,0 @@ -.tags { - margin-bottom: 24px; -} - -.preset { - display: flex; - height: 80px; - background-color: rgba(0, 0, 0, 0.1); - border-radius: 5px; - padding: 5px; - margin-bottom: 24px; - - .left { - flex: 1; - } - - .right { - width: 100px; - border-left: 1px solid rgba(0, 0, 0, 0.4); - margin: 10px 0px; - padding: 5px; - } -} - -.configurationWrapper { - padding: 0 52px; - .buttonWrapper { - text-align: right; - } - .variableSlider { - width: 100%; - } -} - -.categoryPanelWrapper { - .topTitle { - margin-top: 0; - } - .imageRow { - margin-top: 16px; - } - .image { - width: 100%; - } -} diff --git a/web/src/pages/dataset/setting/index.tsx b/web/src/pages/dataset/setting/index.tsx deleted file mode 100644 index 9115339b9..000000000 --- a/web/src/pages/dataset/setting/index.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { Form } from '@/components/ui/form'; -import { - Tabs, - TabsContent, - TabsList, - TabsTrigger, -} from '@/components/ui/tabs-underlined'; -import { DocumentParserType } from '@/constants/knowledge'; -import { PermissionRole } from '@/constants/permission'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { useState } from 'react'; -import { useForm, useWatch } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import { z } from 'zod'; -import { TopTitle } from '../dataset-title'; -import { ChunkMethodForm } from './chunk-method-form'; -import ChunkMethodLearnMore from './chunk-method-learn-more'; -import { formSchema } from './form-schema'; -import { GeneralForm } from './general-form'; -import { useFetchKnowledgeConfigurationOnMount } from './hooks'; - -const enum DocumentType { - DeepDOC = 'DeepDOC', - PlainText = 'Plain Text', -} - -const initialEntityTypes = [ - 'organization', - 'person', - 'geo', - 'event', - 'category', -]; - -const enum MethodValue { - General = 'general', - Light = 'light', -} - -export default function DatasetSettings() { - const { t } = useTranslation(); - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - name: '', - parser_id: DocumentParserType.Naive, - permission: PermissionRole.Me, - parser_config: { - layout_recognize: DocumentType.DeepDOC, - chunk_token_num: 512, - delimiter: `\n`, - auto_keywords: 0, - auto_questions: 0, - html4excel: false, - topn_tags: 3, - raptor: { - use_raptor: false, - }, - graphrag: { - use_graphrag: false, - entity_types: initialEntityTypes, - method: MethodValue.Light, - }, - }, - pagerank: 0, - }, - }); - - useFetchKnowledgeConfigurationOnMount(form); - - const [currentTab, setCurrentTab] = useState< - 'generalForm' | 'chunkMethodForm' - >('generalForm'); // currnet Tab state - - const parserId = useWatch({ - control: form.control, - name: 'parser_id', - }); - - async function onSubmit(data: z.infer) { - console.log('🚀 ~ DatasetSettings ~ data:', data); - } - - return ( -
- -
-
- - { - setCurrentTab(val); - }} - className="h-full flex flex-col" - > - - -
- - {t('knowledgeDetails.general')} - -
-
- -
- - {t('knowledgeDetails.chunkMethodTab')} - -
-
-
- - - - - - -
-
- - -
-
- ); -} diff --git a/web/src/pages/dataset/setting/permission-form-field.tsx b/web/src/pages/dataset/setting/permission-form-field.tsx deleted file mode 100644 index ac095a79c..000000000 --- a/web/src/pages/dataset/setting/permission-form-field.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { SelectWithSearch } from '@/components/originui/select-with-search'; -import { RAGFlowFormItem } from '@/components/ragflow-form'; -import { PermissionRole } from '@/constants/permission'; -import { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; - -export function PermissionFormField() { - const { t } = useTranslation(); - const teamOptions = useMemo(() => { - return Object.values(PermissionRole).map((x) => ({ - label: t('knowledgeConfiguration.' + x), - value: x, - })); - }, [t]); - - return ( - - - - ); -} diff --git a/web/src/pages/dataset/setting/saving-button.tsx b/web/src/pages/dataset/setting/saving-button.tsx deleted file mode 100644 index 1fac81ea7..000000000 --- a/web/src/pages/dataset/setting/saving-button.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { ButtonLoading } from '@/components/ui/button'; -import { useUpdateKnowledge } from '@/hooks/use-knowledge-request'; -import { useMemo } from 'react'; -import { useFormContext } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import { useParams } from 'umi'; - -export function GeneralSavingButton() { - const form = useFormContext(); - const { saveKnowledgeConfiguration, loading: submitLoading } = - useUpdateKnowledge(); - const { id: kb_id } = useParams(); - const { t } = useTranslation(); - - const defaultValues = useMemo( - () => form.formState.defaultValues ?? {}, - [form.formState.defaultValues], - ); - const parser_id = defaultValues['parser_id']; - - return ( - { - (async () => { - let isValidate = await form.trigger('name'); - const { name, description, permission, avatar } = form.getValues(); - - if (isValidate) { - saveKnowledgeConfiguration({ - kb_id, - parser_id, - name, - description, - avatar, - permission, - }); - } - })(); - }} - > - {t('knowledgeConfiguration.save')} - - ); -} - -export function SavingButton() { - const { saveKnowledgeConfiguration, loading: submitLoading } = - useUpdateKnowledge(); - const form = useFormContext(); - const { id: kb_id } = useParams(); - const { t } = useTranslation(); - - return ( - { - (async () => { - try { - let beValid = await form.formControl.trigger(); - if (beValid) { - form.handleSubmit(async (values) => { - console.log('saveKnowledgeConfiguration: ', values); - delete values['avatar']; - await saveKnowledgeConfiguration({ - kb_id, - ...values, - }); - })(); - } - } catch (e) { - console.log(e); - } finally { - } - })(); - }} - > - {t('knowledgeConfiguration.save')} - - ); -} diff --git a/web/src/pages/dataset/setting/tag-item.tsx b/web/src/pages/dataset/setting/tag-item.tsx deleted file mode 100644 index c5ccecca4..000000000 --- a/web/src/pages/dataset/setting/tag-item.tsx +++ /dev/null @@ -1,155 +0,0 @@ -import { RAGFlowAvatar } from '@/components/ragflow-avatar'; -import { SliderInputFormField } from '@/components/slider-input-form-field'; -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { MultiSelect } from '@/components/ui/multi-select'; -import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; -import { Flex, Form, InputNumber, Select, Slider, Space } from 'antd'; -import DOMPurify from 'dompurify'; -import { useFormContext, useWatch } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; - -export const TagSetItem = () => { - const { t } = useTranslation(); - const form = useFormContext(); - - const { list: knowledgeList } = useFetchKnowledgeList(true); - - const knowledgeOptions = knowledgeList - .filter((x) => x.parser_id === 'tag') - .map((x) => ({ - label: x.name, - value: x.id, - icon: () => ( - - - - ), - })); - - return ( - ( - -
-
- } - > - {t('knowledgeConfiguration.tagSet')} - -
- - - -
- -
-
- -
-
- )} - /> - ); - - return ( - - } - rules={[ - { - message: t('chat.knowledgeBasesMessage'), - type: 'array', - }, - ]} - > - - - ); -}; - -export const TopNTagsItem = () => { - const { t } = useTranslation(); - - return ( - - ); - - return ( - - - - - - - - - - - - - ); -}; - -export function TagItems() { - const form = useFormContext(); - const ids: string[] = useWatch({ - control: form.control, - name: 'parser_config.tag_kb_ids', - }); - - return ( - <> - - {Array.isArray(ids) && ids.length > 0 && } - - ); -} diff --git a/web/src/pages/dataset/setting/tag-table/index.tsx b/web/src/pages/dataset/setting/tag-table/index.tsx deleted file mode 100644 index a2e38018c..000000000 --- a/web/src/pages/dataset/setting/tag-table/index.tsx +++ /dev/null @@ -1,305 +0,0 @@ -'use client'; - -import { - ColumnDef, - ColumnFiltersState, - SortingState, - VisibilityState, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from '@tanstack/react-table'; -import { ArrowUpDown, Pencil, Trash2 } from 'lucide-react'; -import * as React from 'react'; - -import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog'; -import { Button } from '@/components/ui/button'; -import { Checkbox } from '@/components/ui/checkbox'; -import { Input } from '@/components/ui/input'; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from '@/components/ui/table'; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@/components/ui/tooltip'; -import { useDeleteTag, useFetchTagList } from '@/hooks/knowledge-hooks'; -import { useCallback, useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useRenameKnowledgeTag } from '../hooks'; -import { RenameDialog } from './rename-dialog'; - -export type ITag = { - tag: string; - frequency: number; -}; - -export function TagTable() { - const { t } = useTranslation(); - const { list } = useFetchTagList(); - const [tagList, setTagList] = useState([]); - - const [sorting, setSorting] = React.useState([]); - const [columnFilters, setColumnFilters] = React.useState( - [], - ); - const [columnVisibility, setColumnVisibility] = - React.useState({}); - const [rowSelection, setRowSelection] = useState({}); - - const { deleteTag } = useDeleteTag(); - - useEffect(() => { - setTagList(list.map((x) => ({ tag: x[0], frequency: x[1] }))); - }, [list]); - - const handleDeleteTag = useCallback( - (tags: string[]) => () => { - deleteTag(tags); - }, - [deleteTag], - ); - - const { - showTagRenameModal, - hideTagRenameModal, - tagRenameVisible, - initialName, - } = useRenameKnowledgeTag(); - - const columns: ColumnDef[] = [ - { - id: 'select', - header: ({ table }) => ( - table.toggleAllPageRowsSelected(!!value)} - aria-label="Select all" - /> - ), - cell: ({ row }) => ( - row.toggleSelected(!!value)} - aria-label="Select row" - /> - ), - enableSorting: false, - enableHiding: false, - }, - { - accessorKey: 'tag', - header: ({ column }) => { - return ( - - ); - }, - cell: ({ row }) => { - const value: string = row.getValue('tag'); - return
{value}
; - }, - }, - { - accessorKey: 'frequency', - header: ({ column }) => { - return ( - - ); - }, - cell: ({ row }) => ( -
{row.getValue('frequency')}
- ), - }, - { - id: 'actions', - enableHiding: false, - header: t('common.action'), - cell: ({ row }) => { - return ( -
- - - - - - - -

{t('common.delete')}

-
-
- - - - - -

{t('common.rename')}

-
-
-
- ); - }, - }, - ]; - - const table = useReactTable({ - data: tagList, - columns, - onSortingChange: setSorting, - onColumnFiltersChange: setColumnFilters, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, - state: { - sorting, - columnFilters, - columnVisibility, - rowSelection, - }, - }); - - const selectedRowLength = table.getFilteredSelectedRowModel().rows.length; - - return ( - -
-
- - table.getColumn('tag')?.setFilterValue(event.target.value) - } - className="w-1/2" - /> - {selectedRowLength > 0 && ( - x.original.tag), - )} - > - - - )} -
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ); - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext(), - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
-
- {selectedRowLength} of {table.getFilteredRowModel().rows.length}{' '} - row(s) selected. -
-
- - -
-
- {tagRenameVisible && ( - - )} -
- ); -} diff --git a/web/src/pages/dataset/setting/tag-table/rename-dialog/index.tsx b/web/src/pages/dataset/setting/tag-table/rename-dialog/index.tsx deleted file mode 100644 index b95907f92..000000000 --- a/web/src/pages/dataset/setting/tag-table/rename-dialog/index.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, -} from '@/components/ui/dialog'; -import { LoadingButton } from '@/components/ui/loading-button'; -import { useTagIsRenaming } from '@/hooks/knowledge-hooks'; -import { IModalProps } from '@/interfaces/common'; -import { TagRenameId } from '@/pages/add-knowledge/constant'; -import { useTranslation } from 'react-i18next'; -import { RenameForm } from './rename-form'; - -export function RenameDialog({ - hideModal, - initialName, -}: IModalProps & { initialName: string }) { - const { t } = useTranslation(); - const loading = useTagIsRenaming(); - - return ( - - - - {t('common.rename')} - - - - - {t('common.save')} - - - - - ); -} diff --git a/web/src/pages/dataset/setting/tag-table/rename-dialog/rename-form.tsx b/web/src/pages/dataset/setting/tag-table/rename-dialog/rename-form.tsx deleted file mode 100644 index 9c8f1cf7e..000000000 --- a/web/src/pages/dataset/setting/tag-table/rename-dialog/rename-form.tsx +++ /dev/null @@ -1,83 +0,0 @@ -'use client'; - -import { zodResolver } from '@hookform/resolvers/zod'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; - -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { Input } from '@/components/ui/input'; -import { useRenameTag } from '@/hooks/knowledge-hooks'; -import { IModalProps } from '@/interfaces/common'; -import { TagRenameId } from '@/pages/add-knowledge/constant'; -import { useEffect } from 'react'; -import { useTranslation } from 'react-i18next'; - -export function RenameForm({ - initialName, - hideModal, -}: IModalProps & { initialName: string }) { - const { t } = useTranslation(); - const FormSchema = z.object({ - name: z - .string() - .min(1, { - message: t('common.namePlaceholder'), - }) - .trim(), - }); - - const form = useForm>({ - resolver: zodResolver(FormSchema), - defaultValues: { - name: '', - }, - }); - - const { renameTag } = useRenameTag(); - - async function onSubmit(data: z.infer) { - const ret = await renameTag({ fromTag: initialName, toTag: data.name }); - if (ret) { - hideModal?.(); - } - } - - useEffect(() => { - form.setValue('name', initialName); - }, [form, initialName]); - - return ( -
- - ( - - {t('common.name')} - - - - - - )} - /> - - - ); -} diff --git a/web/src/pages/dataset/setting/tag-tabs.tsx b/web/src/pages/dataset/setting/tag-tabs.tsx deleted file mode 100644 index abcd3f673..000000000 --- a/web/src/pages/dataset/setting/tag-tabs.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Segmented } from 'antd'; -import { SegmentedLabeledOption } from 'antd/es/segmented'; -import { upperFirst } from 'lodash'; -import { useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { TagTable } from './tag-table'; -import { TagWordCloud } from './tag-word-cloud'; - -enum TagType { - Cloud = 'cloud', - Table = 'table', -} - -const TagContentMap = { - [TagType.Cloud]: , - [TagType.Table]: , -}; - -export function TagTabs() { - const [value, setValue] = useState(TagType.Cloud); - const { t } = useTranslation(); - - const options: SegmentedLabeledOption[] = [TagType.Cloud, TagType.Table].map( - (x) => ({ - label: t(`knowledgeConfiguration.tag${upperFirst(x)}`), - value: x, - }), - ); - - return ( -
- setValue(val as TagType)} - /> - {TagContentMap[value]} -
- ); -} diff --git a/web/src/pages/dataset/setting/tag-word-cloud.tsx b/web/src/pages/dataset/setting/tag-word-cloud.tsx deleted file mode 100644 index b71ed69af..000000000 --- a/web/src/pages/dataset/setting/tag-word-cloud.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { useFetchTagList } from '@/hooks/knowledge-hooks'; -import { Chart } from '@antv/g2'; -import { sumBy } from 'lodash'; -import { useCallback, useEffect, useMemo, useRef } from 'react'; - -export function TagWordCloud() { - const domRef = useRef(null); - let chartRef = useRef(); - const { list } = useFetchTagList(); - - const { list: tagList } = useMemo(() => { - const nextList = list.sort((a, b) => b[1] - a[1]).slice(0, 256); - - return { - list: nextList.map((x) => ({ text: x[0], value: x[1], name: x[0] })), - sumValue: sumBy(nextList, (x: [string, number]) => x[1]), - length: nextList.length, - }; - }, [list]); - - const renderWordCloud = useCallback(() => { - if (domRef.current) { - chartRef.current = new Chart({ container: domRef.current }); - - chartRef.current.options({ - type: 'wordCloud', - autoFit: true, - layout: { - fontSize: [10, 50], - // fontSize: (d: any) => { - // if (d.value) { - // return (d.value / sumValue) * 100 * (length / 10); - // } - // return 0; - // }, - }, - data: { - type: 'inline', - value: tagList, - }, - encode: { color: 'text' }, - legend: false, - tooltip: { - title: 'name', // title - items: ['value'], // data item - }, - }); - - chartRef.current.render(); - } - }, [tagList]); - - useEffect(() => { - renderWordCloud(); - - return () => { - chartRef.current?.destroy(); - }; - }, [renderWordCloud]); - - return
; -} diff --git a/web/src/pages/dataset/setting/utils.ts b/web/src/pages/dataset/setting/utils.ts deleted file mode 100644 index 4c5666467..000000000 --- a/web/src/pages/dataset/setting/utils.ts +++ /dev/null @@ -1,20 +0,0 @@ -const getImageName = (prefix: string, length: number) => - new Array(length) - .fill(0) - .map((x, idx) => `chunk-method/${prefix}-0${idx + 1}`); - -export const ImageMap = { - book: getImageName('book', 4), - laws: getImageName('law', 2), - manual: getImageName('manual', 4), - picture: getImageName('media', 2), - naive: getImageName('naive', 2), - paper: getImageName('paper', 2), - presentation: getImageName('presentation', 2), - qa: getImageName('qa', 2), - resume: getImageName('resume', 2), - table: getImageName('table', 2), - one: getImageName('one', 2), - knowledge_graph: getImageName('knowledge-graph', 2), - tag: getImageName('tag', 2), -}; diff --git a/web/src/pages/dataset/sidebar/index.tsx b/web/src/pages/dataset/sidebar/index.tsx index 277eb6b83..c612f2059 100644 --- a/web/src/pages/dataset/sidebar/index.tsx +++ b/web/src/pages/dataset/sidebar/index.tsx @@ -1,3 +1,4 @@ +import { IconFontFill } from '@/components/icon-font'; import { RAGFlowAvatar } from '@/components/ragflow-avatar'; import { Button } from '@/components/ui/button'; import { useSecondPathName } from '@/hooks/route-hook'; diff --git a/web/src/routes.ts b/web/src/routes.ts index f2f9a47c0..a1ee7dc75 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -30,7 +30,6 @@ export enum Routes { ProfilePrompt = `${ProfileSetting}${Prompt}`, ProfileProfile = `${ProfileSetting}${Profile}`, DatasetTesting = '/testing', - DatasetSetting = '/setting', Chunk = '/chunk', ChunkResult = `${Chunk}${Chunk}`, Parsed = '/parsed', @@ -262,10 +261,6 @@ const routes = [ path: `${Routes.Dataset}/:id`, component: `@/pages${Routes.Dataset}`, }, - { - path: `${Routes.DatasetBase}${Routes.DatasetSetting}/:id`, - component: `@/pages${Routes.DatasetBase}${Routes.DatasetSetting}`, - }, { path: `${Routes.DatasetBase}${Routes.DatasetTesting}/:id`, component: `@/pages${Routes.DatasetBase}${Routes.DatasetTesting}`, diff --git a/web/tailwind.css b/web/tailwind.css index fc96e6232..a65a4b609 100644 --- a/web/tailwind.css +++ b/web/tailwind.css @@ -119,7 +119,7 @@ /* --state-success: #3ba05c; */ --state-success: 59 160 92; /* --state-warning: #767573; */ - --state-warning: 118 117 115; + --state-warning: 250 173 20; --state-error: 216 73 75; --team-group: #5ab77e;