Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Revert "Feat/parent child retrieval" (#12095)
-LAN-db2aa83a7c2a
diff --git a/api/poetry.lock b/api/poetry.lockindex b2d22a887db..b42eb22dd40 100644--- a/api/poetry.lock+++ b/api/poetry.lock@@ -1,15 +1,4 @@-# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand.--[[package]]-name = "aiofiles"-version = "24.1.0"-description = "File support for asyncio."-optional = false-python-versions = ">=3.8"-files = [- {file = "aiofiles-24.1.0-py3-none-any.whl", hash = "sha256:b4ec55f4195e3eb5d7abd1bf7e061763e864dd4954231fb8539a0ef8bb8260e5"},- {file = "aiofiles-24.1.0.tar.gz", hash = "sha256:22a075c9e5a3810f0c2e48f3008c94d68c65d763b9b03857924c99e57355166c"},-]+# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.[[package]]name = "aiofiles"diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsxindex a6fb116fa8a..b416659a6a1 100644--- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx+++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx@@ -7,36 +7,85 @@ import { useTranslation } from 'react-i18next'import { useBoolean } from 'ahooks'import {Cog8ToothIcon,+ // CommandLineIcon,+ Squares2X2Icon,+ // eslint-disable-next-line sort-imports+ PuzzlePieceIcon,DocumentTextIcon,PaperClipIcon,+ QuestionMarkCircleIcon,} from '@heroicons/react/24/outline'import {Cog8ToothIcon as Cog8ToothSolidIcon,// CommandLineIcon as CommandLineSolidIcon,DocumentTextIcon as DocumentTextSolidIcon,} from '@heroicons/react/24/solid'-import { RiApps2AddLine, RiInformation2Line } from '@remixicon/react'+import Link from 'next/link'import s from './style.module.css'import classNames from '@/utils/classnames'import { fetchDatasetDetail, fetchDatasetRelatedApps } from '@/service/datasets'-import type { RelatedAppResponse } from '@/models/datasets'+import type { RelatedApp, RelatedAppResponse } from '@/models/datasets'import AppSideBar from '@/app/components/app-sidebar'+import Divider from '@/app/components/base/divider'+import AppIcon from '@/app/components/base/app-icon'import Loading from '@/app/components/base/loading'+import FloatPopoverContainer from '@/app/components/base/float-popover-container'import DatasetDetailContext from '@/context/dataset-detail'import { DataSourceType } from '@/models/datasets'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'import { LanguagesSupported } from '@/i18n/language'import { useStore } from '@/app/components/app/store'+import { AiText, ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/solid/communication'+import { Route } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel'import { getLocaleOnClient } from '@/i18n'import { useAppContext } from '@/context/app-context'-import Tooltip from '@/app/components/base/tooltip'-import LinkedAppsPanel from '@/app/components/base/linked-apps-panel'export type IAppDetailLayoutProps = {children: React.ReactNodeparams: { datasetId: string }}+type ILikedItemProps = {+ type?: 'plugin' | 'app'+ appStatus?: boolean+ detail: RelatedApp+ isMobile: boolean+}++const LikedItem = ({+ type = 'app',+ detail,+ isMobile,+}: ILikedItemProps) => {+ return (+ <Link className={classNames(s.itemWrapper, 'px-2', isMobile && 'justify-center')} href={`/app/${detail?.id}/overview`}>+ <div className={classNames(s.iconWrapper, 'mr-0')}>+ <AppIcon size='tiny' iconType={detail.icon_type} icon={detail.icon} background={detail.icon_background} imageUrl={detail.icon_url} />+ {type === 'app' && (+ <span className='absolute bottom-[-2px] right-[-2px] w-3.5 h-3.5 p-0.5 bg-white rounded border-[0.5px] border-[rgba(0,0,0,0.02)] shadow-sm'>+ {detail.mode === 'advanced-chat' && (+ <ChatBot className='w-2.5 h-2.5 text-[#1570EF]' />+ )}+ {detail.mode === 'agent-chat' && (+ <CuteRobot className='w-2.5 h-2.5 text-indigo-600' />+ )}+ {detail.mode === 'chat' && (+ <ChatBot className='w-2.5 h-2.5 text-[#1570EF]' />+ )}+ {detail.mode === 'completion' && (+ <AiText className='w-2.5 h-2.5 text-[#0E9384]' />+ )}+ {detail.mode === 'workflow' && (+ <Route className='w-2.5 h-2.5 text-[#f79009]' />+ )}+ </span>+ )}+ </div>+ {!isMobile && <div className={classNames(s.appInfo, 'ml-2')}>{detail?.name || '--'}</div>}+ </Link>+ )+}+const TargetIcon = ({ className }: SVGProps<SVGElement>) => {return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}><g clipPath="url(#clip0_4610_6951)">@@ -68,80 +117,65 @@ const BookOpenIcon = ({ className }: SVGProps<SVGElement>) => {type IExtraInfoProps = {isMobile: booleanrelatedApps?: RelatedAppResponse- expand: boolean}-const ExtraInfo = ({ isMobile, relatedApps, expand }: IExtraInfoProps) => {+const ExtraInfo = ({ isMobile, relatedApps }: IExtraInfoProps) => {const locale = getLocaleOnClient()const [isShowTips, { toggle: toggleTips, set: setShowTips }] = useBoolean(!isMobile)const { t } = useTranslation()- const hasRelatedApps = relatedApps?.data && relatedApps?.data?.length > 0- const relatedAppsTotal = relatedApps?.data?.length || 0-useEffect(() => {setShowTips(!isMobile)}, [isMobile, setShowTips])- return <div>- {hasRelatedApps && (+ return <div className='w-full flex flex-col items-center'>+ <Divider className='mt-5' />+ {(relatedApps?.data && relatedApps?.data?.length > 0) && (<>- {!isMobile && (- <Tooltip- position='right'- noDecoration- needsDelay- popupContent={- <LinkedAppsPanel- relatedApps={relatedApps.data}- isMobile={isMobile}- />- }- >- <div className='inline-flex items-center system-xs-medium-uppercase text-text-secondary space-x-1 cursor-pointer'>- <span>{relatedAppsTotal || '--'} {t('common.datasetMenus.relatedApp')}</span>- <RiInformation2Line className='w-4 h-4' />- </div>- </Tooltip>- )}-+ {!isMobile && <div className='w-full px-2 pb-1 pt-4 uppercase text-xs text-gray-500 font-medium'>{relatedApps?.total || '--'} {t('common.datasetMenus.relatedApp')}</div>}{isMobile && <div className={classNames(s.subTitle, 'flex items-center justify-center !px-0 gap-1')}>- {relatedAppsTotal || '--'}+ {relatedApps?.total || '--'}<PaperClipIcon className='h-4 w-4 text-gray-700' /></div>}+ {relatedApps?.data?.map((item, index) => (<LikedItem key={index} isMobile={isMobile} detail={item} />))}</>)}- {!hasRelatedApps && !expand && (- <Tooltip- position='right'- noDecoration- needsDelay- popupContent={- <div className='p-4 w-[240px] bg-components-panel-bg-blur border-[0.5px] border-components-panel-border rounded-xl'>- <div className='inline-flex p-2 rounded-lg border-[0.5px] border-components-panel-border-subtle bg-background-default-subtle'>- <RiApps2AddLine className='h-4 w-4 text-text-tertiary' />- </div>- <div className='text-xs text-text-tertiary my-2'>{t('common.datasetMenus.emptyTip')}</div>- <a- className='inline-flex items-center text-xs text-text-accent mt-2 cursor-pointer'- href={- locale === LanguagesSupported[1]- ? 'https://docs.dify.ai/v/zh-hans/guides/knowledge-base/integrate-knowledge-within-application'- : 'https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application'- }- target='_blank' rel='noopener noreferrer'- >- <BookOpenIcon className='mr-1' />- {t('common.datasetMenus.viewDoc')}- </a>+ {!relatedApps?.data?.length && (+ <FloatPopoverContainer+ placement='bottom-start'+ open={isShowTips}+ toggle={toggleTips}+ isMobile={isMobile}+ triggerElement={+ <div className={classNames('h-7 w-7 inline-flex justify-center items-center rounded-lg bg-transparent', isShowTips && '!bg-gray-50')}>+ <QuestionMarkCircleIcon className='h-4 w-4 flex-shrink-0 text-gray-500' /></div>}>- <div className='inline-flex items-center system-xs-medium-uppercase text-text-secondary space-x-1 cursor-pointer'>- <span>{t('common.datasetMenus.noRelatedApp')}</span>- <RiInformation2Line className='w-4 h-4' />+ <div className={classNames('mt-5 p-3', isMobile && 'border-[0.5px] border-gray-200 shadow-lg rounded-lg bg-white w-[160px]')}>+ <div className='flex items-center justify-start gap-2'>+ <div className={s.emptyIconDiv}>+ <Squares2X2Icon className='w-3 h-3 text-gray-500' />+ </div>+ <div className={s.emptyIconDiv}>+ <PuzzlePieceIcon className='w-3 h-3 text-gray-500' />+ </div>+ </div>+ <div className='text-xs text-gray-500 mt-2'>{t('common.datasetMenus.emptyTip')}</div>+ <a+ className='inline-flex items-center text-xs text-primary-600 mt-2 cursor-pointer'+ href={+ locale === LanguagesSupported[1]+ ? 'https://docs.dify.ai/v/zh-hans/guides/knowledge-base/integrate-knowledge-within-application'+ : 'https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application'+ }+ target='_blank' rel='noopener noreferrer'+ >+ <BookOpenIcon className='mr-1' />+ {t('common.datasetMenus.viewDoc')}+ </a></div>- </Tooltip>+ </FloatPopoverContainer>)}</div>}@@ -201,7 +235,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {}, [isMobile, setAppSiderbarExpand])if (!datasetRes && !error)- return <Loading type='app' />+ return <Loading />return (<div className='grow flex overflow-hidden'>@@ -212,7 +246,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {desc={datasetRes?.description || '--'}isExternal={datasetRes?.provider === 'external'}navigation={navigation}- extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => <ExtraInfo isMobile={mode === 'collapse'} relatedApps={relatedApps} expand={mode === 'collapse'} /> : undefined}+ extraInfo={!isCurrentWorkspaceDatasetOperator ? mode => <ExtraInfo isMobile={mode === 'collapse'} relatedApps={relatedApps} /> : undefined}iconType={datasetRes?.data_source_type === DataSourceType.NOTION ? 'notion' : 'dataset'}/>}<DatasetDetailContext.Provider value={{@@ -220,7 +254,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {dataset: datasetRes,mutateDatasetRes: () => mutateDatasetRes(),}}>- <div className="bg-background-default-subtle grow overflow-hidden">{children}</div>+ <div className="bg-white grow overflow-hidden">{children}</div></DatasetDetailContext.Provider></div>)diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsxindex 3a65f1d30ff..df314ddafe9 100644--- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx+++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx@@ -7,10 +7,10 @@ const Settings = async () => {const { t } = await translate(locale, 'dataset-settings')return (- <div className='h-full overflow-y-auto'>+ <div className='bg-white h-full overflow-y-auto'><div className='px-6 py-3'>- <div className='mb-1 system-xl-semibold text-text-primary'>{t('title')}</div>- <div className='system-sm-regular text-text-tertiary'>{t('desc')}</div>+ <div className='mb-1 text-lg font-semibold text-gray-900'>{t('title')}</div>+ <div className='text-sm text-gray-500'>{t('desc')}</div></div><Form /></div>diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/style.module.css b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/style.module.cssindex 516b124809b..0ee64b4fcd0 100644--- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/style.module.css+++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/style.module.css@@ -1,3 +1,12 @@+.itemWrapper {+ @apply flex items-center w-full h-10 rounded-lg hover:bg-gray-50 cursor-pointer;+}+.appInfo {+ @apply truncate text-gray-700 text-sm font-normal;+}+.iconWrapper {+ @apply relative w-6 h-6 rounded-lg;+}.statusPoint {@apply flex justify-center items-center absolute -right-0.5 -bottom-0.5 w-2.5 h-2.5 bg-white rounded;}diff --git a/web/app/(commonLayout)/datasets/Container.tsx b/web/app/(commonLayout)/datasets/Container.tsxindex a0edb1cd61b..a30521d9988 100644--- a/web/app/(commonLayout)/datasets/Container.tsx+++ b/web/app/(commonLayout)/datasets/Container.tsx@@ -17,6 +17,7 @@ import TagManagementModal from '@/app/components/base/tag-management'import TagFilter from '@/app/components/base/tag-management/filter'import Button from '@/app/components/base/button'import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development'+import SearchInput from '@/app/components/base/search-input'// Servicesimport { fetchDatasetApiBaseUrl } from '@/service/datasets'@@ -28,7 +29,6 @@ import { useAppContext } from '@/context/app-context'import { useExternalApiPanel } from '@/context/external-api-panel-context'// eslint-disable-next-line import/orderimport { useQuery } from '@tanstack/react-query'-import Input from '@/app/components/base/input'const Container = () => {const { t } = useTranslation()@@ -81,24 +81,17 @@ const Container = () => {}, [currentWorkspace, router])return (- <div ref={containerRef} className='grow relative flex flex-col bg-background-body overflow-y-auto'>- <div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-background-body z-10 flex-wrap gap-y-2'>+ <div ref={containerRef} className='grow relative flex flex-col bg-gray-100 overflow-y-auto'>+ <div className='sticky top-0 flex justify-between pt-4 px-12 pb-2 leading-[56px] bg-gray-100 z-10 flex-wrap gap-y-2'><TabSliderNewvalue={activeTab}onChange={newActiveTab => setActiveTab(newActiveTab)}options={options}/>{activeTab === 'dataset' && (- <div className='flex items-center justify-center gap-2'>+ <div className='flex items-center gap-2'><TagFilter type='knowledge' value={tagFilterValue} onChange={handleTagsChange} />- <Input- showLeftIcon- showClearIcon- wrapperClassName='w-[200px]'- value={keywords}- onChange={e => handleKeywordsChange(e.target.value)}- onClear={() => handleKeywordsChange('')}- />+ <SearchInput className='w-[200px]' value={keywords} onChange={handleKeywordsChange} /><div className="w-[1px] h-4 bg-divider-regular" /><ButtonclassName='gap-0.5 shadows-shadow-xs'diff --git a/web/app/(commonLayout)/datasets/DatasetCard.tsx b/web/app/(commonLayout)/datasets/DatasetCard.tsxindex ad83a41dff9..e8ccddbcb78 100644--- a/web/app/(commonLayout)/datasets/DatasetCard.tsx+++ b/web/app/(commonLayout)/datasets/DatasetCard.tsx@@ -111,7 +111,7 @@ const DatasetCard = ({return (<><div- className='group relative col-span-1 bg-components-card-bg border-[0.5px] border-solid border-components-card-border rounded-xl shadow-sm min-h-[160px] flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg'+ className='group relative col-span-1 bg-white border-[0.5px] border-solid border-transparent rounded-xl shadow-sm min-h-[160px] flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg'data-disable-nprogress={true}onClick={(e) => {e.preventDefault()@@ -129,8 +129,8 @@ const DatasetCard = ({<Folder className='w-5 h-5 text-[#444CE7]' /></div><div className='grow w-0 py-[1px]'>- <div className='flex items-center text-sm leading-5 font-semibold text-text-secondary'>- <div className={cn('truncate', !dataset.embedding_available && 'opacity-50 hover:opacity-100 text-text-tertiary')} title={dataset.name}>{dataset.name}</div>+ <div className='flex items-center text-sm leading-5 font-semibold text-gray-800'>+ <div className={cn('truncate', !dataset.embedding_available && 'opacity-50 hover:opacity-100')} title={dataset.name}>{dataset.name}</div>{!dataset.embedding_available && (<TooltippopupContent={t('dataset.unavailableTip')}@@ -139,7 +139,7 @@ const DatasetCard = ({</Tooltip>)}</div>- <div className='flex items-center mt-[1px] text-xs leading-[18px] text-text-tertiary'>+ <div className='flex items-center mt-[1px] text-xs leading-[18px] text-gray-500'><divclassName={cn('truncate', (!dataset.embedding_available || !dataset.document_count) && 'opacity-50')}title={dataset.provider === 'external' ? `${dataset.app_count}${t('dataset.appCount')}` : `${dataset.document_count}${t('dataset.documentCount')} · ${Math.round(dataset.word_count / 1000)}${t('dataset.wordCount')} · ${dataset.app_count}${t('dataset.appCount')}`}@@ -162,7 +162,7 @@ const DatasetCard = ({</div><divclassName={cn(- 'grow mb-2 px-[14px] max-h-[72px] text-xs leading-normal text-text-tertiary group-hover:line-clamp-2 group-hover:max-h-[36px]',+ 'grow mb-2 px-[14px] max-h-[72px] text-xs leading-normal text-gray-500 group-hover:line-clamp-2 group-hover:max-h-[36px]',tags.length ? 'line-clamp-2' : 'line-clamp-4',!dataset.embedding_available && 'opacity-50 hover:opacity-100',)}diff --git a/web/app/components/app-sidebar/dataset-info.tsx b/web/app/components/app-sidebar/dataset-info.tsxdeleted file mode 100644index 5ce51d46e91..00000000000--- a/web/app/components/app-sidebar/dataset-info.tsx+++ /dev/null@@ -1,45 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import { useTranslation } from 'react-i18next'-import AppIcon from '../base/app-icon'--const DatasetSvg = <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path fillRule="evenodd" clipRule="evenodd" d="M0.833497 5.13481C0.833483 4.69553 0.83347 4.31654 0.858973 4.0044C0.88589 3.67495 0.94532 3.34727 1.10598 3.03195C1.34567 2.56155 1.72812 2.17909 2.19852 1.93941C2.51384 1.77875 2.84152 1.71932 3.17097 1.6924C3.48312 1.6669 3.86209 1.66691 4.30137 1.66693L7.62238 1.66684C8.11701 1.66618 8.55199 1.66561 8.95195 1.80356C9.30227 1.92439 9.62134 2.12159 9.88607 2.38088C10.1883 2.67692 10.3823 3.06624 10.603 3.50894L11.3484 5.00008H14.3679C15.0387 5.00007 15.5924 5.00006 16.0434 5.03691C16.5118 5.07518 16.9424 5.15732 17.3468 5.36339C17.974 5.68297 18.4839 6.19291 18.8035 6.82011C19.0096 7.22456 19.0917 7.65515 19.13 8.12356C19.1668 8.57455 19.1668 9.12818 19.1668 9.79898V13.5345C19.1668 14.2053 19.1668 14.7589 19.13 15.2099C19.0917 15.6784 19.0096 16.1089 18.8035 16.5134C18.4839 17.1406 17.974 17.6505 17.3468 17.9701C16.9424 18.1762 16.5118 18.2583 16.0434 18.2966C15.5924 18.3334 15.0387 18.3334 14.3679 18.3334H5.63243C4.96163 18.3334 4.40797 18.3334 3.95698 18.2966C3.48856 18.2583 3.05798 18.1762 2.65353 17.9701C2.02632 17.6505 1.51639 17.1406 1.19681 16.5134C0.990734 16.1089 0.908597 15.6784 0.870326 15.2099C0.833478 14.7589 0.833487 14.2053 0.833497 13.5345V5.13481ZM7.51874 3.33359C8.17742 3.33359 8.30798 3.34447 8.4085 3.37914C8.52527 3.41942 8.63163 3.48515 8.71987 3.57158C8.79584 3.64598 8.86396 3.7579 9.15852 4.34704L9.48505 5.00008L2.50023 5.00008C2.50059 4.61259 2.50314 4.34771 2.5201 4.14012C2.5386 3.91374 2.57 3.82981 2.59099 3.7886C2.67089 3.6318 2.79837 3.50432 2.95517 3.42442C2.99638 3.40343 3.08031 3.37203 3.30669 3.35353C3.54281 3.33424 3.85304 3.33359 4.3335 3.33359H7.51874Z" fill="#444CE7" />-</svg>--type Props = {- isExternal?: boolean- name: string- description: string- expand: boolean- extraInfo?: React.ReactNode-}--const DatasetInfo: FC<Props> = ({- name,- description,- isExternal,- expand,- extraInfo,-}) => {- const { t } = useTranslation()- return (- <div className='pl-1 pt-1'>- <div className='flex-shrink-0 mr-3'>- <AppIcon innerIcon={DatasetSvg} className='!border-[0.5px] !border-indigo-100 !bg-indigo-25' />- </div>- {expand && (- <div className='mt-2'>- <div className='system-md-semibold text-text-secondary'>- {name}- </div>- <div className='mt-1 text-text-tertiary system-2xs-medium-uppercase'>{isExternal ? t('dataset.externalTag') : t('dataset.localDocs')}</div>- <div className='my-3 system-xs-regular text-text-tertiary first-letter:capitalize'>{description}</div>- </div>- )}- {extraInfo}- </div>- )-}-export default React.memo(DatasetInfo)diff --git a/web/app/components/app-sidebar/index.tsx b/web/app/components/app-sidebar/index.tsxindex 61e4bf83308..5ee063ad646 100644--- a/web/app/components/app-sidebar/index.tsx+++ b/web/app/components/app-sidebar/index.tsx@@ -1,15 +1,15 @@import React, { useEffect } from 'react'import { useShallow } from 'zustand/react/shallow'-import { RiLayoutRight2Line } from '@remixicon/react'-import { LayoutRight2LineMod } from '../base/icons/src/public/knowledge'import NavLink from './navLink'import type { NavIcon } from './navLink'import AppBasic from './basic'import AppInfo from './app-info'-import DatasetInfo from './dataset-info'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'+import {+ AlignLeft01,+ AlignRight01,+} from '@/app/components/base/icons/src/vender/line/layout'import { useStore as useAppStore } from '@/app/components/app/store'-import cn from '@/utils/classnames'export type IAppDetailNavProps = {iconType?: 'app' | 'dataset' | 'notion'@@ -63,16 +63,7 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati{iconType === 'app' && (<AppInfo expand={expand} />)}- {iconType === 'dataset' && (- <DatasetInfo- name={title}- description={desc}- isExternal={isExternal}- expand={expand}- extraInfo={extraInfo && extraInfo(appSidebarExpand)}- />- )}- {!['app', 'dataset'].includes(iconType) && (+ {iconType !== 'app' && (<AppBasicmode={appSidebarExpand}iconType={iconType}@@ -84,9 +75,9 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati/>)}</div>- <div className='px-4'>- <div className={cn('mt-1 mx-auto h-[1px] bg-divider-subtle', !expand && 'w-6')} />- </div>+ {!expand && (+ <div className='mt-1 mx-auto w-6 h-[1px] bg-divider-subtle' />+ )}<navclassName={`grow space-y-1@@ -98,6 +89,7 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati<NavLink key={index} mode={appSidebarExpand} iconMap={{ selected: item.selectedIcon, normal: item.icon }} name={item.name} href={item.href} />)})}+ {extraInfo && extraInfo(appSidebarExpand)}</nav>{!isMobile && (@@ -113,8 +105,8 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati>{expand- ? <RiLayoutRight2Line className='w-5 h-5 text-components-menu-item-text' />- : <LayoutRight2LineMod className='w-5 h-5 text-components-menu-item-text' />+ ? <AlignLeft01 className='w-[14px] h-[14px]' />+ : <AlignRight01 className='w-[14px] h-[14px]' />}</div></div>diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsxindex 7a347a18995..389ae0d1fa1 100644--- a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx+++ b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx@@ -12,7 +12,7 @@ import Divider from '@/app/components/base/divider'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Textarea from '@/app/components/base/textarea'-import { type DataSet, RerankingModeEnum } from '@/models/datasets'+import type { DataSet } from '@/models/datasets'import { useToastContext } from '@/app/components/base/toast'import { updateDatasetSetting } from '@/service/datasets'import { useAppContext } from '@/context/app-context'@@ -111,10 +111,7 @@ const SettingsModal: FC<SettingsModalProps> = ({}const postRetrievalConfig = ensureRerankModelSelected({rerankDefaultModel: rerankDefaultModel!,- retrievalConfig: {- ...retrievalConfig,- reranking_enable: retrievalConfig.reranking_mode === RerankingModeEnum.RerankingModel,- },+ retrievalConfig,indexMethod,})try {@@ -258,8 +255,7 @@ const SettingsModal: FC<SettingsModalProps> = ({disable={!localeCurrentDataset?.embedding_available}value={indexMethod}onChange={v => setIndexMethod(v!)}- docForm={currentDataset.doc_form}- currentValue={currentDataset.indexing_technique}+ itemClassName='sm:!w-[280px]'/></div></div>@@ -291,7 +287,7 @@ const SettingsModal: FC<SettingsModalProps> = ({{/* Retrieval Method Config */}{currentDataset?.provider === 'external'? <>- <div className={rowClass}><Divider /></div>+ <div className={rowClass}><Divider/></div><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.retrievalSetting.title')}</div>@@ -304,7 +300,7 @@ const SettingsModal: FC<SettingsModalProps> = ({isInRetrievalSetting={true}/></div>- <div className={rowClass}><Divider /></div>+ <div className={rowClass}><Divider/></div><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.externalKnowledgeAPI')}</div>@@ -330,7 +326,7 @@ const SettingsModal: FC<SettingsModalProps> = ({</div></div></div>- <div className={rowClass}><Divider /></div>+ <div className={rowClass}><Divider/></div></>: <div className={rowClass}><div className={cn(labelClass, 'w-auto min-w-[168px]')}>diff --git a/web/app/components/base/app-icon/style.module.css b/web/app/components/base/app-icon/style.module.cssdeleted file mode 100644index 8554058ffb4..00000000000--- a/web/app/components/base/app-icon/style.module.css+++ /dev/null@@ -1,19 +0,0 @@-.appIcon.large {- @apply w-10 h-10;-}--.appIcon.small {- @apply w-8 h-8;-}--.appIcon.tiny {- @apply w-6 h-6 text-base;-}--.appIcon.xs {- @apply w-3 h-3 text-base;-}--.appIcon.rounded {- @apply rounded-full;-}diff --git a/web/app/components/base/auto-height-textarea/common.tsx b/web/app/components/base/auto-height-textarea/common.tsxindex 98ff0b7272f..c71df04395d 100644--- a/web/app/components/base/auto-height-textarea/common.tsx+++ b/web/app/components/base/auto-height-textarea/common.tsx@@ -49,6 +49,4 @@ const AutoHeightTextarea = forwardRef<HTMLTextAreaElement, AutoHeightTextareaPro},)-AutoHeightTextarea.displayName = 'AutoHeightTextarea'-export default AutoHeightTextareadiff --git a/web/app/components/base/badge.tsx b/web/app/components/base/badge.tsxindex 787b005a8f7..722fde3237b 100644--- a/web/app/components/base/badge.tsx+++ b/web/app/components/base/badge.tsx@@ -3,15 +3,13 @@ import cn from '@/utils/classnames'type BadgeProps = {className?: string- text?: string- children?: React.ReactNode+ text: stringuppercase?: boolean}const Badge = ({className,text,- children,uppercase = true,}: BadgeProps) => {return (@@ -22,7 +20,7 @@ const Badge = ({className,)}>- {children || text}+ {text}</div>)}diff --git a/web/app/components/base/checkbox/assets/mixed.svg b/web/app/components/base/checkbox/assets/mixed.svgdeleted file mode 100644index e16b8fc975b..00000000000--- a/web/app/components/base/checkbox/assets/mixed.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="check">-<path id="Vector 1" d="M2.5 6H9.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>-</g>-</svg>diff --git a/web/app/components/base/checkbox/index.module.css b/web/app/components/base/checkbox/index.module.cssdeleted file mode 100644index d675607b469..00000000000--- a/web/app/components/base/checkbox/index.module.css+++ /dev/null@@ -1,10 +0,0 @@-.mixed {- background: var(--color-components-checkbox-bg) url(./assets/mixed.svg) center center no-repeat;- background-size: 12px 12px;- border: none;-}--.checked.disabled {- background-color: #d0d5dd;- border-color: #d0d5dd;-}\ No newline at end of filediff --git a/web/app/components/base/checkbox/index.tsx b/web/app/components/base/checkbox/index.tsxindex df2c368cc0b..c2b43ba4b29 100644--- a/web/app/components/base/checkbox/index.tsx+++ b/web/app/components/base/checkbox/index.tsx@@ -1,5 +1,4 @@import { RiCheckLine } from '@remixicon/react'-import s from './index.module.css'import cn from '@/utils/classnames'type CheckboxProps = {@@ -7,17 +6,15 @@ type CheckboxProps = {onCheck?: () => voidclassName?: stringdisabled?: boolean- mixed?: boolean}-const Checkbox = ({ checked, onCheck, className, disabled, mixed }: CheckboxProps) => {+const Checkbox = ({ checked, onCheck, className, disabled }: CheckboxProps) => {if (!checked) {return (<divclassName={cn('w-4 h-4 rounded-[4px] bg-components-checkbox-bg-unchecked border border-components-checkbox-border hover:bg-components-checkbox-bg-unchecked-hover hover:border-components-checkbox-border-hover shadow-xs cursor-pointer',disabled && 'border-components-checkbox-border-disabled bg-components-checkbox-bg-disabled hover:border-components-checkbox-border-disabled hover:bg-components-checkbox-bg-disabled cursor-not-allowed',- mixed && s.mixed,className,)}onClick={() => {diff --git a/web/app/components/base/divider/index.tsx b/web/app/components/base/divider/index.tsxindex 6fe16b95a23..fcee10a9e2e 100644--- a/web/app/components/base/divider/index.tsx+++ b/web/app/components/base/divider/index.tsx@@ -22,7 +22,7 @@ const dividerVariants = cva('',},)-export type DividerProps = {+type DividerProps = {className?: stringstyle?: CSSProperties} & VariantProps<typeof dividerVariants>diff --git a/web/app/components/base/divider/with-label.tsx b/web/app/components/base/divider/with-label.tsxdeleted file mode 100644index 608bc799987..00000000000--- a/web/app/components/base/divider/with-label.tsx+++ /dev/null@@ -1,23 +0,0 @@-import type { FC } from 'react'-import type { DividerProps } from '.'-import Divider from '.'-import classNames from '@/utils/classnames'--export type DividerWithLabelProps = DividerProps & {- label: string-}--export const DividerWithLabel: FC<DividerWithLabelProps> = (props) => {- const { label, className, ...rest } = props- return <div- className="flex items-center gap-2 my-2"- >- <Divider {...rest} className={classNames('flex-1', className)} />- <span className="text-text-tertiary text-xs">- {label}- </span>- <Divider {...rest} className={classNames('flex-1', className)} />- </div>-}--export default DividerWithLabeldiff --git a/web/app/components/base/drawer/index.tsx b/web/app/components/base/drawer/index.tsxindex c1057b9f1f7..d9df7cc0537 100644--- a/web/app/components/base/drawer/index.tsx+++ b/web/app/components/base/drawer/index.tsx@@ -19,7 +19,6 @@ export type IDrawerProps = {onClose: () => voidonCancel?: () => voidonOk?: () => void- unmount?: boolean}export default function Drawer({@@ -36,12 +35,11 @@ export default function Drawer({onClose,onCancel,onOk,- unmount = false,}: IDrawerProps) {const { t } = useTranslation()return (<Dialog- unmount={unmount}+ unmount={false}open={isOpen}onClose={() => !clickOutsideNotOpen && onClose()}className="fixed z-30 inset-0 overflow-y-auto"diff --git a/web/app/components/base/file-uploader/file-type-icon.tsx b/web/app/components/base/file-uploader/file-type-icon.tsxindex 08d0131520a..ed4cdde7e74 100644--- a/web/app/components/base/file-uploader/file-type-icon.tsx+++ b/web/app/components/base/file-uploader/file-type-icon.tsx@@ -82,8 +82,11 @@ const FileTypeIcon = ({size = 'sm',className,}: FileTypeIconProps) => {- const Icon = FILE_TYPE_ICON_MAP[type]?.component || FILE_TYPE_ICON_MAP[FileAppearanceTypeEnum.document].component- const color = FILE_TYPE_ICON_MAP[type]?.color || FILE_TYPE_ICON_MAP[FileAppearanceTypeEnum.document].color+ const Icon = FILE_TYPE_ICON_MAP[type].component+ const color = FILE_TYPE_ICON_MAP[type].color++ if (!Icon)+ return nullreturn <Icon className={cn('shrink-0', SizeMap[size], color, className)} />}diff --git a/web/app/components/base/icons/assets/public/knowledge/chunk.svg b/web/app/components/base/icons/assets/public/knowledge/chunk.svgdeleted file mode 100644index 1dc04943fc4..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/chunk.svg+++ /dev/null@@ -1,13 +0,0 @@-<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Group">-<path id="Vector" d="M2.5 10H0V7.5H2.5V10Z" fill="#676F83"/>-<path id="Vector_2" d="M6.25 6.25H3.75V3.75H6.25V6.25Z" fill="#676F83"/>-<path id="Vector_3" d="M2.5 6.25H0V3.75H2.5V6.25Z" fill="#676F83"/>-<path id="Vector_4" d="M6.25 2.5H3.75V0H6.25V2.5Z" fill="#676F83"/>-<path id="Vector_5" d="M2.5 2.5H0V0H2.5V2.5Z" fill="#676F83"/>-<path id="Vector_6" d="M10 2.5H7.5V0H10V2.5Z" fill="#676F83"/>-<path id="Vector_7" d="M9.58342 7.91663H7.91675V9.58329H9.58342V7.91663Z" fill="#676F83"/>-<path id="Vector_8" d="M9.58342 4.16663H7.91675V5.83329H9.58342V4.16663Z" fill="#676F83"/>-<path id="Vector_9" d="M5.83341 7.91663H4.16675V9.58329H5.83341V7.91663Z" fill="#676F83"/>-</g>-</svg>diff --git a/web/app/components/base/icons/assets/public/knowledge/collapse.svg b/web/app/components/base/icons/assets/public/knowledge/collapse.svgdeleted file mode 100644index b54e0460850..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/collapse.svg+++ /dev/null@@ -1,9 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Icon L">-<g id="Vector">-<path d="M2.66602 11.3333H0.666016L3.33268 8.66667L5.99935 11.3333H3.99935L3.99935 14H2.66602L2.66602 11.3333Z" fill="#354052"/>-<path d="M2.66602 4.66667L2.66602 2L3.99935 2L3.99935 4.66667L5.99935 4.66667L3.33268 7.33333L0.666016 4.66667L2.66602 4.66667Z" fill="#354052"/>-<path d="M7.33268 2.66667H13.9993V4H7.33268V2.66667ZM7.33268 12H13.9993V13.3333H7.33268V12ZM5.99935 7.33333H13.9993V8.66667H5.99935V7.33333Z" fill="#354052"/>-</g>-</g>-</svg>diff --git a/web/app/components/base/icons/assets/public/knowledge/general-type.svg b/web/app/components/base/icons/assets/public/knowledge/general-type.svgdeleted file mode 100644index 779df5f31c2..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/general-type.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Icon L">-<path id="Vector" fill-rule="evenodd" clip-rule="evenodd" d="M6 0.5C6.27615 0.5 6.5 0.72386 6.5 1V1.52755C6.95855 1.57831 7.3967 1.69804 7.80355 1.87619L8.067 1.41997C8.20505 1.18083 8.51085 1.09889 8.75 1.23696C8.98915 1.37503 9.07105 1.68082 8.933 1.91998L8.6692 2.37685C9.033 2.64523 9.3548 2.96707 9.6232 3.33084L10.0801 3.06703C10.3193 2.92896 10.6251 3.0109 10.7632 3.25005C10.9012 3.4892 10.8193 3.79499 10.5801 3.93306L10.1238 4.19649C10.302 4.60333 10.4218 5.0415 10.4725 5.50005H11C11.2761 5.50005 11.5 5.7239 11.5 6.00005C11.5 6.2762 11.2761 6.50005 11 6.50005H10.4725C10.4218 6.9586 10.302 7.3968 10.1238 7.80365L10.5801 8.0671C10.8193 8.20515 10.9012 8.51095 10.7632 8.7501C10.6251 8.98925 10.3193 9.0712 10.0801 8.9331L9.6232 8.6693C9.3548 9.03305 9.03295 9.3549 8.6692 9.62325L8.933 10.0802C9.07105 10.3193 8.98915 10.6251 8.75 10.7632C8.51085 10.9012 8.20505 10.8193 8.067 10.5802L7.80355 10.1239C7.3967 10.3021 6.95855 10.4218 6.5 10.4726V11C6.5 11.2761 6.27615 11.5 6 11.5C5.72385 11.5 5.5 11.2761 5.5 11V10.4726C5.04145 10.4218 4.60328 10.3021 4.19644 10.1239L3.933 10.5802C3.79493 10.8194 3.48914 10.9013 3.24999 10.7633C3.01084 10.6252 2.92891 10.3194 3.06698 10.0802L3.3308 9.62325C2.96702 9.3549 2.64517 9.03305 2.37678 8.66925L1.91986 8.93305C1.68071 9.07115 1.37492 8.9892 1.23685 8.75005C1.09878 8.5109 1.18072 8.2051 1.41986 8.06705L1.87612 7.8036C1.69797 7.39675 1.57824 6.9586 1.52749 6.50005L0.999975 6.5C0.723835 6.5 0.499987 6.2761 0.5 6C0.500015 5.72385 0.72388 5.5 1.00003 5.5L1.5275 5.50005C1.57825 5.0415 1.69796 4.60335 1.87611 4.19652L1.41987 3.93312C1.18072 3.79504 1.09878 3.48925 1.23685 3.2501C1.37492 3.01095 1.68071 2.92901 1.91985 3.06709L2.37675 3.33086C2.64514 2.96708 2.967 2.64524 3.33078 2.37684L3.06698 1.91992C2.92891 1.68077 3.01084 1.37498 3.24999 1.23691C3.48914 1.09884 3.79493 1.18077 3.933 1.41992L4.19642 1.87619C4.60327 1.69803 5.04145 1.57831 5.5 1.52755V1C5.5 0.72386 5.72385 0.5 6 0.5ZM3.83484 3.24991C3.48643 3.52463 3.19141 3.86415 2.96808 4.25014C2.67048 4.7645 2.49999 5.3616 2.49999 6.00005C2.49999 6.6385 2.67048 7.2356 2.96809 7.75C3.19142 8.13595 3.48645 8.4755 3.83486 8.7502L4.8599 6.97475C4.63581 6.71285 4.49999 6.37245 4.49999 6.00005C4.49999 5.62765 4.63581 5.28725 4.8599 5.02535L3.83484 3.24991ZM5.7258 4.52514L4.70041 2.74911C5.10185 2.58847 5.5402 2.50005 6 2.50005C6.63845 2.50005 7.23555 2.67054 7.74995 2.96816C8.28125 3.27557 8.7245 3.71882 9.0319 4.25012C9.2503 4.62764 9.4003 5.04975 9.4646 5.50005H7.41465C7.2087 4.91745 6.6531 4.50005 6 4.50005C5.9065 4.50005 5.8148 4.50865 5.7258 4.52514ZM7.41465 6.50005C7.2087 7.08265 6.6531 7.50005 6 7.50005C5.9065 7.50005 5.8148 7.49145 5.7258 7.47495L4.70043 9.251C5.10185 9.41165 5.5402 9.50005 6 9.50005C6.63845 9.50005 7.23555 9.32955 7.7499 9.03195C8.2812 8.72455 8.72445 8.2813 9.03185 7.75C9.2503 7.3725 9.4003 6.95035 9.4646 6.50005H7.41465Z" fill="#676F83"/>-</g>-</svg>diff --git a/web/app/components/base/icons/assets/public/knowledge/layout-right-2-line-mod.svg b/web/app/components/base/icons/assets/public/knowledge/layout-right-2-line-mod.svgdeleted file mode 100644index 188f9b55a36..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/layout-right-2-line-mod.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Icon L">-<path id="Vector" d="M14.0002 2C14.3684 2 14.6668 2.29848 14.6668 2.66667V13.3333C14.6668 13.7015 14.3684 14 14.0002 14H2.00016C1.63198 14 1.3335 13.7015 1.3335 13.3333V2.66667C1.3335 2.29848 1.63198 2 2.00016 2H14.0002ZM13.3335 3.33333H2.66683V12.6667H13.3335V3.33333ZM14.0002 2.66667V13.3333H10.0002V2.66667H14.0002Z" fill="#354052"/>-</g>-</svg>diff --git a/web/app/components/base/icons/assets/public/knowledge/parent-child-type.svg b/web/app/components/base/icons/assets/public/knowledge/parent-child-type.svgdeleted file mode 100644index bc596b672a6..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/parent-child-type.svg+++ /dev/null@@ -1,7 +0,0 @@-<svg width="10" height="11" viewBox="0 0 10 11" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Group">-<path id="Vector" d="M2.70833 3.87501C3.51375 3.87501 4.16666 3.22209 4.16666 2.41668C4.16666 1.61126 3.51375 0.958344 2.70833 0.958344C1.90292 0.958344 1.25 1.61126 1.25 2.41668C1.25 3.22209 1.90292 3.87501 2.70833 3.87501Z" fill="#676F83"/>-<path id="Vector_2" d="M7.29158 3.87501C8.097 3.87501 8.74992 3.22209 8.74992 2.41668C8.74992 1.61126 8.097 0.958344 7.29158 0.958344C6.48617 0.958344 5.83325 1.61126 5.83325 2.41668C5.83325 3.22209 6.48617 3.87501 7.29158 3.87501Z" fill="#676F83"/>-<path id="Vector_3" d="M7.29167 4.70835C6.83771 4.70886 6.39118 4.82363 5.99324 5.04208C5.59529 5.26053 5.25874 5.57563 5.01459 5.95835C5.34482 5.9622 5.66011 6.09658 5.89159 6.33215C6.12306 6.56771 6.25191 6.8853 6.24998 7.21555C6.24805 7.5458 6.11551 7.86187 5.8813 8.09472C5.6471 8.32756 5.33026 8.45826 5 8.45826C4.66975 8.45826 4.35291 8.32756 4.1187 8.09472C3.8845 7.86187 3.75195 7.5458 3.75003 7.21555C3.7481 6.8853 3.87695 6.56771 4.10842 6.33215C4.3399 6.09658 4.65519 5.9622 4.98542 5.95835C4.67086 5.46415 4.20432 5.08546 3.656 4.87926C3.10767 4.67306 2.50721 4.6505 1.94496 4.81497C1.3827 4.97944 0.889064 5.32205 0.538306 5.79125C0.187547 6.26045 -0.00135882 6.83086 7.35834e-06 7.41668V10.125C7.35834e-06 10.2355 0.043906 10.3415 0.122046 10.4196C0.200186 10.4978 0.306167 10.5417 0.416674 10.5417H3.33334V9.50001L1.83334 8.37501C1.78957 8.34218 1.75269 8.30105 1.72481 8.25397C1.69693 8.20688 1.6786 8.15477 1.67086 8.1006C1.65523 7.99121 1.6837 7.88008 1.75001 7.79168C1.81631 7.70327 1.91502 7.64483 2.02441 7.6292C2.13381 7.61357 2.24493 7.64204 2.33334 7.70835L3.88875 8.87501H6.11125L7.66667 7.70835C7.75507 7.64204 7.8662 7.61357 7.97559 7.6292C8.08499 7.64483 8.1837 7.70327 8.25 7.79168C8.31631 7.88008 8.34478 7.99121 8.32915 8.1006C8.31352 8.21 8.25507 8.30871 8.16667 8.37501L6.66667 9.50001V10.5417H9.58333C9.69384 10.5417 9.79982 10.4978 9.87796 10.4196C9.9561 10.3415 10 10.2355 10 10.125V7.41668C9.99912 6.69866 9.71349 6.01029 9.20577 5.50257C8.69805 4.99485 8.00969 4.70923 7.29167 4.70835Z" fill="#676F83"/>-</g>-</svg>diff --git a/web/app/components/base/icons/assets/public/knowledge/selection-mod.svg b/web/app/components/base/icons/assets/public/knowledge/selection-mod.svgdeleted file mode 100644index ae3c9c5c75b..00000000000--- a/web/app/components/base/icons/assets/public/knowledge/selection-mod.svg+++ /dev/null@@ -1,13 +0,0 @@-<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Group">-<path id="Vector" d="M2.5 10H0V7.5H2.5V10Z" fill="#676F83"/>-<path id="Vector_2" d="M6.25 6.25H3.75V3.75H6.25V6.25Z" fill="#676F83"/>-<path id="Vector_3" d="M2.5 6.25H0V3.75H2.5V6.25Z" fill="#676F83"/>-<path id="Vector_4" d="M6.25 2.5H3.75V0H6.25V2.5Z" fill="#676F83"/>-<path id="Vector_5" d="M2.5 2.5H0V0H2.5V2.5Z" fill="#676F83"/>-<path id="Vector_6" d="M10 2.5H7.5V0H10V2.5Z" fill="#676F83"/>-<path id="Vector_7" d="M9.58332 7.91663H7.91666V9.58329H9.58332V7.91663Z" fill="#676F83"/>-<path id="Vector_8" d="M9.58332 4.16663H7.91666V5.83329H9.58332V4.16663Z" fill="#676F83"/>-<path id="Vector_9" d="M5.83332 7.91663H4.16666V9.58329H5.83332V7.91663Z" fill="#676F83"/>-</g>-</svg>diff --git a/web/app/components/base/icons/src/public/knowledge/Chunk.json b/web/app/components/base/icons/src/public/knowledge/Chunk.jsondeleted file mode 100644index 7bd5668810c..00000000000--- a/web/app/components/base/icons/src/public/knowledge/Chunk.json+++ /dev/null@@ -1,116 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "10",- "height": "10",- "viewBox": "0 0 10 10",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Group"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector",- "d": "M2.5 10H0V7.5H2.5V10Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_2",- "d": "M6.25 6.25H3.75V3.75H6.25V6.25Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_3",- "d": "M2.5 6.25H0V3.75H2.5V6.25Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_4",- "d": "M6.25 2.5H3.75V0H6.25V2.5Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_5",- "d": "M2.5 2.5H0V0H2.5V2.5Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_6",- "d": "M10 2.5H7.5V0H10V2.5Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_7",- "d": "M9.58342 7.91663H7.91675V9.58329H9.58342V7.91663Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_8",- "d": "M9.58342 4.16663H7.91675V5.83329H9.58342V4.16663Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_9",- "d": "M5.83341 7.91663H4.16675V9.58329H5.83341V7.91663Z",- "fill": "currentColor"- },- "children": []- }- ]- }- ]- },- "name": "Chunk"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/Chunk.tsx b/web/app/components/base/icons/src/public/knowledge/Chunk.tsxdeleted file mode 100644index 87ff635811d..00000000000--- a/web/app/components/base/icons/src/public/knowledge/Chunk.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './Chunk.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'Chunk'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/Collapse.json b/web/app/components/base/icons/src/public/knowledge/Collapse.jsondeleted file mode 100644index 5e3cf08ce03..00000000000--- a/web/app/components/base/icons/src/public/knowledge/Collapse.json+++ /dev/null@@ -1,62 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "16",- "height": "16",- "viewBox": "0 0 16 16",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Icon L"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Vector"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "d": "M2.66602 11.3333H0.666016L3.33268 8.66667L5.99935 11.3333H3.99935L3.99935 14H2.66602L2.66602 11.3333Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "d": "M2.66602 4.66667L2.66602 2L3.99935 2L3.99935 4.66667L5.99935 4.66667L3.33268 7.33333L0.666016 4.66667L2.66602 4.66667Z",- "fill": "currentColor"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "d": "M7.33268 2.66667H13.9993V4H7.33268V2.66667ZM7.33268 12H13.9993V13.3333H7.33268V12ZM5.99935 7.33333H13.9993V8.66667H5.99935V7.33333Z",- "fill": "currentColor"- },- "children": []- }- ]- }- ]- }- ]- },- "name": "Collapse"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/Collapse.tsx b/web/app/components/base/icons/src/public/knowledge/Collapse.tsxdeleted file mode 100644index 48206c4d0cc..00000000000--- a/web/app/components/base/icons/src/public/knowledge/Collapse.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './Collapse.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'Collapse'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/GeneralType.json b/web/app/components/base/icons/src/public/knowledge/GeneralType.jsondeleted file mode 100644index 9a87d00a60c..00000000000--- a/web/app/components/base/icons/src/public/knowledge/GeneralType.json+++ /dev/null@@ -1,38 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "12",- "height": "12",- "viewBox": "0 0 12 12",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Icon L"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector",- "fill-rule": "evenodd",- "clip-rule": "evenodd",- "d": "M6 0.5C6.27615 0.5 6.5 0.72386 6.5 1V1.52755C6.95855 1.57831 7.3967 1.69804 7.80355 1.87619L8.067 1.41997C8.20505 1.18083 8.51085 1.09889 8.75 1.23696C8.98915 1.37503 9.07105 1.68082 8.933 1.91998L8.6692 2.37685C9.033 2.64523 9.3548 2.96707 9.6232 3.33084L10.0801 3.06703C10.3193 2.92896 10.6251 3.0109 10.7632 3.25005C10.9012 3.4892 10.8193 3.79499 10.5801 3.93306L10.1238 4.19649C10.302 4.60333 10.4218 5.0415 10.4725 5.50005H11C11.2761 5.50005 11.5 5.7239 11.5 6.00005C11.5 6.2762 11.2761 6.50005 11 6.50005H10.4725C10.4218 6.9586 10.302 7.3968 10.1238 7.80365L10.5801 8.0671C10.8193 8.20515 10.9012 8.51095 10.7632 8.7501C10.6251 8.98925 10.3193 9.0712 10.0801 8.9331L9.6232 8.6693C9.3548 9.03305 9.03295 9.3549 8.6692 9.62325L8.933 10.0802C9.07105 10.3193 8.98915 10.6251 8.75 10.7632C8.51085 10.9012 8.20505 10.8193 8.067 10.5802L7.80355 10.1239C7.3967 10.3021 6.95855 10.4218 6.5 10.4726V11C6.5 11.2761 6.27615 11.5 6 11.5C5.72385 11.5 5.5 11.2761 5.5 11V10.4726C5.04145 10.4218 4.60328 10.3021 4.19644 10.1239L3.933 10.5802C3.79493 10.8194 3.48914 10.9013 3.24999 10.7633C3.01084 10.6252 2.92891 10.3194 3.06698 10.0802L3.3308 9.62325C2.96702 9.3549 2.64517 9.03305 2.37678 8.66925L1.91986 8.93305C1.68071 9.07115 1.37492 8.9892 1.23685 8.75005C1.09878 8.5109 1.18072 8.2051 1.41986 8.06705L1.87612 7.8036C1.69797 7.39675 1.57824 6.9586 1.52749 6.50005L0.999975 6.5C0.723835 6.5 0.499987 6.2761 0.5 6C0.500015 5.72385 0.72388 5.5 1.00003 5.5L1.5275 5.50005C1.57825 5.0415 1.69796 4.60335 1.87611 4.19652L1.41987 3.93312C1.18072 3.79504 1.09878 3.48925 1.23685 3.2501C1.37492 3.01095 1.68071 2.92901 1.91985 3.06709L2.37675 3.33086C2.64514 2.96708 2.967 2.64524 3.33078 2.37684L3.06698 1.91992C2.92891 1.68077 3.01084 1.37498 3.24999 1.23691C3.48914 1.09884 3.79493 1.18077 3.933 1.41992L4.19642 1.87619C4.60327 1.69803 5.04145 1.57831 5.5 1.52755V1C5.5 0.72386 5.72385 0.5 6 0.5ZM3.83484 3.24991C3.48643 3.52463 3.19141 3.86415 2.96808 4.25014C2.67048 4.7645 2.49999 5.3616 2.49999 6.00005C2.49999 6.6385 2.67048 7.2356 2.96809 7.75C3.19142 8.13595 3.48645 8.4755 3.83486 8.7502L4.8599 6.97475C4.63581 6.71285 4.49999 6.37245 4.49999 6.00005C4.49999 5.62765 4.63581 5.28725 4.8599 5.02535L3.83484 3.24991ZM5.7258 4.52514L4.70041 2.74911C5.10185 2.58847 5.5402 2.50005 6 2.50005C6.63845 2.50005 7.23555 2.67054 7.74995 2.96816C8.28125 3.27557 8.7245 3.71882 9.0319 4.25012C9.2503 4.62764 9.4003 5.04975 9.4646 5.50005H7.41465C7.2087 4.91745 6.6531 4.50005 6 4.50005C5.9065 4.50005 5.8148 4.50865 5.7258 4.52514ZM7.41465 6.50005C7.2087 7.08265 6.6531 7.50005 6 7.50005C5.9065 7.50005 5.8148 7.49145 5.7258 7.47495L4.70043 9.251C5.10185 9.41165 5.5402 9.50005 6 9.50005C6.63845 9.50005 7.23555 9.32955 7.7499 9.03195C8.2812 8.72455 8.72445 8.2813 9.03185 7.75C9.2503 7.3725 9.4003 6.95035 9.4646 6.50005H7.41465Z",- "fill": "#676F83"- },- "children": []- }- ]- }- ]- },- "name": "GeneralType"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/GeneralType.tsx b/web/app/components/base/icons/src/public/knowledge/GeneralType.tsxdeleted file mode 100644index 7fce78a61db..00000000000--- a/web/app/components/base/icons/src/public/knowledge/GeneralType.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './GeneralType.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'GeneralType'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.json b/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.jsondeleted file mode 100644index 6f5b00eb544..00000000000--- a/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.json+++ /dev/null@@ -1,36 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "16",- "height": "16",- "viewBox": "0 0 16 16",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Icon L"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector",- "d": "M14.0002 2C14.3684 2 14.6668 2.29848 14.6668 2.66667V13.3333C14.6668 13.7015 14.3684 14 14.0002 14H2.00016C1.63198 14 1.3335 13.7015 1.3335 13.3333V2.66667C1.3335 2.29848 1.63198 2 2.00016 2H14.0002ZM13.3335 3.33333H2.66683V12.6667H13.3335V3.33333ZM14.0002 2.66667V13.3333H10.0002V2.66667H14.0002Z",- "fill": "currentColor"- },- "children": []- }- ]- }- ]- },- "name": "LayoutRight2LineMod"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.tsx b/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.tsxdeleted file mode 100644index 2189893eb39..00000000000--- a/web/app/components/base/icons/src/public/knowledge/LayoutRight2LineMod.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './LayoutRight2LineMod.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'LayoutRight2LineMod'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/ParentChildType.json b/web/app/components/base/icons/src/public/knowledge/ParentChildType.jsondeleted file mode 100644index 250da77fc88..00000000000--- a/web/app/components/base/icons/src/public/knowledge/ParentChildType.json+++ /dev/null@@ -1,56 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "10",- "height": "11",- "viewBox": "0 0 10 11",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Group"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector",- "d": "M2.70833 3.87501C3.51375 3.87501 4.16666 3.22209 4.16666 2.41668C4.16666 1.61126 3.51375 0.958344 2.70833 0.958344C1.90292 0.958344 1.25 1.61126 1.25 2.41668C1.25 3.22209 1.90292 3.87501 2.70833 3.87501Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_2",- "d": "M7.29158 3.87501C8.097 3.87501 8.74992 3.22209 8.74992 2.41668C8.74992 1.61126 8.097 0.958344 7.29158 0.958344C6.48617 0.958344 5.83325 1.61126 5.83325 2.41668C5.83325 3.22209 6.48617 3.87501 7.29158 3.87501Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_3",- "d": "M7.29167 4.70835C6.83771 4.70886 6.39118 4.82363 5.99324 5.04208C5.59529 5.26053 5.25874 5.57563 5.01459 5.95835C5.34482 5.9622 5.66011 6.09658 5.89159 6.33215C6.12306 6.56771 6.25191 6.8853 6.24998 7.21555C6.24805 7.5458 6.11551 7.86187 5.8813 8.09472C5.6471 8.32756 5.33026 8.45826 5 8.45826C4.66975 8.45826 4.35291 8.32756 4.1187 8.09472C3.8845 7.86187 3.75195 7.5458 3.75003 7.21555C3.7481 6.8853 3.87695 6.56771 4.10842 6.33215C4.3399 6.09658 4.65519 5.9622 4.98542 5.95835C4.67086 5.46415 4.20432 5.08546 3.656 4.87926C3.10767 4.67306 2.50721 4.6505 1.94496 4.81497C1.3827 4.97944 0.889064 5.32205 0.538306 5.79125C0.187547 6.26045 -0.00135882 6.83086 7.35834e-06 7.41668V10.125C7.35834e-06 10.2355 0.043906 10.3415 0.122046 10.4196C0.200186 10.4978 0.306167 10.5417 0.416674 10.5417H3.33334V9.50001L1.83334 8.37501C1.78957 8.34218 1.75269 8.30105 1.72481 8.25397C1.69693 8.20688 1.6786 8.15477 1.67086 8.1006C1.65523 7.99121 1.6837 7.88008 1.75001 7.79168C1.81631 7.70327 1.91502 7.64483 2.02441 7.6292C2.13381 7.61357 2.24493 7.64204 2.33334 7.70835L3.88875 8.87501H6.11125L7.66667 7.70835C7.75507 7.64204 7.8662 7.61357 7.97559 7.6292C8.08499 7.64483 8.1837 7.70327 8.25 7.79168C8.31631 7.88008 8.34478 7.99121 8.32915 8.1006C8.31352 8.21 8.25507 8.30871 8.16667 8.37501L6.66667 9.50001V10.5417H9.58333C9.69384 10.5417 9.79982 10.4978 9.87796 10.4196C9.9561 10.3415 10 10.2355 10 10.125V7.41668C9.99912 6.69866 9.71349 6.01029 9.20577 5.50257C8.69805 4.99485 8.00969 4.70923 7.29167 4.70835Z",- "fill": "#676F83"- },- "children": []- }- ]- }- ]- },- "name": "ParentChildType"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/ParentChildType.tsx b/web/app/components/base/icons/src/public/knowledge/ParentChildType.tsxdeleted file mode 100644index 2b13aa939c9..00000000000--- a/web/app/components/base/icons/src/public/knowledge/ParentChildType.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './ParentChildType.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'ParentChildType'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/SelectionMod.json b/web/app/components/base/icons/src/public/knowledge/SelectionMod.jsondeleted file mode 100644index ff8174a572d..00000000000--- a/web/app/components/base/icons/src/public/knowledge/SelectionMod.json+++ /dev/null@@ -1,116 +0,0 @@-{- "icon": {- "type": "element",- "isRootNode": true,- "name": "svg",- "attributes": {- "width": "10",- "height": "10",- "viewBox": "0 0 10 10",- "fill": "none",- "xmlns": "http://www.w3.org/2000/svg"- },- "children": [- {- "type": "element",- "name": "g",- "attributes": {- "id": "Group"- },- "children": [- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector",- "d": "M2.5 10H0V7.5H2.5V10Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_2",- "d": "M6.25 6.25H3.75V3.75H6.25V6.25Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_3",- "d": "M2.5 6.25H0V3.75H2.5V6.25Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_4",- "d": "M6.25 2.5H3.75V0H6.25V2.5Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_5",- "d": "M2.5 2.5H0V0H2.5V2.5Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_6",- "d": "M10 2.5H7.5V0H10V2.5Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_7",- "d": "M9.58332 7.91663H7.91666V9.58329H9.58332V7.91663Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_8",- "d": "M9.58332 4.16663H7.91666V5.83329H9.58332V4.16663Z",- "fill": "#676F83"- },- "children": []- },- {- "type": "element",- "name": "path",- "attributes": {- "id": "Vector_9",- "d": "M5.83332 7.91663H4.16666V9.58329H5.83332V7.91663Z",- "fill": "#676F83"- },- "children": []- }- ]- }- ]- },- "name": "SelectionMod"-}\ No newline at end of filediff --git a/web/app/components/base/icons/src/public/knowledge/SelectionMod.tsx b/web/app/components/base/icons/src/public/knowledge/SelectionMod.tsxdeleted file mode 100644index 19125b70634..00000000000--- a/web/app/components/base/icons/src/public/knowledge/SelectionMod.tsx+++ /dev/null@@ -1,16 +0,0 @@-// GENERATE BY script-// DON NOT EDIT IT MANUALLY--import * as React from 'react'-import data from './SelectionMod.json'-import IconBase from '@/app/components/base/icons/IconBase'-import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'--const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((- props,- ref,-) => <IconBase {...props} ref={ref} data={data as IconData} />)--Icon.displayName = 'SelectionMod'--export default Icondiff --git a/web/app/components/base/icons/src/public/knowledge/index.ts b/web/app/components/base/icons/src/public/knowledge/index.tsdeleted file mode 100644index 0af2cf341d0..00000000000--- a/web/app/components/base/icons/src/public/knowledge/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export { default as Chunk } from './Chunk'-export { default as Collapse } from './Collapse'-export { default as GeneralType } from './GeneralType'-export { default as LayoutRight2LineMod } from './LayoutRight2LineMod'-export { default as ParentChildType } from './ParentChildType'-export { default as SelectionMod } from './SelectionMod'diff --git a/web/app/components/base/icons/src/vender/features/index.ts b/web/app/components/base/icons/src/vender/features/index.tsindex 853cad8f9f1..f246732226f 100644--- a/web/app/components/base/icons/src/vender/features/index.ts+++ b/web/app/components/base/icons/src/vender/features/index.ts@@ -1,6 +1,5 @@export { default as Citations } from './Citations'export { default as ContentModeration } from './ContentModeration'-export { default as Document } from './Document'export { default as FolderUpload } from './FolderUpload'export { default as LoveMessage } from './LoveMessage'export { default as MessageFast } from './MessageFast'@@ -8,3 +7,4 @@ export { default as Microphone01 } from './Microphone01'export { default as TextToAudio } from './TextToAudio'export { default as VirtualAssistant } from './VirtualAssistant'export { default as Vision } from './Vision'+export { default as Document } from './Document'diff --git a/web/app/components/base/input-number/index.tsx b/web/app/components/base/input-number/index.tsxdeleted file mode 100644index 316d863b482..00000000000--- a/web/app/components/base/input-number/index.tsx+++ /dev/null@@ -1,86 +0,0 @@-import type { FC } from 'react'-import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react'-import Input, { type InputProps } from '../input'-import classNames from '@/utils/classnames'--export type InputNumberProps = {- unit?: string- value?: number- onChange: (value?: number) => void- amount?: number- size?: 'sm' | 'md'- max?: number- min?: number- defaultValue?: number-} & Omit<InputProps, 'value' | 'onChange' | 'size' | 'min' | 'max' | 'defaultValue'>--export const InputNumber: FC<InputNumberProps> = (props) => {- const { unit, className, onChange, amount = 1, value, size = 'md', max, min, defaultValue, ...rest } = props-- const isValidValue = (v: number) => {- if (max && v > max)- return false- if (min && v < min)- return false- return true- }-- const inc = () => {- if (value === undefined) {- onChange(defaultValue)- return- }- const newValue = value + amount- if (!isValidValue(newValue))- return- onChange(newValue)- }- const dec = () => {- if (value === undefined) {- onChange(defaultValue)- return- }- const newValue = value - amount- if (!isValidValue(newValue))- return- onChange(newValue)- }-- return <div className='flex'>- <Input {...rest}- // disable default controller- type='text'- className={classNames('rounded-r-none', className)}- value={value}- max={max}- min={min}- onChange={(e) => {- if (e.target.value === '')- onChange(undefined)-- const parsed = Number(e.target.value)- if (Number.isNaN(parsed))- return-- if (!isValidValue(parsed))- return- onChange(parsed)- }}- unit={unit}- />- <div className='flex flex-col bg-components-input-bg-normal rounded-r-md border-l border-divider-subtle text-text-tertiary focus:shadow-xs'>- <button onClick={inc} className={classNames(- size === 'sm' ? 'pt-1' : 'pt-1.5',- 'px-1.5 hover:bg-components-input-bg-hover',- )}>- <RiArrowUpSLine className='size-3' />- </button>- <button onClick={dec} className={classNames(- size === 'sm' ? 'pb-1' : 'pb-1.5',- 'px-1.5 hover:bg-components-input-bg-hover',- )}>- <RiArrowDownSLine className='size-3' />- </button>- </div>- </div>-}diff --git a/web/app/components/base/linked-apps-panel/index.tsx b/web/app/components/base/linked-apps-panel/index.tsxdeleted file mode 100644index 4320cb0fc63..00000000000--- a/web/app/components/base/linked-apps-panel/index.tsx+++ /dev/null@@ -1,62 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import Link from 'next/link'-import { useTranslation } from 'react-i18next'-import { RiArrowRightUpLine } from '@remixicon/react'-import cn from '@/utils/classnames'-import AppIcon from '@/app/components/base/app-icon'-import type { RelatedApp } from '@/models/datasets'--type ILikedItemProps = {- appStatus?: boolean- detail: RelatedApp- isMobile: boolean-}--const appTypeMap = {- 'chat': 'Chatbot',- 'completion': 'Completion',- 'agent-chat': 'Agent',- 'advanced-chat': 'Chatflow',- 'workflow': 'Workflow',-}--const LikedItem = ({- detail,- isMobile,-}: ILikedItemProps) => {- return (- <Link className={cn('group/link-item flex items-center justify-between w-full h-8 rounded-lg hover:bg-state-base-hover cursor-pointer px-2', isMobile && 'justify-center')} href={`/app/${detail?.id}/overview`}>- <div className='flex items-center'>- <div className={cn('relative w-6 h-6 rounded-md')}>- <AppIcon size='tiny' iconType={detail.icon_type} icon={detail.icon} background={detail.icon_background} imageUrl={detail.icon_url} />- </div>- {!isMobile && <div className={cn(' ml-2 truncate system-sm-medium text-text-primary')}>{detail?.name || '--'}</div>}- </div>- <div className='group-hover/link-item:hidden shrink-0 system-2xs-medium-uppercase text-text-tertiary'>{appTypeMap[detail.mode]}</div>- <RiArrowRightUpLine className='hidden group-hover/link-item:block w-4 h-4 text-text-tertiary' />- </Link>- )-}--type Props = {- relatedApps: RelatedApp[]- isMobile: boolean-}--const LinkedAppsPanel: FC<Props> = ({- relatedApps,- isMobile,-}) => {- const { t } = useTranslation()- return (- <div className='p-1 w-[320px] bg-components-panel-bg-blur border-[0.5px] border-components-panel-border shadow-lg rounded-xl backdrop-blur-[5px]'>- <div className='mt-1 mb-0.5 pl-2 system-xs-medium-uppercase text-text-tertiary'>{relatedApps.length || '--'} {t('common.datasetMenus.relatedApp')}</div>- {relatedApps.map((item, index) => (- <LikedItem key={index} detail={item} isMobile={isMobile} />- ))}- </div>- )-}-export default React.memo(LinkedAppsPanel)diff --git a/web/app/components/base/pagination/index.tsx b/web/app/components/base/pagination/index.tsxindex c0cc9f86ec2..b64c7124251 100644--- a/web/app/components/base/pagination/index.tsx+++ b/web/app/components/base/pagination/index.tsx@@ -8,7 +8,7 @@ import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import cn from '@/utils/classnames'-export type Props = {+type Props = {className?: stringcurrent: numberonChange: (cur: number) => voiddiff --git a/web/app/components/base/param-item/index.tsx b/web/app/components/base/param-item/index.tsxindex 68c980ad095..49acc814845 100644--- a/web/app/components/base/param-item/index.tsx+++ b/web/app/components/base/param-item/index.tsx@@ -1,6 +1,5 @@'use client'import type { FC } from 'react'-import { InputNumber } from '../input-number'import Tooltip from '@/app/components/base/tooltip'import Slider from '@/app/components/base/slider'import Switch from '@/app/components/base/switch'@@ -24,44 +23,39 @@ type Props = {const ParamItem: FC<Props> = ({ className, id, name, noTooltip, tip, step = 0.1, min = 0, max, value, enable, onChange, hasSwitch, onSwitchChange }) => {return (<div className={className}>- <div className="flex items-center justify-between">- <div className="flex items-center h-6">+ <div className="flex items-center h-8 justify-between">+ <div className="flex items-center">{hasSwitch && (<Switchsize='md'- className='mr-2'defaultValue={enable}onChange={async (val) => {onSwitchChange?.(id, val)}}/>)}- <span className="mr-1 text-text-secondary system-sm-semibold">{name}</span>+ <span className="mx-1 text-gray-900 text-[13px] leading-[18px] font-medium">{name}</span>{!noTooltip && (<TooltiptriggerClassName='w-4 h-4 shrink-0'popupContent={<div className="w-[200px]">{tip}</div>}/>)}+</div>+ <div className="flex items-center"></div></div>- <div className="mt-1 flex items-center">- <div className="mr-3 flex shrink-0 items-center">- <InputNumber- disabled={!enable}- type="number"- min={min}- max={max}- step={step}- size='sm'- value={value}- onChange={(value) => {- onChange(id, value)- }}- className='w-[72px]'- />+ <div className="mt-2 flex items-center">+ <div className="mr-4 flex shrink-0 items-center">+ <input disabled={!enable} type="number" min={min} max={max} step={step} className="block w-[48px] h-7 text-xs leading-[18px] rounded-lg border-0 pl-1 pl py-1.5 bg-gray-50 text-gray-900 placeholder:text-gray-400 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-60" value={(value === null || value === undefined) ? '' : value} onChange={(e) => {+ const value = parseFloat(e.target.value)+ if (value < min || value > max)+ return++ onChange(id, value)+ }} /></div>- <div className="flex items-center grow">+ <div className="flex items-center h-7 grow"><SliderclassName='w-full'disabled={!enable}diff --git a/web/app/components/base/radio-card/index.tsx b/web/app/components/base/radio-card/index.tsxindex b8e8440dd07..28fd5dc143a 100644--- a/web/app/components/base/radio-card/index.tsx+++ b/web/app/components/base/radio-card/index.tsx@@ -26,26 +26,24 @@ const RadioCard: FC<Props> = ({onChosen = () => { },chosenConfig,chosenConfigWrapClassName,- className,}) => {return (<divclassName={cn(- 'relative p-3 border-[0.5px] border-components-option-card-option-border bg-components-option-card-option-bg rounded-xl cursor-pointer',- isChosen && 'border-[1.5px] bg-components-option-card-option-selected-bg',- className,+ 'border border-components-option-card-option-border bg-components-option-card-option-bg rounded-xl hover:shadow-xs cursor-pointer',+ isChosen && 'bg-components-option-card-option-selected-bg border-components-panel-border shadow-xs',)}>- <div className='flex gap-x-2' onClick={onChosen}>- <div className={cn(iconBgClassName, 'shrink-0 flex size-8 justify-center items-center rounded-lg shadow-md')}>+ <div className='flex py-3 pl-3 pr-4' onClick={onChosen}>+ <div className={cn(iconBgClassName, 'mr-3 shrink-0 flex w-8 justify-center h-8 items-center rounded-lg')}>{icon}</div><div className='grow'>- <div className='system-sm-semibold text-text-secondary mb-1'>{title}</div>- <div className='system-xs-regular text-text-tertiary'>{description}</div>+ <div className='leading-5 text-sm font-medium text-gray-900'>{title}</div>+ <div className='leading-[18px] text-xs font-normal text-[#667085]'>{description}</div></div>{!noRadio && (- <div className='absolute top-3 right-3'>+ <div className='shrink-0 flex items-center h-8'><div className={cn('w-4 h-4 border border-components-radio-border bg-components-radio-bg shadow-xs rounded-full',isChosen && 'border-[5px] border-components-radio-border-checked',@@ -54,11 +52,8 @@ const RadioCard: FC<Props> = ({)}</div>{((isChosen && chosenConfig) || noRadio) && (- <div className='flex gap-x-2 mt-2'>- <div className='size-8 shrink-0'></div>- <div className={cn(chosenConfigWrapClassName, 'grow')}>- {chosenConfig}- </div>+ <div className={cn(chosenConfigWrapClassName, 'p-3 border-t border-gray-200')}>+ {chosenConfig}</div>)}</div>diff --git a/web/app/components/base/retry-button/index.tsx b/web/app/components/base/retry-button/index.tsxnew file mode 100644index 00000000000..689827af7b3--- /dev/null+++ b/web/app/components/base/retry-button/index.tsx@@ -0,0 +1,85 @@+'use client'+import type { FC } from 'react'+import React, { useEffect, useReducer } from 'react'+import { useTranslation } from 'react-i18next'+import useSWR from 'swr'+import s from './style.module.css'+import classNames from '@/utils/classnames'+import Divider from '@/app/components/base/divider'+import { getErrorDocs, retryErrorDocs } from '@/service/datasets'+import type { IndexingStatusResponse } from '@/models/datasets'++const WarningIcon = () =>+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000 /svg">+ <path fillRule="evenodd" clipRule="evenodd" d="M6.40616 0.834307C6.14751 0.719294 5.85222 0.719294 5.59356 0.834307C5.3938 0.923133 5.26403 1.07959 5.17373 1.20708C5.08495 1.33242 4.9899 1.49664 4.88536 1.67723L0.751783 8.81705C0.646828 8.9983 0.551451 9.16302 0.486781 9.3028C0.421056 9.44487 0.349754 9.63584 0.372478 9.85381C0.401884 10.1359 0.549654 10.3922 0.779012 10.5589C0.956259 10.6878 1.15726 10.7218 1.31314 10.7361C1.46651 10.7501 1.65684 10.7501 1.86628 10.7501H10.1334C10.3429 10.7501 10.5332 10.7501 10.6866 10.7361C10.8425 10.7218 11.0435 10.6878 11.2207 10.5589C11.4501 10.3922 11.5978 10.1359 11.6272 9.85381C11.65 9.63584 11.5787 9.44487 11.5129 9.3028C11.4483 9.16303 11.3529 8.99833 11.248 8.81709L7.11436 1.67722C7.00983 1.49663 6.91477 1.33242 6.82599 1.20708C6.73569 1.07959 6.60593 0.923133 6.40616 0.834307ZM6.49988 4.50012C6.49988 4.22398 6.27602 4.00012 5.99988 4.00012C5.72374 4.00012 5.49988 4.22398 5.49988 4.50012V6.50012C5.49988 6.77626 5.72374 7.00012 5.99988 7.00012C6.27602 7.00012 6.49988 6.77626 6.49988 6.50012V4.50012ZM5.99988 8.00012C5.72374 8.00012 5.49988 8.22398 5.49988 8.50012C5.49988 8.77626 5.72374 9.00012 5.99988 9.00012H6.00488C6.28102 9.00012 6.50488 8.77626 6.50488 8.50012C6.50488 8.22398 6.28102 8.00012 6.00488 8.00012H5.99988Z" fill="#F79009" />+ </svg>++type Props = {+ datasetId: string+}+type IIndexState = {+ value: string+}+type ActionType = 'retry' | 'success' | 'error'++type IAction = {+ type: ActionType+}+const indexStateReducer = (state: IIndexState, action: IAction) => {+ const actionMap = {+ retry: 'retry',+ success: 'success',+ error: 'error',+ }++ return {+ ...state,+ value: actionMap[action.type] || state.value,+ }+}++const RetryButton: FC<Props> = ({ datasetId }) => {+ const { t } = useTranslation()+ const [indexState, dispatch] = useReducer(indexStateReducer, { value: 'success' })+ const { data: errorDocs } = useSWR({ datasetId }, getErrorDocs)++ const onRetryErrorDocs = async () => {+ dispatch({ type: 'retry' })+ const document_ids = errorDocs?.data.map((doc: IndexingStatusResponse) => doc.id) || []+ const res = await retryErrorDocs({ datasetId, document_ids })+ if (res.result === 'success')+ dispatch({ type: 'success' })+ else+ dispatch({ type: 'error' })+ }++ useEffect(() => {+ if (errorDocs?.total === 0)+ dispatch({ type: 'success' })+ else+ dispatch({ type: 'error' })+ }, [errorDocs?.total])++ if (indexState.value === 'success')+ return null++ return (+ <div className={classNames('inline-flex justify-center items-center gap-2', s.retryBtn)}>+ <WarningIcon />+ <span className='flex shrink-0 text-sm text-gray-500'>+ {errorDocs?.total} {t('dataset.docsFailedNotice')}+ </span>+ <Divider type='vertical' className='!h-4' />+ <span+ className={classNames(+ 'text-primary-600 font-semibold text-sm cursor-pointer',+ indexState.value === 'retry' && '!text-gray-500 !cursor-not-allowed',+ )}+ onClick={indexState.value === 'error' ? onRetryErrorDocs : undefined}+ >+ {t('dataset.retry')}+ </span>+ </div>+ )+}+export default RetryButtondiff --git a/web/app/components/base/retry-button/style.module.css b/web/app/components/base/retry-button/style.module.cssnew file mode 100644index 00000000000..99a0947576d--- /dev/null+++ b/web/app/components/base/retry-button/style.module.css@@ -0,0 +1,4 @@+.retryBtn {+ @apply inline-flex justify-center items-center content-center h-9 leading-5 rounded-lg px-4 py-2 text-base;+ @apply border-solid border border-gray-200 text-gray-500 hover:bg-white hover:shadow-sm hover:border-gray-300;+}diff --git a/web/app/components/base/simple-pie-chart/index.tsx b/web/app/components/base/simple-pie-chart/index.tsxindex 4b987ab42de..7de539cbb1a 100644--- a/web/app/components/base/simple-pie-chart/index.tsx+++ b/web/app/components/base/simple-pie-chart/index.tsx@@ -10,11 +10,10 @@ export type SimplePieChartProps = {fill?: stringstroke?: stringsize?: number- animationDuration?: numberclassName?: string}-const SimplePieChart = ({ percentage = 80, fill = '#fdb022', stroke = '#f79009', size = 12, animationDuration, className }: SimplePieChartProps) => {+const SimplePieChart = ({ percentage = 80, fill = '#fdb022', stroke = '#f79009', size = 12, className }: SimplePieChartProps) => {const option: EChartsOption = useMemo(() => ({series: [{@@ -35,7 +34,7 @@ const SimplePieChart = ({ percentage = 80, fill = '#fdb022', stroke = '#f79009',{type: 'pie',radius: '83%',- animationDuration: animationDuration ?? 600,+ animationDuration: 600,data: [{ value: percentage, itemStyle: { color: fill } },{ value: 100 - percentage, itemStyle: { color: '#fff' } },@@ -49,7 +48,7 @@ const SimplePieChart = ({ percentage = 80, fill = '#fdb022', stroke = '#f79009',cursor: 'default',},],- }), [stroke, fill, percentage, animationDuration])+ }), [stroke, fill, percentage])return (<ReactEChartsdiff --git a/web/app/components/base/skeleton/index.tsx b/web/app/components/base/skeleton/index.tsxindex a2d4e4da631..5f29c22f7c3 100644--- a/web/app/components/base/skeleton/index.tsx+++ b/web/app/components/base/skeleton/index.tsx@@ -3,7 +3,7 @@ import classNames from '@/utils/classnames'type SkeletonProps = ComponentProps<'div'>-export const SkeletonContainer: FC<SkeletonProps> = (props) => {+export const SkeletonContanier: FC<SkeletonProps> = (props) => {const { className, children, ...rest } = propsreturn (<div className={classNames('flex flex-col gap-1', className)} {...rest}>@@ -30,14 +30,11 @@ export const SkeletonRectangle: FC<SkeletonProps> = (props) => {)}-export const SkeletonPoint: FC<SkeletonProps> = (props) => {- const { className, ...rest } = props- return (- <div className={classNames('text-text-quaternary text-xs font-medium', className)} {...rest}>·</div>- )-}+export const SkeletonPoint: FC = () =>+ <div className='text-text-quaternary text-xs font-medium'>·</div>+/** Usage- * <SkeletonContainer>+ * <SkeletonContanier>* <SkeletonRow>* <SkeletonRectangle className="w-96" />* <SkeletonPoint />diff --git a/web/app/components/base/switch/index.tsx b/web/app/components/base/switch/index.tsxindex 8bf32b1311b..f61c6f46fff 100644--- a/web/app/components/base/switch/index.tsx+++ b/web/app/components/base/switch/index.tsx@@ -64,7 +64,4 @@ const Switch = ({ onChange, size = 'md', defaultValue = false, disabled = false,</OriginalSwitch>)}--Switch.displayName = 'Switch'-export default React.memo(Switch)diff --git a/web/app/components/base/tag-input/index.tsx b/web/app/components/base/tag-input/index.tsxindex ec6c1cee342..b26d0c6438c 100644--- a/web/app/components/base/tag-input/index.tsx+++ b/web/app/components/base/tag-input/index.tsx@@ -3,8 +3,8 @@ import type { ChangeEvent, FC, KeyboardEvent } from 'react'import { } from 'use-context-selector'import { useTranslation } from 'react-i18next'import AutosizeInput from 'react-18-input-autosize'-import { RiAddLine, RiCloseLine } from '@remixicon/react'import cn from '@/utils/classnames'+import { X } from '@/app/components/base/icons/src/vender/line/general'import { useToastContext } from '@/app/components/base/toast'type TagInputProps = {@@ -75,14 +75,14 @@ const TagInput: FC<TagInputProps> = ({(items || []).map((item, index) => (<divkey={item}- className={cn('flex items-center mr-1 mt-1 pl-1.5 pr-1 py-1 system-xs-regular text-text-secondary border border-divider-deep bg-components-badge-white-to-dark rounded-md')}- >+ className={cn('flex items-center mr-1 mt-1 px-2 py-1 text-sm text-gray-700 border border-gray-200', isSpecialMode ? 'bg-white rounded-md' : 'rounded-lg')}>{item}{!disableRemove && (- <div className='flex items-center justify-center w-4 h-4 cursor-pointer' onClick={() => handleRemove(index)}>- <RiCloseLine className='ml-0.5 w-3.5 h-3.5 text-text-tertiary' />- </div>+ <X+ className='ml-0.5 w-3 h-3 text-gray-500 cursor-pointer'+ onClick={() => handleRemove(index)}+ />)}</div>@@ -90,27 +90,24 @@ const TagInput: FC<TagInputProps> = ({}{!disableAdd && (- <div className={cn('flex items-center gap-x-0.5 mt-1 group/tag-add', !isSpecialMode ? 'px-1.5 rounded-md border border-dashed border-divider-deep' : '')}>- {!isSpecialMode && !focused && <RiAddLine className='w-3.5 h-3.5 text-text-placeholder group-hover/tag-add:text-text-secondary' />}- <AutosizeInput- inputClassName={cn('outline-none appearance-none placeholder:text-text-placeholder caret-[#295EFF] group-hover/tag-add:placeholder:text-text-secondary', isSpecialMode ? 'bg-transparent' : '')}- className={cn(- !isInWorkflow && 'max-w-[300px]',- isInWorkflow && 'max-w-[146px]',- `- py-1 rounded-md overflow-hidden system-xs-regular- ${focused && isSpecialMode && 'px-1.5 border border-dashed border-divider-deep'}- `)}- onFocus={() => setFocused(true)}- onBlur={handleBlur}- value={value}- onChange={(e: ChangeEvent<HTMLInputElement>) => {- setValue(e.target.value)- }}- onKeyDown={handleKeyDown}- placeholder={t(placeholder || (isSpecialMode ? 'common.model.params.stop_sequencesPlaceholder' : 'datasetDocuments.segment.addKeyWord'))}- />- </div>+ <AutosizeInput+ inputClassName={cn('outline-none appearance-none placeholder:text-gray-300 caret-primary-600 hover:placeholder:text-gray-400', isSpecialMode ? 'bg-transparent' : '')}+ className={cn(+ !isInWorkflow && 'max-w-[300px]',+ isInWorkflow && 'max-w-[146px]',+ `+ mt-1 py-1 rounded-lg border border-transparent text-sm overflow-hidden+ ${focused && 'px-2 border !border-dashed !border-gray-200'}+ `)}+ onFocus={() => setFocused(true)}+ onBlur={handleBlur}+ value={value}+ onChange={(e: ChangeEvent<HTMLInputElement>) => {+ setValue(e.target.value)+ }}+ onKeyDown={handleKeyDown}+ placeholder={t(placeholder || (isSpecialMode ? 'common.model.params.stop_sequencesPlaceholder' : 'datasetDocuments.segment.addKeyWord'))}+ />)}</div>diff --git a/web/app/components/base/toast/index.tsx b/web/app/components/base/toast/index.tsxindex ba7d8af518e..b9a6de9fe5a 100644--- a/web/app/components/base/toast/index.tsx+++ b/web/app/components/base/toast/index.tsx@@ -21,7 +21,6 @@ export type IToastProps = {children?: ReactNodeonClose?: () => voidclassName?: string- customComponent?: ReactNode}type IToastContext = {notify: (props: IToastProps) => void@@ -36,7 +35,6 @@ const Toast = ({message,children,className,- customComponent,}: IToastProps) => {const { close } = useToastContext()// sometimes message is react node array. Not handle it.@@ -51,7 +49,8 @@ const Toast = ({'top-0','right-0',)}>- <div className={`absolute inset-0 opacity-40 -z-10 ${(type === 'success' && 'bg-[linear-gradient(92deg,rgba(23,178,106,0.25)_0%,rgba(255,255,255,0.00)_100%)]')+ <div className={`absolute inset-0 opacity-40 ${+ (type === 'success' && 'bg-[linear-gradient(92deg,rgba(23,178,106,0.25)_0%,rgba(255,255,255,0.00)_100%)]')|| (type === 'warning' && 'bg-[linear-gradient(92deg,rgba(247,144,9,0.25)_0%,rgba(255,255,255,0.00)_100%)]')|| (type === 'error' && 'bg-[linear-gradient(92deg,rgba(240,68,56,0.25)_0%,rgba(255,255,255,0.00)_100%)]')|| (type === 'info' && 'bg-[linear-gradient(92deg,rgba(11,165,236,0.25)_0%,rgba(255,255,255,0.00)_100%)]')@@ -64,17 +63,14 @@ const Toast = ({{type === 'warning' && <RiAlertFill className={`${size === 'md' ? 'w-5 h-5' : 'w-4 h-4'} text-text-warning-secondary`} aria-hidden="true" />}{type === 'info' && <RiInformation2Fill className={`${size === 'md' ? 'w-5 h-5' : 'w-4 h-4'} text-text-accent`} aria-hidden="true" />}</div>- <div className={`flex py-1 ${size === 'md' ? 'px-1' : 'px-0.5'} flex-col items-start gap-1 flex-grow z-10`}>- <div className='flex items-center gap-1'>- <div className='text-text-primary system-sm-semibold'>{message}</div>- {customComponent}- </div>+ <div className={`flex py-1 ${size === 'md' ? 'px-1' : 'px-0.5'} flex-col items-start gap-1 flex-grow`}>+ <div className='text-text-primary system-sm-semibold'>{message}</div>{children && <div className='text-text-secondary system-xs-regular'>{children}</div>}</div>- <ActionButton onClick={close}>+ <ActionButton className='z-[1000]' onClick={close}><RiCloseLine className='w-4 h-4 flex-shrink-0 text-text-tertiary' /></ActionButton></div>@@ -121,8 +117,7 @@ Toast.notify = ({message,duration,className,- customComponent,-}: Pick<IToastProps, 'type' | 'size' | 'message' | 'duration' | 'className' | 'customComponent'>) => {+}: Pick<IToastProps, 'type' | 'size' | 'message' | 'duration' | 'className'>) => {const defaultDuring = (type === 'success' || type === 'info') ? 3000 : 6000if (typeof window === 'object') {const holder = document.createElement('div')@@ -138,7 +133,7 @@ Toast.notify = ({}},}}>- <Toast type={type} size={size} message={message} duration={duration} className={className} customComponent={customComponent} />+ <Toast type={type} size={size} message={message} duration={duration} className={className} /></ToastContext.Provider>,)document.body.appendChild(holder)diff --git a/web/app/components/base/tooltip/index.tsx b/web/app/components/base/tooltip/index.tsxindex 65b5a99077c..8ec3cd8c7ab 100644--- a/web/app/components/base/tooltip/index.tsx+++ b/web/app/components/base/tooltip/index.tsx@@ -14,7 +14,6 @@ export type TooltipProps = {popupContent?: React.ReactNodechildren?: React.ReactNodepopupClassName?: string- noDecoration?: booleanoffset?: OffsetOptionsneedsDelay?: booleanasChild?: boolean@@ -28,7 +27,6 @@ const Tooltip: FC<TooltipProps> = ({popupContent,children,popupClassName,- noDecoration,offset,asChild = true,needsDelay = false,@@ -98,7 +96,7 @@ const Tooltip: FC<TooltipProps> = ({>{popupContent && (<divclassName={cn(- !noDecoration && 'relative px-3 py-2 system-xs-regular text-text-tertiary bg-components-panel-bg rounded-md shadow-lg break-words',+ 'relative px-3 py-2 system-xs-regular text-text-tertiary bg-components-panel-bg rounded-md shadow-lg break-words',popupClassName,)}onMouseEnter={() => triggerMethod === 'hover' && setHoverPopup()}diff --git a/web/app/components/billing/priority-label/index.tsx b/web/app/components/billing/priority-label/index.tsxindex 6ecac4a79ea..36338cf4a8e 100644--- a/web/app/components/billing/priority-label/index.tsx+++ b/web/app/components/billing/priority-label/index.tsx@@ -4,7 +4,6 @@ import {DocumentProcessingPriority,Plan,} from '../type'-import cn from '@/utils/classnames'import { useProviderContext } from '@/context/provider-context'import {ZapFast,@@ -12,11 +11,7 @@ import {} from '@/app/components/base/icons/src/vender/solid/general'import Tooltip from '@/app/components/base/tooltip'-type PriorityLabelProps = {- className?: string-}--const PriorityLabel = ({ className }: PriorityLabelProps) => {+const PriorityLabel = () => {const { t } = useTranslation()const { plan } = useProviderContext()@@ -42,18 +37,18 @@ const PriorityLabel = ({ className }: PriorityLabelProps) => {}</div>}>- <span className={cn(`- shrink-0 flex items-center ml-1 px-1 h-[18px] rounded-[5px] border border-text-accent-secondary- text-2xs font-medium text-text-accent-secondary- `, className)}>+ <span className={`+ flex items-center ml-1 px-[5px] h-[18px] rounded border border-[#C7D7FE]+ text-[10px] font-medium text-[#3538CD]+ `}>{plan.type === Plan.professional && (- <ZapNarrow className='mr-0.5 size-3' />+ <ZapNarrow className='mr-0.5 w-3 h-3' />)}{(plan.type === Plan.team || plan.type === Plan.enterprise) && (- <ZapFast className='mr-0.5 size-3' />+ <ZapFast className='mr-0.5 w-3 h-3' />)}{t(`billing.plansCommon.priority.${priority}`)}diff --git a/web/app/components/datasets/chunk.tsx b/web/app/components/datasets/chunk.tsxdeleted file mode 100644index bf2835dbdbe..00000000000--- a/web/app/components/datasets/chunk.tsx+++ /dev/null@@ -1,54 +0,0 @@-import type { FC, PropsWithChildren } from 'react'-import { SelectionMod } from '../base/icons/src/public/knowledge'-import type { QA } from '@/models/datasets'--export type ChunkLabelProps = {- label: string- characterCount: number-}--export const ChunkLabel: FC<ChunkLabelProps> = (props) => {- const { label, characterCount } = props- return <div className='flex items-center text-text-tertiary text-xs font-medium'>- <SelectionMod className='size-[10px]' />- <p className='flex gap-2 ml-0.5'><span>- {label}- </span>- <span>- ·- </span>- <span>- {`${characterCount} characters`}- </span></p>- </div>-}--export type ChunkContainerProps = ChunkLabelProps & PropsWithChildren--export const ChunkContainer: FC<ChunkContainerProps> = (props) => {- const { label, characterCount, children } = props- return <div className='space-y-2'>- <ChunkLabel label={label} characterCount={characterCount} />- <div className='text-text-secondary body-md-regular'>- {children}- </div>- </div>-}--export type QAPreviewProps = {- qa: QA-}--export const QAPreview: FC<QAPreviewProps> = (props) => {- const { qa } = props- return <div className='flex flex-col gap-y-2'>- <div className='flex gap-x-1'>- <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>Q</label>- <p className='text-text-secondary body-md-regular'>{qa.question}</p>- </div>- <div className='flex gap-x-1'>- <label className='text-text-tertiary text-[13px] font-medium leading-[20px] shrink-0'>A</label>- <p className='text-text-secondary body-md-regular'>{qa.answer}</p>- </div>- </div>-}diff --git a/web/app/components/datasets/common/chunking-mode-label.tsx b/web/app/components/datasets/common/chunking-mode-label.tsxdeleted file mode 100644index 7c6e924009d..00000000000--- a/web/app/components/datasets/common/chunking-mode-label.tsx+++ /dev/null@@ -1,29 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import { useTranslation } from 'react-i18next'-import Badge from '@/app/components/base/badge'-import { GeneralType, ParentChildType } from '@/app/components/base/icons/src/public/knowledge'--type Props = {- isGeneralMode: boolean- isQAMode: boolean-}--const ChunkingModeLabel: FC<Props> = ({- isGeneralMode,- isQAMode,-}) => {- const { t } = useTranslation()- const TypeIcon = isGeneralMode ? GeneralType : ParentChildType-- return (- <Badge>- <div className='flex items-center h-full space-x-0.5 text-text-tertiary'>- <TypeIcon className='w-3 h-3' />- <span className='system-2xs-medium-uppercase'>{isGeneralMode ? `${t('dataset.chunkingMode.general')}${isQAMode ? ' · QA' : ''}` : t('dataset.chunkingMode.parentChild')}</span>- </div>- </Badge>- )-}-export default React.memo(ChunkingModeLabel)diff --git a/web/app/components/datasets/common/document-file-icon.tsx b/web/app/components/datasets/common/document-file-icon.tsxdeleted file mode 100644index 5842cbbc7c3..00000000000--- a/web/app/components/datasets/common/document-file-icon.tsx+++ /dev/null@@ -1,40 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import FileTypeIcon from '../../base/file-uploader/file-type-icon'-import type { FileAppearanceType } from '@/app/components/base/file-uploader/types'-import { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'--const extendToFileTypeMap: { [key: string]: FileAppearanceType } = {- pdf: FileAppearanceTypeEnum.pdf,- json: FileAppearanceTypeEnum.document,- html: FileAppearanceTypeEnum.document,- txt: FileAppearanceTypeEnum.document,- markdown: FileAppearanceTypeEnum.markdown,- md: FileAppearanceTypeEnum.markdown,- xlsx: FileAppearanceTypeEnum.excel,- xls: FileAppearanceTypeEnum.excel,- csv: FileAppearanceTypeEnum.excel,- doc: FileAppearanceTypeEnum.word,- docx: FileAppearanceTypeEnum.word,-}--type Props = {- extension?: string- name?: string- size?: 'sm' | 'lg' | 'md'- className?: string-}--const DocumentFileIcon: FC<Props> = ({- extension,- name,- size = 'md',- className,-}) => {- const localExtension = extension?.toLowerCase() || name?.split('.')?.pop()?.toLowerCase()- return (- <FileTypeIcon type={extendToFileTypeMap[localExtension!] || FileAppearanceTypeEnum.document} size={size} className={className} />- )-}-export default React.memo(DocumentFileIcon)diff --git a/web/app/components/datasets/common/document-picker/document-list.tsx b/web/app/components/datasets/common/document-picker/document-list.tsxdeleted file mode 100644index 3e320d75073..00000000000--- a/web/app/components/datasets/common/document-picker/document-list.tsx+++ /dev/null@@ -1,42 +0,0 @@-'use client'-import type { FC } from 'react'-import React, { useCallback } from 'react'-import FileIcon from '../document-file-icon'-import cn from '@/utils/classnames'-import type { DocumentItem } from '@/models/datasets'--type Props = {- className?: string- list: DocumentItem[]- onChange: (value: DocumentItem) => void-}--const DocumentList: FC<Props> = ({- className,- list,- onChange,-}) => {- const handleChange = useCallback((item: DocumentItem) => {- return () => onChange(item)- }, [onChange])-- return (- <div className={cn(className)}>- {list.map((item) => {- const { id, name, extension } = item- return (- <div- key={id}- className='flex items-center h-8 px-2 hover:bg-state-base-hover rounded-lg space-x-2 cursor-pointer'- onClick={handleChange(item)}- >- <FileIcon name={item.name} extension={extension} size='md' />- <div className='truncate text-text-secondary text-sm'>{name}</div>- </div>- )- })}- </div>- )-}--export default React.memo(DocumentList)diff --git a/web/app/components/datasets/common/document-picker/index.tsx b/web/app/components/datasets/common/document-picker/index.tsxdeleted file mode 100644index 30690fca007..00000000000--- a/web/app/components/datasets/common/document-picker/index.tsx+++ /dev/null@@ -1,118 +0,0 @@-'use client'-import type { FC } from 'react'-import React, { useCallback, useState } from 'react'-import { useBoolean } from 'ahooks'-import { RiArrowDownSLine } from '@remixicon/react'-import { useTranslation } from 'react-i18next'-import FileIcon from '../document-file-icon'-import DocumentList from './document-list'-import type { DocumentItem, ParentMode, SimpleDocumentDetail } from '@/models/datasets'-import { ProcessMode } from '@/models/datasets'-import {- PortalToFollowElem,- PortalToFollowElemContent,- PortalToFollowElemTrigger,-} from '@/app/components/base/portal-to-follow-elem'-import cn from '@/utils/classnames'-import SearchInput from '@/app/components/base/search-input'-import { GeneralType, ParentChildType } from '@/app/components/base/icons/src/public/knowledge'-import { useDocumentList } from '@/service/knowledge/use-document'-import Loading from '@/app/components/base/loading'--type Props = {- datasetId: string- value: {- name?: string- extension?: string- processMode?: ProcessMode- parentMode?: ParentMode- }- onChange: (value: SimpleDocumentDetail) => void-}--const DocumentPicker: FC<Props> = ({- datasetId,- value,- onChange,-}) => {- const { t } = useTranslation()- const {- name,- extension,- processMode,- parentMode,- } = value- const [query, setQuery] = useState('')-- const { data } = useDocumentList({- datasetId,- query: {- keyword: query,- page: 1,- limit: 20,- },- })- const documentsList = data?.data- const isParentChild = processMode === ProcessMode.parentChild- const TypeIcon = isParentChild ? ParentChildType : GeneralType-- const [open, {- set: setOpen,- toggle: togglePopup,- }] = useBoolean(false)- const ArrowIcon = RiArrowDownSLine-- const handleChange = useCallback(({ id }: DocumentItem) => {- onChange(documentsList?.find(item => item.id === id) as SimpleDocumentDetail)- setOpen(false)- }, [documentsList, onChange, setOpen])-- return (- <PortalToFollowElem- open={open}- onOpenChange={setOpen}- placement='bottom-start'- >- <PortalToFollowElemTrigger onClick={togglePopup}>- <div className={cn('flex items-center ml-1 px-2 py-0.5 rounded-lg hover:bg-state-base-hover select-none cursor-pointer', open && 'bg-state-base-hover')}>- <FileIcon name={name} extension={extension} size='lg' />- <div className='flex flex-col items-start ml-1 mr-0.5'>- <div className='flex items-center space-x-0.5'>- <span className={cn('system-md-semibold')}> {name || '--'}</span>- <ArrowIcon className={'h-4 w-4 text-text-primary'} />- </div>- <div className='flex items-center h-3 text-text-tertiary space-x-0.5'>- <TypeIcon className='w-3 h-3' />- <span className={cn('system-2xs-medium-uppercase', isParentChild && 'mt-0.5' /* to icon problem cause not ver align */)}>- {isParentChild ? t('dataset.chunkingMode.parentChild') : t('dataset.chunkingMode.general')}- {isParentChild && ` · ${!parentMode ? '--' : parentMode === 'paragraph' ? t('dataset.parentMode.paragraph') : t('dataset.parentMode.fullDoc')}`}- </span>- </div>- </div>- </div>- </PortalToFollowElemTrigger>- <PortalToFollowElemContent className='z-[11]'>- <div className='w-[360px] p-1 pt-2 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]'>- <SearchInput value={query} onChange={setQuery} className='mx-1' />- {documentsList- ? (- <DocumentList- className='mt-2'- list={documentsList.map(d => ({- id: d.id,- name: d.name,- extension: d.data_source_detail_dict?.upload_file?.extension || '',- }))}- onChange={handleChange}- />- )- : (<div className='mt-2 flex items-center justify-center w-[360px] h-[100px]'>- <Loading />- </div>)}- </div>-- </PortalToFollowElemContent>- </PortalToFollowElem>- )-}-export default React.memo(DocumentPicker)diff --git a/web/app/components/datasets/common/document-picker/preview-document-picker.tsx b/web/app/components/datasets/common/document-picker/preview-document-picker.tsxdeleted file mode 100644index 2a35b75471c..00000000000--- a/web/app/components/datasets/common/document-picker/preview-document-picker.tsx+++ /dev/null@@ -1,82 +0,0 @@-'use client'-import type { FC } from 'react'-import React, { useCallback } from 'react'-import { useBoolean } from 'ahooks'-import { RiArrowDownSLine } from '@remixicon/react'-import { useTranslation } from 'react-i18next'-import FileIcon from '../document-file-icon'-import DocumentList from './document-list'-import {- PortalToFollowElem,- PortalToFollowElemContent,- PortalToFollowElemTrigger,-} from '@/app/components/base/portal-to-follow-elem'-import cn from '@/utils/classnames'-import Loading from '@/app/components/base/loading'-import type { DocumentItem } from '@/models/datasets'--type Props = {- className?: string- value: DocumentItem- files: DocumentItem[]- onChange: (value: DocumentItem) => void-}--const PreviewDocumentPicker: FC<Props> = ({- className,- value,- files,- onChange,-}) => {- const { t } = useTranslation()- const { name, extension } = value-- const [open, {- set: setOpen,- toggle: togglePopup,- }] = useBoolean(false)- const ArrowIcon = RiArrowDownSLine-- const handleChange = useCallback((item: DocumentItem) => {- onChange(item)- setOpen(false)- }, [onChange, setOpen])-- return (- <PortalToFollowElem- open={open}- onOpenChange={setOpen}- placement='bottom-start'- offset={4}- >- <PortalToFollowElemTrigger onClick={togglePopup}>- <div className={cn('flex items-center h-6 px-1 rounded-md hover:bg-state-base-hover select-none', open && 'bg-state-base-hover', className)}>- <FileIcon name={name} extension={extension} size='md' />- <div className='flex flex-col items-start ml-1'>- <div className='flex items-center space-x-0.5'>- <span className={cn('system-md-semibold max-w-[200px] truncate text-text-primary')}> {name || '--'}</span>- <ArrowIcon className={'h-[18px] w-[18px] text-text-primary'} />- </div>- </div>- </div>- </PortalToFollowElemTrigger>- <PortalToFollowElemContent className='z-[11]'>- <div className='w-[392px] p-1 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]'>- {files?.length > 1 && <div className='pl-2 flex items-center h-8 system-xs-medium-uppercase text-text-tertiary'>{t('dataset.preprocessDocument', { num: files.length })}</div>}- {files?.length > 0- ? (- <DocumentList- list={files}- onChange={handleChange}- />- )- : (<div className='mt-2 flex items-center justify-center w-[360px] h-[100px]'>- <Loading />- </div>)}- </div>-- </PortalToFollowElemContent>- </PortalToFollowElem>- )-}-export default React.memo(PreviewDocumentPicker)diff --git a/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx b/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsxdeleted file mode 100644index b687c004e5c..00000000000--- a/web/app/components/datasets/common/document-status-with-action/auto-disabled-document.tsx+++ /dev/null@@ -1,38 +0,0 @@-'use client'-import type { FC } from 'react'-import React, { useCallback } from 'react'-import { useTranslation } from 'react-i18next'-import StatusWithAction from './status-with-action'-import { useAutoDisabledDocuments, useDocumentEnable, useInvalidDisabledDocument } from '@/service/knowledge/use-document'-import Toast from '@/app/components/base/toast'-type Props = {- datasetId: string-}--const AutoDisabledDocument: FC<Props> = ({- datasetId,-}) => {- const { t } = useTranslation()- const { data, isLoading } = useAutoDisabledDocuments(datasetId)- const invalidDisabledDocument = useInvalidDisabledDocument()- const documentIds = data?.document_ids- const hasDisabledDocument = documentIds && documentIds.length > 0- const { mutateAsync: enableDocument } = useDocumentEnable()- const handleEnableDocuments = useCallback(async () => {- await enableDocument({ datasetId, documentIds })- invalidDisabledDocument()- Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- }, [])- if (!hasDisabledDocument || isLoading)- return null-- return (- <StatusWithAction- type='info'- description={t('dataset.documentsDisabled', { num: documentIds?.length })}- actionText={t('dataset.enable')}- onAction={handleEnableDocuments}- />- )-}-export default React.memo(AutoDisabledDocument)diff --git a/web/app/components/datasets/common/document-status-with-action/index-failed.tsx b/web/app/components/datasets/common/document-status-with-action/index-failed.tsxdeleted file mode 100644index 37311768b95..00000000000--- a/web/app/components/datasets/common/document-status-with-action/index-failed.tsx+++ /dev/null@@ -1,69 +0,0 @@-'use client'-import type { FC } from 'react'-import React, { useEffect, useReducer } from 'react'-import { useTranslation } from 'react-i18next'-import useSWR from 'swr'-import StatusWithAction from './status-with-action'-import { getErrorDocs, retryErrorDocs } from '@/service/datasets'-import type { IndexingStatusResponse } from '@/models/datasets'--type Props = {- datasetId: string-}-type IIndexState = {- value: string-}-type ActionType = 'retry' | 'success' | 'error'--type IAction = {- type: ActionType-}-const indexStateReducer = (state: IIndexState, action: IAction) => {- const actionMap = {- retry: 'retry',- success: 'success',- error: 'error',- }-- return {- ...state,- value: actionMap[action.type] || state.value,- }-}--const RetryButton: FC<Props> = ({ datasetId }) => {- const { t } = useTranslation()- const [indexState, dispatch] = useReducer(indexStateReducer, { value: 'success' })- const { data: errorDocs, isLoading } = useSWR({ datasetId }, getErrorDocs)-- const onRetryErrorDocs = async () => {- dispatch({ type: 'retry' })- const document_ids = errorDocs?.data.map((doc: IndexingStatusResponse) => doc.id) || []- const res = await retryErrorDocs({ datasetId, document_ids })- if (res.result === 'success')- dispatch({ type: 'success' })- else- dispatch({ type: 'error' })- }-- useEffect(() => {- if (errorDocs?.total === 0)- dispatch({ type: 'success' })- else- dispatch({ type: 'error' })- }, [errorDocs?.total])-- if (isLoading || indexState.value === 'success')- return null-- return (- <StatusWithAction- type='warning'- description={`${errorDocs?.total} ${t('dataset.docsFailedNotice')}`}- actionText={t('dataset.retry')}- disabled={indexState.value === 'retry'}- onAction={indexState.value === 'error' ? onRetryErrorDocs : () => { }}- />- )-}-export default RetryButtondiff --git a/web/app/components/datasets/common/document-status-with-action/status-with-action.tsx b/web/app/components/datasets/common/document-status-with-action/status-with-action.tsxdeleted file mode 100644index a8da9bf6cc2..00000000000--- a/web/app/components/datasets/common/document-status-with-action/status-with-action.tsx+++ /dev/null@@ -1,65 +0,0 @@-'use client'-import { RiAlertFill, RiCheckboxCircleFill, RiErrorWarningFill, RiInformation2Fill } from '@remixicon/react'-import type { FC } from 'react'-import React from 'react'-import cn from '@/utils/classnames'-import Divider from '@/app/components/base/divider'--type Status = 'success' | 'error' | 'warning' | 'info'-type Props = {- type?: Status- description: string- actionText: string- onAction: () => void- disabled?: boolean-}--const IconMap = {- success: {- Icon: RiCheckboxCircleFill,- color: 'text-text-success',- },- error: {- Icon: RiErrorWarningFill,- color: 'text-text-destructive',- },- warning: {- Icon: RiAlertFill,- color: 'text-text-warning-secondary',- },- info: {- Icon: RiInformation2Fill,- color: 'text-text-accent',- },-}--const getIcon = (type: Status) => {- return IconMap[type]-}--const StatusAction: FC<Props> = ({- type = 'info',- description,- actionText,- onAction,- disabled,-}) => {- const { Icon, color } = getIcon(type)- return (- <div className='relative flex items-center h-[34px] rounded-lg pl-2 pr-3 border border-components-panel-border bg-components-panel-bg-blur shadow-xs'>- <div className={`absolute inset-0 opacity-40 rounded-lg ${(type === 'success' && 'bg-[linear-gradient(92deg,rgba(23,178,106,0.25)_0%,rgba(255,255,255,0.00)_100%)]')- || (type === 'warning' && 'bg-[linear-gradient(92deg,rgba(247,144,9,0.25)_0%,rgba(255,255,255,0.00)_100%)]')- || (type === 'error' && 'bg-[linear-gradient(92deg,rgba(240,68,56,0.25)_0%,rgba(255,255,255,0.00)_100%)]')- || (type === 'info' && 'bg-[linear-gradient(92deg,rgba(11,165,236,0.25)_0%,rgba(255,255,255,0.00)_100%)]')- }`}- />- <div className='relative z-10 flex h-full items-center space-x-2'>- <Icon className={cn('w-4 h-4', color)} />- <div className='text-[13px] font-normal text-text-secondary'>{description}</div>- <Divider type='vertical' className='!h-4' />- <div onClick={onAction} className={cn('text-text-accent font-semibold text-[13px] cursor-pointer', disabled && 'text-text-disabled cursor-not-allowed')}>{actionText}</div>- </div>- </div>- )-}-export default React.memo(StatusAction)diff --git a/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx b/web/app/components/datasets/common/economical-retrieval-method-config/index.tsxindex 9236858ae4c..f3da67b92cc 100644--- a/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx+++ b/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx@@ -2,11 +2,10 @@import type { FC } from 'react'import React from 'react'import { useTranslation } from 'react-i18next'-import Image from 'next/image'import RetrievalParamConfig from '../retrieval-param-config'-import { OptionCard } from '../../create/step-two/option-card'-import { retrievalIcon } from '../../create/icons'import { RETRIEVE_METHOD } from '@/types/app'+import RadioCard from '@/app/components/base/radio-card'+import { HighPriority } from '@/app/components/base/icons/src/vender/solid/arrows'import type { RetrievalConfig } from '@/types/app'type Props = {@@ -22,17 +21,19 @@ const EconomicalRetrievalMethodConfig: FC<Props> = ({return (<div className='space-y-2'>- <OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.vector} alt='' />}+ <RadioCard+ icon={<HighPriority className='w-4 h-4 text-[#7839EE]' />}title={t('dataset.retrieval.invertedIndex.title')}- description={t('dataset.retrieval.invertedIndex.description')} isActive- activeHeaderClassName='bg-dataset-option-card-purple-gradient'- >- <RetrievalParamConfig- type={RETRIEVE_METHOD.invertedIndex}- value={value}- onChange={onChange}- />- </OptionCard>+ description={t('dataset.retrieval.invertedIndex.description')}+ noRadio+ chosenConfig={+ <RetrievalParamConfig+ type={RETRIEVE_METHOD.invertedIndex}+ value={value}+ onChange={onChange}+ />+ }+ /></div>)}diff --git a/web/app/components/datasets/common/retrieval-method-config/index.tsx b/web/app/components/datasets/common/retrieval-method-config/index.tsxindex 9ab157571b5..20d93568add 100644--- a/web/app/components/datasets/common/retrieval-method-config/index.tsx+++ b/web/app/components/datasets/common/retrieval-method-config/index.tsx@@ -2,13 +2,12 @@import type { FC } from 'react'import React from 'react'import { useTranslation } from 'react-i18next'-import Image from 'next/image'import RetrievalParamConfig from '../retrieval-param-config'-import { OptionCard } from '../../create/step-two/option-card'-import Effect from '../../create/assets/option-card-effect-purple.svg'-import { retrievalIcon } from '../../create/icons'import type { RetrievalConfig } from '@/types/app'import { RETRIEVE_METHOD } from '@/types/app'+import RadioCard from '@/app/components/base/radio-card'+import { PatternRecognition, Semantic } from '@/app/components/base/icons/src/vender/solid/development'+import { FileSearch02 } from '@/app/components/base/icons/src/vender/solid/files'import { useProviderContext } from '@/context/provider-context'import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'@@ -17,7 +16,6 @@ import {RerankingModeEnum,WeightedScoreEnum,} from '@/models/datasets'-import Badge from '@/app/components/base/badge'type Props = {value: RetrievalConfig@@ -58,72 +56,67 @@ const RetrievalMethodConfig: FC<Props> = ({return (<div className='space-y-2'>{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (- <OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.vector} alt='' />}+ <RadioCard+ icon={<Semantic className='w-4 h-4 text-[#7839EE]' />}title={t('dataset.retrieval.semantic_search.title')}description={t('dataset.retrieval.semantic_search.description')}- isActive={- value.search_method === RETRIEVE_METHOD.semantic- }- onSwitched={() => onChange({+ isChosen={value.search_method === RETRIEVE_METHOD.semantic}+ onChosen={() => onChange({...value,search_method: RETRIEVE_METHOD.semantic,})}- effectImg={Effect.src}- activeHeaderClassName='bg-dataset-option-card-purple-gradient'- >- <RetrievalParamConfig- type={RETRIEVE_METHOD.semantic}- value={value}- onChange={onChange}- />- </OptionCard>+ chosenConfig={+ <RetrievalParamConfig+ type={RETRIEVE_METHOD.semantic}+ value={value}+ onChange={onChange}+ />+ }+ />)}{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (- <OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.fullText} alt='' />}+ <RadioCard+ icon={<FileSearch02 className='w-4 h-4 text-[#7839EE]' />}title={t('dataset.retrieval.full_text_search.title')}description={t('dataset.retrieval.full_text_search.description')}- isActive={- value.search_method === RETRIEVE_METHOD.fullText- }- onSwitched={() => onChange({+ isChosen={value.search_method === RETRIEVE_METHOD.fullText}+ onChosen={() => onChange({...value,search_method: RETRIEVE_METHOD.fullText,})}- effectImg={Effect.src}- activeHeaderClassName='bg-dataset-option-card-purple-gradient'- >- <RetrievalParamConfig- type={RETRIEVE_METHOD.fullText}- value={value}- onChange={onChange}- />- </OptionCard>+ chosenConfig={+ <RetrievalParamConfig+ type={RETRIEVE_METHOD.fullText}+ value={value}+ onChange={onChange}+ />+ }+ />)}{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && (- <OptionCard icon={<Image className='w-4 h-4' src={retrievalIcon.hybrid} alt='' />}+ <RadioCard+ icon={<PatternRecognition className='w-4 h-4 text-[#7839EE]' />}title={<div className='flex items-center space-x-1'><div>{t('dataset.retrieval.hybrid_search.title')}</div>- <Badge text={t('dataset.retrieval.hybrid_search.recommend')!} className='border-text-accent-secondary text-text-accent-secondary ml-1 h-[18px]' uppercase />+ <div className='flex h-full items-center px-1.5 rounded-md border border-[#E0EAFF] text-xs font-medium text-[#444CE7]'>{t('dataset.retrieval.hybrid_search.recommend')}</div></div>}- description={t('dataset.retrieval.hybrid_search.description')} isActive={- value.search_method === RETRIEVE_METHOD.hybrid- }- onSwitched={() => onChange({+ description={t('dataset.retrieval.hybrid_search.description')}+ isChosen={value.search_method === RETRIEVE_METHOD.hybrid}+ onChosen={() => onChange({...value,search_method: RETRIEVE_METHOD.hybrid,reranking_enable: true,})}- effectImg={Effect.src}- activeHeaderClassName='bg-dataset-option-card-purple-gradient'- >- <RetrievalParamConfig- type={RETRIEVE_METHOD.hybrid}- value={value}- onChange={onChange}- />- </OptionCard>+ chosenConfig={+ <RetrievalParamConfig+ type={RETRIEVE_METHOD.hybrid}+ value={value}+ onChange={onChange}+ />+ }+ />)}</div>)diff --git a/web/app/components/datasets/common/retrieval-method-info/index.tsx b/web/app/components/datasets/common/retrieval-method-info/index.tsxindex fc3020d4a96..7d9b999c539 100644--- a/web/app/components/datasets/common/retrieval-method-info/index.tsx+++ b/web/app/components/datasets/common/retrieval-method-info/index.tsx@@ -2,11 +2,12 @@import type { FC } from 'react'import React from 'react'import { useTranslation } from 'react-i18next'-import Image from 'next/image'-import { retrievalIcon } from '../../create/icons'import type { RetrievalConfig } from '@/types/app'import { RETRIEVE_METHOD } from '@/types/app'import RadioCard from '@/app/components/base/radio-card'+import { HighPriority } from '@/app/components/base/icons/src/vender/solid/arrows'+import { PatternRecognition, Semantic } from '@/app/components/base/icons/src/vender/solid/development'+import { FileSearch02 } from '@/app/components/base/icons/src/vender/solid/files'type Props = {value: RetrievalConfig@@ -14,12 +15,11 @@ type Props = {export const getIcon = (type: RETRIEVE_METHOD) => {return ({- [RETRIEVE_METHOD.semantic]: retrievalIcon.vector,- [RETRIEVE_METHOD.fullText]: retrievalIcon.fullText,- [RETRIEVE_METHOD.hybrid]: retrievalIcon.hybrid,- [RETRIEVE_METHOD.invertedIndex]: retrievalIcon.vector,- [RETRIEVE_METHOD.keywordSearch]: retrievalIcon.vector,- })[type] || retrievalIcon.vector+ [RETRIEVE_METHOD.semantic]: Semantic,+ [RETRIEVE_METHOD.fullText]: FileSearch02,+ [RETRIEVE_METHOD.hybrid]: PatternRecognition,+ [RETRIEVE_METHOD.invertedIndex]: HighPriority,+ })[type] || FileSearch02}const EconomicalRetrievalMethodConfig: FC<Props> = ({@@ -28,11 +28,11 @@ const EconomicalRetrievalMethodConfig: FC<Props> = ({}) => {const { t } = useTranslation()const type = value.search_method- const icon = <Image className='size-3.5 text-util-colors-purple-purple-600' src={getIcon(type)} alt='' />+ const Icon = getIcon(type)return (<div className='space-y-2'><RadioCard- icon={icon}+ icon={<Icon className='w-4 h-4 text-[#7839EE]' />}title={t(`dataset.retrieval.${type}.title`)}description={t(`dataset.retrieval.${type}.description`)}noRadiodiff --git a/web/app/components/datasets/common/retrieval-param-config/index.tsx b/web/app/components/datasets/common/retrieval-param-config/index.tsxindex 5136ac16591..9d48d56a8dc 100644--- a/web/app/components/datasets/common/retrieval-param-config/index.tsx+++ b/web/app/components/datasets/common/retrieval-param-config/index.tsx@@ -3,9 +3,6 @@ import type { FC } from 'react'import React, { useCallback } from 'react'import { useTranslation } from 'react-i18next'-import Image from 'next/image'-import ProgressIndicator from '../../create/assets/progress-indicator.svg'-import Reranking from '../../create/assets/rerank.svg'import cn from '@/utils/classnames'import TopKItem from '@/app/components/base/param-item/top-k-item'import ScoreThresholdItem from '@/app/components/base/param-item/score-threshold-item'@@ -23,7 +20,6 @@ import {} from '@/models/datasets'import WeightedScore from '@/app/components/app/configuration/dataset-config/params-config/weighted-score'import Toast from '@/app/components/base/toast'-import RadioCard from '@/app/components/base/radio-card'type Props = {type: RETRIEVE_METHOD@@ -120,7 +116,7 @@ const RetrievalParamConfig: FC<Props> = ({<div>{!isEconomical && !isHybridSearch && (<div>- <div className='flex items-center space-x-2 mb-2'>+ <div className='flex h-8 items-center text-[13px] font-medium text-gray-900 space-x-2'>{canToggleRerankModalEnable && (<divclassName='flex items-center'@@ -140,7 +136,7 @@ const RetrievalParamConfig: FC<Props> = ({</div>)}<div className='flex items-center'>- <span className='mr-0.5 system-sm-semibold text-text-secondary'>{t('common.modelProvider.rerankModel.key')}</span>+ <span className='mr-0.5'>{t('common.modelProvider.rerankModel.key')}</span><TooltippopupContent={<div className="w-[200px]">{t('common.modelProvider.rerankModel.tip')}</div>@@ -167,7 +163,7 @@ const RetrievalParamConfig: FC<Props> = ({)}{!isHybridSearch && (- <div className={cn(!isEconomical && 'mt-4', 'flex space-between space-x-4')}>+ <div className={cn(!isEconomical && 'mt-4', 'flex space-between space-x-6')}><TopKItemclassName='grow'value={value.top_k}@@ -205,22 +201,24 @@ const RetrievalParamConfig: FC<Props> = ({{isHybridSearch && (<>- <div className='flex gap-2 mb-4'>+ <div className='flex items-center justify-between'>{rerankingModeOptions.map(option => (- <RadioCard+ <divkey={option.value}- isChosen={value.reranking_mode === option.value}- onChosen={() => handleChangeRerankMode(option.value)}- icon={<Image src={- option.value === RerankingModeEnum.WeightedScore- ? ProgressIndicator- : Reranking- } alt=''/>}- title={option.label}- description={option.tips}- className='flex-1'- />+ className={cn(+ 'flex items-center justify-center mb-4 w-[calc((100%-8px)/2)] h-8 rounded-lg border border-components-option-card-option-border bg-components-option-card-option-bg cursor-pointer system-sm-medium text-text-secondary',+ value.reranking_mode === RerankingModeEnum.WeightedScore && option.value === RerankingModeEnum.WeightedScore && 'border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg text-text-primary',+ value.reranking_mode !== RerankingModeEnum.WeightedScore && option.value !== RerankingModeEnum.WeightedScore && 'border-[1.5px] border-components-option-card-option-selected-border bg-components-option-card-option-selected-bg text-text-primary',+ )}+ onClick={() => handleChangeRerankMode(option.value)}+ >+ <div className='truncate'>{option.label}</div>+ <Tooltip+ popupContent={<div className='w-[200px]'>{option.tips}</div>}+ triggerClassName='ml-0.5 w-3.5 h-3.5'+ />+ </div>))}</div>diff --git a/web/app/components/datasets/create/assets/family-mod.svg b/web/app/components/datasets/create/assets/family-mod.svgdeleted file mode 100644index b1c4e6f566e..00000000000--- a/web/app/components/datasets/create/assets/family-mod.svg+++ /dev/null@@ -1,6 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M6.18055 6.45828C7.52291 6.45828 8.61111 5.37008 8.61111 4.02772C8.61111 2.68536 7.52291 1.59717 6.18055 1.59717C4.8382 1.59717 3.75 2.68536 3.75 4.02772C3.75 5.37008 4.8382 6.45828 6.18055 6.45828Z" fill="#EF6820"/>- <path d="M13.8192 6.45828C15.1616 6.45828 16.2498 5.37008 16.2498 4.02772C16.2498 2.68536 15.1616 1.59717 13.8192 1.59717C12.4769 1.59717 11.3887 2.68536 11.3887 4.02772C11.3887 5.37008 12.4769 6.45828 13.8192 6.45828Z" fill="#EF6820"/>- <path d="M13.8193 7.84719C13.0627 7.84805 12.3185 8.03933 11.6552 8.40341C10.992 8.7675 10.4311 9.29267 10.0241 9.93053C10.5745 9.93695 11.1 10.1609 11.4858 10.5535C11.8716 10.9461 12.0864 11.4755 12.0831 12.0259C12.0799 12.5763 11.859 13.1031 11.4687 13.4911C11.0783 13.8792 10.5503 14.097 9.99984 14.097C9.44942 14.097 8.92135 13.8792 8.53101 13.4911C8.14066 13.1031 7.91976 12.5763 7.91655 12.0259C7.91334 11.4755 8.12808 10.9461 8.51387 10.5535C8.89966 10.1609 9.42515 9.93695 9.97554 9.93053C9.45127 9.10686 8.67371 8.47572 7.75983 8.13205C6.84596 7.78839 5.84519 7.75078 4.9081 8.0249C3.97101 8.29902 3.14828 8.87003 2.56368 9.65203C1.97908 10.434 1.66424 11.3847 1.66652 12.3611V16.875C1.66652 17.0591 1.73968 17.2358 1.86991 17.366C2.00015 17.4962 2.17678 17.5694 2.36096 17.5694H7.22207V15.8333L4.72207 13.9583C4.64911 13.9036 4.58765 13.835 4.54118 13.7566C4.49472 13.6781 4.46417 13.5912 4.45127 13.501C4.42522 13.3186 4.47267 13.1334 4.58318 12.9861C4.69369 12.8387 4.8582 12.7413 5.04053 12.7153C5.22285 12.6892 5.40806 12.7367 5.5554 12.8472L8.14776 14.7916H11.8519L14.4443 12.8472C14.5916 12.7367 14.7768 12.6892 14.9592 12.7153C15.1415 12.7413 15.306 12.8387 15.4165 12.9861C15.527 13.1334 15.5745 13.3186 15.5484 13.501C15.5224 13.6833 15.425 13.8478 15.2776 13.9583L12.7776 15.8333V17.5694H17.6387C17.8229 17.5694 17.9995 17.4962 18.1298 17.366C18.26 17.2358 18.3332 17.0591 18.3332 16.875V12.3611C18.3317 11.1644 17.8557 10.0171 17.0095 9.17091C16.1633 8.32471 15.016 7.84867 13.8193 7.84719Z" fill="#EF6820"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/file-list-3-fill.svg b/web/app/components/datasets/create/assets/file-list-3-fill.svgdeleted file mode 100644index a4e6c4da978..00000000000--- a/web/app/components/datasets/create/assets/file-list-3-fill.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="file-list-3-fill">-<path id="Vector" d="M15.8332 18.3333H4.1665C2.7858 18.3333 1.6665 17.2141 1.6665 15.8333V2.50001C1.6665 2.03977 2.0396 1.66667 2.49984 1.66667H14.1665C14.6268 1.66667 14.9998 2.03977 14.9998 2.50001V12.5H18.3332V15.8333C18.3332 17.2141 17.2139 18.3333 15.8332 18.3333ZM14.9998 14.1667V15.8333C14.9998 16.2936 15.3729 16.6667 15.8332 16.6667C16.2934 16.6667 16.6665 16.2936 16.6665 15.8333V14.1667H14.9998ZM4.99984 5.83334V7.50001H11.6665V5.83334H4.99984ZM4.99984 9.16667V10.8333H11.6665V9.16667H4.99984ZM4.99984 12.5V14.1667H9.1665V12.5H4.99984Z" fill="#1570EF"/>-</g>-</svg>diff --git a/web/app/components/datasets/create/assets/gold.svg b/web/app/components/datasets/create/assets/gold.svgdeleted file mode 100644index b48ac0eae5d..00000000000--- a/web/app/components/datasets/create/assets/gold.svg+++ /dev/null@@ -1,4 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M9.99984 1.66663C8.35166 1.66663 6.7405 2.15537 5.37009 3.07105C3.99968 3.98672 2.93157 5.28821 2.30084 6.81093C1.67011 8.33365 1.50509 10.0092 1.82663 11.6257C2.14817 13.2422 2.94185 14.7271 4.10728 15.8925C5.27272 17.058 6.75758 17.8516 8.37409 18.1732C9.9906 18.4947 11.6662 18.3297 13.1889 17.699C14.7116 17.0682 16.0131 16.0001 16.9288 14.6297C17.8444 13.2593 18.3332 11.6481 18.3332 9.99996C18.3332 7.78982 17.4552 5.67021 15.8924 4.1074C14.3296 2.5446 12.21 1.66663 9.99984 1.66663ZM12.295 5.65899L13.1116 4.53538C13.1653 4.46155 13.2329 4.39901 13.3107 4.35133C13.3885 4.30365 13.4749 4.27175 13.565 4.25747C13.6551 4.24319 13.7472 4.24679 13.8359 4.26809C13.9246 4.28938 14.0083 4.32793 14.0821 4.38156C14.156 4.43518 14.2185 4.50282 14.2662 4.58061C14.3139 4.6584 14.3458 4.74482 14.36 4.83494C14.3743 4.92506 14.3707 5.01711 14.3494 5.10583C14.3281 5.19456 14.2896 5.27822 14.236 5.35204L13.4193 6.47565C13.311 6.62474 13.1479 6.72471 12.9659 6.75356C12.7839 6.7824 12.5979 6.73777 12.4488 6.62947C12.2997 6.52118 12.1997 6.35809 12.1709 6.17609C12.142 5.99408 12.1867 5.80808 12.295 5.65899ZM5.9179 4.3819C5.99174 4.32795 6.07551 4.28911 6.1644 4.26761C6.25329 4.24612 6.34556 4.2424 6.43589 4.25666C6.52623 4.27092 6.61286 4.30288 6.69081 4.35071C6.76875 4.39854 6.83649 4.4613 6.89012 4.53538L7.70817 5.65899C7.81647 5.80854 7.86092 5.99499 7.83175 6.17731C7.80258 6.35964 7.70217 6.52291 7.55262 6.63121C7.40307 6.73951 7.21662 6.78396 7.03429 6.75478C6.85196 6.72561 6.68869 6.62521 6.5804 6.47565L5.76373 5.35204C5.71013 5.27823 5.6716 5.19457 5.65034 5.10586C5.62908 5.01715 5.62551 4.92512 5.63983 4.83503C5.65414 4.74494 5.68607 4.65855 5.73378 4.5808C5.78149 4.50306 5.84406 4.43547 5.9179 4.3819ZM5.59151 12.1597L4.27206 12.5888C4.18433 12.6215 4.0909 12.6361 3.99739 12.6317C3.90388 12.6273 3.81222 12.6041 3.72791 12.5634C3.64361 12.5227 3.56841 12.4654 3.50682 12.3949C3.44524 12.3244 3.39854 12.2421 3.36954 12.1531C3.34055 12.0641 3.32984 11.9702 3.33808 11.8769C3.34631 11.7837 3.37332 11.693 3.41747 11.6105C3.46162 11.528 3.522 11.4552 3.59499 11.3966C3.66798 11.3379 3.75207 11.2947 3.8422 11.2694L5.16165 10.8402C5.24947 10.8072 5.34308 10.7924 5.43681 10.7965C5.53054 10.8007 5.62245 10.8238 5.707 10.8645C5.79154 10.9052 5.86697 10.9626 5.92872 11.0332C5.99047 11.1039 6.03727 11.1863 6.06629 11.2755C6.09531 11.3647 6.10595 11.4589 6.09757 11.5524C6.08919 11.6458 6.06195 11.7366 6.01752 11.8192C5.97308 11.9018 5.91236 11.9746 5.83902 12.0331C5.76568 12.0916 5.68194 12.1347 5.59151 12.1597ZM10.6943 16.25C10.6943 16.4341 10.6211 16.6108 10.4909 16.741C10.3607 16.8712 10.184 16.9444 9.99984 16.9444C9.81566 16.9444 9.63903 16.8712 9.50879 16.741C9.37856 16.6108 9.3054 16.4341 9.3054 16.25V14.8611C9.3054 14.6769 9.37856 14.5003 9.50879 14.37C9.63903 14.2398 9.81566 14.1666 9.99984 14.1666C10.184 14.1666 10.3607 14.2398 10.4909 14.37C10.6211 14.5003 10.6943 14.6769 10.6943 14.8611V16.25ZM9.99984 12.2222L7.38595 13.5972L7.88526 10.6868L5.77067 8.62565L8.6929 8.20135L9.99984 5.55551L11.3068 8.20135L14.229 8.62565L12.1144 10.6868L12.6137 13.5972L9.99984 12.2222ZM15.729 12.5902L14.4096 12.1611C14.3191 12.1361 14.2347 12.093 14.1614 12.0345C14.088 11.976 14.0273 11.9032 13.9829 11.8206C13.9384 11.738 13.9112 11.6472 13.9028 11.5537C13.8944 11.4603 13.9051 11.3661 13.9341 11.2769C13.9631 11.1877 14.0099 11.1053 14.0717 11.0346C14.1334 10.964 14.2088 10.9066 14.2934 10.8659C14.3779 10.8252 14.4698 10.8021 14.5636 10.7979C14.6573 10.7938 14.7509 10.8086 14.8387 10.8416L16.1582 11.2708C16.2483 11.2961 16.3324 11.3393 16.4054 11.398C16.4784 11.4566 16.5388 11.5293 16.5829 11.6119C16.6271 11.6944 16.6541 11.7851 16.6623 11.8783C16.6705 11.9716 16.6598 12.0655 16.6308 12.1545C16.6018 12.2435 16.5551 12.3258 16.4936 12.3963C16.432 12.4668 16.3568 12.5241 16.2725 12.5648C16.1882 12.6055 16.0965 12.6287 16.003 12.6331C15.9095 12.6375 15.8167 12.6229 15.729 12.5902Z" fill="#EF6820"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/note-mod.svg b/web/app/components/datasets/create/assets/note-mod.svgdeleted file mode 100644index b9e81f6bd53..00000000000--- a/web/app/components/datasets/create/assets/note-mod.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="note-mod">-<path id="Vector" d="M17.6387 3.05555H2.36095C1.97762 3.05555 1.6665 3.36666 1.6665 3.74999V16.25C1.6665 16.6333 1.97762 16.9444 2.36095 16.9444H17.6387C18.0221 16.9444 18.3332 16.6333 18.3332 16.25V3.74999C18.3332 3.36666 18.0221 3.05555 17.6387 3.05555ZM9.30539 14.1667H5.13873C4.75539 14.1667 4.44428 13.8555 4.44428 13.4722C4.44428 13.0889 4.75539 12.7778 5.13873 12.7778H9.30539C9.68873 12.7778 9.99984 13.0889 9.99984 13.4722C9.99984 13.8555 9.68873 14.1667 9.30539 14.1667ZM14.8609 10.6944H5.13873C4.75539 10.6944 4.44428 10.3833 4.44428 9.99999C4.44428 9.61666 4.75539 9.30555 5.13873 9.30555H14.8609C15.2443 9.30555 15.5554 9.61666 15.5554 9.99999C15.5554 10.3833 15.2443 10.6944 14.8609 10.6944ZM14.8609 7.22221H5.13873C4.75539 7.22221 4.44428 6.9111 4.44428 6.52777C4.44428 6.14443 4.75539 5.83332 5.13873 5.83332H14.8609C15.2443 5.83332 15.5554 6.14443 15.5554 6.52777C15.5554 6.9111 15.2443 7.22221 14.8609 7.22221Z" fill="#1570EF"/>-</g>-</svg>diff --git a/web/app/components/datasets/create/assets/option-card-effect-blue.svg b/web/app/components/datasets/create/assets/option-card-effect-blue.svgdeleted file mode 100644index 00a8afad8b1..00000000000--- a/web/app/components/datasets/create/assets/option-card-effect-blue.svg+++ /dev/null@@ -1,12 +0,0 @@-<svg width="220" height="220" viewBox="0 0 220 220" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Effect" opacity="0.8" filter="url(#filter0_f_1328_28605)">-<circle cx="32" cy="32" r="28" fill="#444CE7"/>-</g>-<defs>-<filter id="filter0_f_1328_28605" x="-156" y="-156" width="376" height="376" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">-<feFlood flood-opacity="0" result="BackgroundImageFix"/>-<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>-<feGaussianBlur stdDeviation="80" result="effect1_foregroundBlur_1328_28605"/>-</filter>-</defs>-</svg>diff --git a/web/app/components/datasets/create/assets/option-card-effect-orange.svg b/web/app/components/datasets/create/assets/option-card-effect-orange.svgdeleted file mode 100644index d833764f0cb..00000000000--- a/web/app/components/datasets/create/assets/option-card-effect-orange.svg+++ /dev/null@@ -1,12 +0,0 @@-<svg width="220" height="220" viewBox="0 0 220 220" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Effect" opacity="0.8" filter="url(#filter0_f_481_16338)">-<circle cx="32" cy="32" r="28" fill="#EF6820"/>-</g>-<defs>-<filter id="filter0_f_481_16338" x="-156" y="-156" width="376" height="376" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">-<feFlood flood-opacity="0" result="BackgroundImageFix"/>-<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>-<feGaussianBlur stdDeviation="80" result="effect1_foregroundBlur_481_16338"/>-</filter>-</defs>-</svg>diff --git a/web/app/components/datasets/create/assets/option-card-effect-purple.svg b/web/app/components/datasets/create/assets/option-card-effect-purple.svgdeleted file mode 100644index a7857f8e570..00000000000--- a/web/app/components/datasets/create/assets/option-card-effect-purple.svg+++ /dev/null@@ -1,12 +0,0 @@-<svg width="220" height="220" viewBox="0 0 220 220" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="Effect" opacity="0.8" filter="url(#filter0_f_481_16453)">-<circle cx="32" cy="32" r="28" fill="#6938EF"/>-</g>-<defs>-<filter id="filter0_f_481_16453" x="-156" y="-156" width="376" height="376" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">-<feFlood flood-opacity="0" result="BackgroundImageFix"/>-<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>-<feGaussianBlur stdDeviation="80" result="effect1_foregroundBlur_481_16453"/>-</filter>-</defs>-</svg>diff --git a/web/app/components/datasets/create/assets/pattern-recognition-mod.svg b/web/app/components/datasets/create/assets/pattern-recognition-mod.svgdeleted file mode 100644index 1083e888ed6..00000000000--- a/web/app/components/datasets/create/assets/pattern-recognition-mod.svg+++ /dev/null@@ -1,12 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M3.93923 18.3333C3.48973 18.3333 3.05032 18.2 2.67657 17.9503C2.30282 17.7006 2.01152 17.3456 1.83951 16.9303C1.66749 16.515 1.62248 16.0581 1.71017 15.6172C1.79787 15.1763 2.01432 14.7714 2.33217 14.4535C2.65002 14.1357 3.05498 13.9192 3.49584 13.8315C3.93671 13.7438 4.39368 13.7889 4.80897 13.9609C5.22425 14.1329 5.5792 14.4242 5.82894 14.7979C6.07867 15.1717 6.21196 15.6111 6.21196 16.0606C6.21196 16.6634 5.97251 17.2414 5.54629 17.6677C5.12007 18.0939 4.542 18.3333 3.93923 18.3333Z" fill="#6938EF"/>- <path d="M9.99978 7.72726C9.55028 7.72726 9.11087 7.86056 8.73712 8.11029C8.36337 8.36002 8.07207 8.71497 7.90005 9.13026C7.72804 9.54554 7.68303 10.0025 7.77072 10.4434C7.85842 10.8842 8.07487 11.2892 8.39272 11.6071C8.71056 11.9249 9.11553 12.1414 9.55639 12.229C9.99726 12.3167 10.4542 12.2717 10.8695 12.0997C11.2848 11.9277 11.6398 11.6364 11.8895 11.2627C12.1392 10.8889 12.2725 10.4495 12.2725 9.99999C12.2725 9.39723 12.0331 8.81915 11.6068 8.39293C11.1806 7.96671 10.6025 7.72726 9.99978 7.72726Z" fill="#6938EF"/>- <path d="M3.93923 1.66666C3.48973 1.66666 3.05032 1.79995 2.67657 2.04968C2.30282 2.29941 2.01152 2.65436 1.83951 3.06965C1.66749 3.48494 1.62248 3.9419 1.71017 4.38277C1.79787 4.82364 2.01432 5.2286 2.33217 5.54644C2.65002 5.86429 3.05498 6.08075 3.49585 6.16844C3.93671 6.25613 4.39368 6.21113 4.80897 6.03911C5.22425 5.86709 5.57921 5.57579 5.82894 5.20204C6.07867 4.8283 6.21196 4.38889 6.21196 3.93938C6.21196 3.33662 5.97251 2.75854 5.54629 2.33232C5.12007 1.9061 4.542 1.66666 3.93923 1.66666Z" fill="#6938EF"/>- <path d="M16.0603 1.66666C15.6108 1.66666 15.1714 1.79995 14.7977 2.04968C14.4239 2.29941 14.1326 2.65436 13.9606 3.06965C13.7886 3.48494 13.7436 3.9419 13.8313 4.38277C13.919 4.82364 14.1354 5.2286 14.4533 5.54644C14.7711 5.86429 15.1761 6.08075 15.6169 6.16844C16.0578 6.25613 16.5148 6.21113 16.9301 6.03911C17.3453 5.86709 17.7003 5.57579 17.95 5.20204C18.1998 4.8283 18.3331 4.38889 18.3331 3.93938C18.3331 3.33662 18.0936 2.75854 17.6674 2.33232C17.2412 1.9061 16.6631 1.66666 16.0603 1.66666Z" fill="#6938EF"/>- <path d="M16.0603 13.7879C15.6108 13.7879 15.1714 13.9212 14.7977 14.1709C14.4239 14.4206 14.1326 14.7756 13.9606 15.1909C13.7886 15.6062 13.7436 16.0631 13.8313 16.504C13.919 16.9449 14.1354 17.3498 14.4533 17.6677C14.7711 17.9855 15.1761 18.202 15.6169 18.2897C16.0578 18.3774 16.5148 18.3323 16.9301 18.1603C17.3453 17.9883 17.7003 17.697 17.95 17.3233C18.1998 16.9495 18.3331 16.5101 18.3331 16.0606C18.3331 15.4578 18.0936 14.8798 17.6674 14.4535C17.2412 14.0273 16.6631 13.7879 16.0603 13.7879Z" fill="#6938EF"/>- <path d="M6.21196 7.72726H1.6665V12.2727H6.21196V7.72726Z" fill="#6938EF"/>- <path d="M18.3331 7.72726H13.7876V12.2727H18.3331V7.72726Z" fill="#6938EF"/>- <path d="M12.2725 1.66666H7.72705V6.21211H12.2725V1.66666Z" fill="#6938EF"/>- <path d="M12.2725 13.7879H7.72705V18.3333H12.2725V13.7879Z" fill="#6938EF"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/piggy-bank-mod.svg b/web/app/components/datasets/create/assets/piggy-bank-mod.svgdeleted file mode 100644index b1120ad9a9c..00000000000--- a/web/app/components/datasets/create/assets/piggy-bank-mod.svg+++ /dev/null@@ -1,7 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path fill-rule="evenodd" clip-rule="evenodd" d="M7.91672 15.2028V17.9805H6.52783V15.2028H7.91672Z" fill="#444CE7"/>- <path fill-rule="evenodd" clip-rule="evenodd" d="M14.1667 15.2028V17.9805H12.7778V15.2028H14.1667Z" fill="#444CE7"/>- <path d="M14.1666 2.0083C14.1666 3.54243 12.923 4.78608 11.3889 4.78608C9.85476 4.78608 8.61108 3.54243 8.61108 2.0083L14.1666 2.0083Z" fill="#444CE7"/>- <path fill-rule="evenodd" clip-rule="evenodd" d="M5.8864 5.23918C6.9718 4.92907 8.12598 5.30791 8.81883 6.17498H13.1251C16.0015 6.17498 18.3334 8.50683 18.3334 11.3833C18.3334 14.2598 16.0015 16.5916 13.1251 16.5916H7.39252C6.14908 16.5916 4.97062 16.0363 4.1791 15.0773L3.32342 14.0407L1.66675 13.3448V9.93061L3.65692 9.40957L4.44453 8.40703V5.65114L5.8864 5.23918ZM8.61119 8.25831H14.1667V9.64721H8.61119V8.25831ZM6.52786 9.99443C6.52786 10.5697 6.06149 11.0361 5.48619 11.0361C4.91089 11.0361 4.44453 10.5697 4.44453 9.99443C4.44453 9.41915 4.91089 8.95276 5.48619 8.95276C6.06149 8.95276 6.52786 9.41915 6.52786 9.99443Z" fill="#444CE7"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/progress-indicator.svg b/web/app/components/datasets/create/assets/progress-indicator.svgdeleted file mode 100644index 3c997136360..00000000000--- a/web/app/components/datasets/create/assets/progress-indicator.svg+++ /dev/null@@ -1,8 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="progress-indicator">-<g id="Vector">-<path d="M18.4029 10.7639H1.59738C1.17572 10.7639 0.833496 11.1061 0.833496 11.5278V16.1111C0.833496 16.5328 1.17572 16.875 1.59738 16.875H18.4029C18.8246 16.875 19.1668 16.5328 19.1668 16.1111V11.5278C19.1668 11.1061 18.8246 10.7639 18.4029 10.7639ZM17.6391 15.3472H10.0002V12.2917H17.6391V15.3472Z" fill="#1570EF"/>-<path d="M9.716 7.58153C9.78933 7.66174 9.89169 7.70833 10.0002 7.70833C10.1086 7.70833 10.211 7.6625 10.2843 7.58153L13.7218 3.76208C13.8227 3.64979 13.8479 3.48937 13.7868 3.35111C13.7249 3.21361 13.5881 3.125 13.4377 3.125H6.56266C6.41218 3.125 6.27544 3.21361 6.21356 3.35111C6.15245 3.48937 6.17766 3.64979 6.2785 3.76208L9.716 7.58153Z" fill="#1570EF"/>-</g>-</g>-</svg>diff --git a/web/app/components/datasets/create/assets/rerank.svg b/web/app/components/datasets/create/assets/rerank.svgdeleted file mode 100644index 409b52e6e23..00000000000--- a/web/app/components/datasets/create/assets/rerank.svg+++ /dev/null@@ -1,13 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="rerank">-<g id="Vector">-<path d="M18.3333 4.58329C18.3333 5.73389 17.4005 6.66663 16.2499 6.66663C15.0993 6.66663 14.1666 5.73389 14.1666 4.58329C14.1666 3.4327 15.0993 2.49996 16.2499 2.49996C17.4005 2.49996 18.3333 3.4327 18.3333 4.58329Z" fill="#0E9384"/>-<path d="M13.3333 15.4166C13.3333 16.5672 12.4005 17.5 11.2499 17.5C10.0993 17.5 9.16658 16.5672 9.16658 15.4166C9.16658 14.266 10.0993 13.3333 11.2499 13.3333C12.4005 13.3333 13.3333 14.266 13.3333 15.4166Z" fill="#0E9384"/>-<path d="M12.0833 4.58329C12.0833 5.27365 11.5236 5.83329 10.8333 5.83329C10.1429 5.83329 9.58325 5.27365 9.58325 4.58329C9.58325 3.89294 10.1429 3.33329 10.8333 3.33329C11.5236 3.33329 12.0833 3.89294 12.0833 4.58329Z" fill="#0E9384"/>-<path d="M17.4999 15.4166C17.4999 16.107 16.9403 16.6666 16.2499 16.6666C15.5596 16.6666 14.9999 16.107 14.9999 15.4166C14.9999 14.7263 15.5596 14.1666 16.2499 14.1666C16.9403 14.1666 17.4999 14.7263 17.4999 15.4166Z" fill="#0E9384"/>-<path d="M7.49992 15.4166C7.49992 17.0275 6.19408 18.3333 4.58325 18.3333C2.97242 18.3333 1.66659 17.0275 1.66659 15.4166C1.66659 13.8058 2.97242 12.5 4.58325 12.5C6.19408 12.5 7.49992 13.8058 7.49992 15.4166Z" fill="#0E9384"/>-<path d="M7.49992 4.58329C7.49992 6.19412 6.19408 7.49996 4.58325 7.49996C2.97242 7.49996 1.66659 6.19412 1.66659 4.58329C1.66659 2.97246 2.97242 1.66663 4.58325 1.66663C6.19408 1.66663 7.49992 2.97246 7.49992 4.58329Z" fill="#0E9384"/>-<path d="M0.833252 9.99996C0.833252 9.53972 1.20635 9.16663 1.66659 9.16663H18.3333C18.7935 9.16663 19.1666 9.53972 19.1666 9.99996C19.1666 10.4602 18.7935 10.8333 18.3333 10.8333H1.66659C1.20635 10.8333 0.833252 10.4602 0.833252 9.99996Z" fill="#0E9384"/>-</g>-</g>-</svg>diff --git a/web/app/components/datasets/create/assets/research-mod.svg b/web/app/components/datasets/create/assets/research-mod.svgdeleted file mode 100644index 1f0bb342335..00000000000--- a/web/app/components/datasets/create/assets/research-mod.svg+++ /dev/null@@ -1,6 +0,0 @@-<svg width="16" height="18" viewBox="0 0 16 18" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M13.6752 4.83333H9.91553V1.07361L13.6752 4.83333Z" fill="#6938EF"/>- <path d="M7.2003 13.8611H2.62391C2.53183 13.8611 2.44351 13.8245 2.37839 13.7594C2.31327 13.6943 2.27669 13.606 2.27669 13.5139V12.8195C2.27669 12.7274 2.31327 12.6391 2.37839 12.5739C2.44351 12.5088 2.53183 12.4722 2.62391 12.4722H7.2003C7.33176 11.6964 7.68097 10.9739 8.20725 10.3889H2.62391C2.53183 10.3889 2.44351 10.3523 2.37839 10.2872C2.31327 10.2221 2.27669 10.1338 2.27669 10.0417V9.34724C2.27669 9.25515 2.31327 9.16684 2.37839 9.10172C2.44351 9.0366 2.53183 9.00002 2.62391 9.00002H11.3045C12.3309 9.0003 13.3207 9.38137 14.0822 10.0695V6.22224H9.22114C9.03696 6.22224 8.86032 6.14908 8.73009 6.01884C8.59986 5.88861 8.52669 5.71198 8.52669 5.5278V0.666687H0.887804C0.703626 0.666687 0.526991 0.739851 0.396757 0.870085C0.266524 1.00032 0.193359 1.17695 0.193359 1.36113V16.6389C0.193359 16.8231 0.266524 16.9997 0.396757 17.13C0.526991 17.2602 0.703626 17.3334 0.887804 17.3334H10.61C9.73337 17.224 8.91945 16.8214 8.30046 16.1911C7.68146 15.5607 7.29375 14.7396 7.2003 13.8611ZM2.62391 5.5278H6.09614C6.18823 5.5278 6.27654 5.56438 6.34166 5.6295C6.40678 5.69461 6.44336 5.78293 6.44336 5.87502V6.56947C6.44336 6.66155 6.40678 6.74987 6.34166 6.81499C6.27654 6.88011 6.18823 6.91669 6.09614 6.91669H2.62391C2.53183 6.91669 2.44351 6.88011 2.37839 6.81499C2.31327 6.74987 2.27669 6.66155 2.27669 6.56947V5.87502C2.27669 5.78293 2.31327 5.69461 2.37839 5.6295C2.44351 5.56438 2.53183 5.5278 2.62391 5.5278Z" fill="#6938EF"/>- <path d="M15.2678 16.1479L13.6887 14.5688C13.9439 14.1455 14.08 13.661 14.0824 13.1667C14.0824 12.6173 13.9195 12.0802 13.6143 11.6234C13.309 11.1666 12.8752 10.8106 12.3676 10.6004C11.8601 10.3901 11.3016 10.3351 10.7627 10.4423C10.2239 10.5495 9.72893 10.814 9.34045 11.2025C8.95197 11.591 8.68741 12.0859 8.58023 12.6248C8.47305 13.1636 8.52806 13.7221 8.7383 14.2297C8.94855 14.7373 9.30458 15.1711 9.76138 15.4763C10.2182 15.7816 10.7552 15.9445 11.3046 15.9445C11.799 15.9421 12.2834 15.806 12.7067 15.5507L14.2859 17.1299C14.4169 17.2564 14.5923 17.3264 14.7744 17.3248C14.9564 17.3232 15.1306 17.2502 15.2594 17.1214C15.3881 16.9927 15.4612 16.8185 15.4627 16.6364C15.4643 16.4543 15.3943 16.2789 15.2678 16.1479ZM9.91575 13.1667C9.91575 12.892 9.9972 12.6235 10.1498 12.3951C10.3024 12.1667 10.5193 11.9887 10.7731 11.8835C11.0269 11.7784 11.3062 11.7509 11.5756 11.8045C11.845 11.8581 12.0925 11.9904 12.2867 12.1846C12.481 12.3788 12.6132 12.6263 12.6668 12.8957C12.7204 13.1652 12.6929 13.4444 12.5878 13.6982C12.4827 13.952 12.3047 14.1689 12.0763 14.3215C11.8479 14.4741 11.5793 14.5556 11.3046 14.5556C10.9363 14.5556 10.583 14.4093 10.3225 14.1488C10.0621 13.8883 9.91575 13.5351 9.91575 13.1667Z" fill="#6938EF"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/selection-mod.svg b/web/app/components/datasets/create/assets/selection-mod.svgdeleted file mode 100644index 2d0dd3b5f74..00000000000--- a/web/app/components/datasets/create/assets/selection-mod.svg+++ /dev/null@@ -1,12 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M5.83317 18.3334H1.6665V14.1667H5.83317V18.3334Z" fill="#6938EF"/>- <path d="M12.0832 12.0834H7.9165V7.91669H12.0832V12.0834Z" fill="#6938EF"/>- <path d="M5.83317 12.0834H1.6665V7.91669H5.83317V12.0834Z" fill="#6938EF"/>- <path d="M12.0832 5.83335H7.9165V1.66669H12.0832V5.83335Z" fill="#6938EF"/>- <path d="M5.83317 5.83335H1.6665V1.66669H5.83317V5.83335Z" fill="#6938EF"/>- <path d="M18.3332 5.83335H14.1665V1.66669H18.3332V5.83335Z" fill="#6938EF"/>- <path d="M17.6386 14.8611H14.8608V17.6389H17.6386V14.8611Z" fill="#6938EF"/>- <path d="M17.6386 8.61115H14.8608V11.3889H17.6386V8.61115Z" fill="#6938EF"/>- <path d="M11.3886 14.8611H8.61084V17.6389H11.3886V14.8611Z" fill="#6938EF"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/assets/setting-gear-mod.svg b/web/app/components/datasets/create/assets/setting-gear-mod.svgdeleted file mode 100644index c782caade88..00000000000--- a/web/app/components/datasets/create/assets/setting-gear-mod.svg+++ /dev/null@@ -1,4 +0,0 @@-<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">- <path fill-rule="evenodd" clip-rule="evenodd" d="M10.0002 0.833374C10.4604 0.833374 10.8335 1.20647 10.8335 1.66671V2.54597C11.5977 2.63056 12.328 2.8301 13.0061 3.12703L13.4452 2.36666C13.6752 1.96808 14.1849 1.83152 14.5835 2.06164C14.9821 2.29176 15.1186 2.80142 14.8885 3.2L14.4488 3.96146C15.0552 4.40877 15.5915 4.94516 16.0388 5.55143L16.8003 5.11177C17.1989 4.88165 17.7086 5.01821 17.9387 5.41679C18.1688 5.81537 18.0322 6.32502 17.6337 6.55514L16.8732 6.99418C17.1702 7.67226 17.3697 8.40254 17.4543 9.16679H18.3335C18.7937 9.16679 19.1668 9.53987 19.1668 10.0001C19.1668 10.4604 18.7937 10.8335 18.3335 10.8335H17.4543C17.3697 11.5977 17.1702 12.328 16.8732 13.0061L17.6337 13.4452C18.0322 13.6753 18.1688 14.185 17.9387 14.5835C17.7086 14.9821 17.1989 15.1187 16.8003 14.8885L16.0388 14.4489C15.5915 15.0551 15.0551 15.5915 14.4488 16.0388L14.8885 16.8004C15.1186 17.1989 14.9821 17.7085 14.5835 17.9387C14.1849 18.1688 13.6752 18.0322 13.4452 17.6337L13.0061 16.8732C12.328 17.1701 11.5977 17.3697 10.8335 17.4543V18.3334C10.8335 18.7936 10.4604 19.1667 10.0002 19.1667C9.53991 19.1667 9.16683 18.7936 9.16683 18.3334V17.4543C8.40258 17.3697 7.6723 17.1701 6.99424 16.8732L6.55516 17.6337C6.32505 18.0323 5.81539 18.1689 5.41681 17.9388C5.01824 17.7086 4.88167 17.199 5.11179 16.8005L5.55149 16.0388C4.94519 15.5915 4.40878 15.0551 3.96145 14.4488L3.19993 14.8885C2.80135 15.1186 2.2917 14.982 2.06158 14.5835C1.83145 14.1849 1.96802 13.6752 2.3666 13.4451L3.12704 13.006C2.83011 12.328 2.63056 11.5977 2.54598 10.8335L1.66679 10.8334C1.20655 10.8334 0.833474 10.4602 0.833496 10C0.833521 9.53979 1.20663 9.16671 1.66687 9.16671L2.54599 9.16679C2.63058 8.40254 2.8301 7.67229 3.12701 6.99424L2.3666 6.55523C1.96802 6.32512 1.83145 5.81546 2.06157 5.41687C2.29169 5.0183 2.80135 4.88173 3.19992 5.11185L3.96142 5.55148C4.40874 4.94518 4.94515 4.40877 5.55145 3.96144L5.11179 3.19991C4.88167 2.80133 5.01823 2.29167 5.41681 2.06156C5.81539 1.83144 6.32505 1.968 6.55516 2.36657L6.9942 3.12702C7.67228 2.83009 8.40258 2.63055 9.16683 2.54597V1.66671C9.16683 1.20647 9.53991 0.833374 10.0002 0.833374ZM6.39156 5.41655C5.81089 5.87442 5.31917 6.44029 4.94695 7.08361C4.45095 7.94087 4.16681 8.93604 4.16681 10.0001C4.16681 11.0642 4.45096 12.0594 4.94698 12.9167C5.3192 13.56 5.81091 14.1259 6.39159 14.5837L8.1 11.6246C7.72651 11.1881 7.50015 10.6208 7.50015 10.0001C7.50015 9.37946 7.72651 8.81212 8.09999 8.37562L6.39156 5.41655ZM9.54316 7.54194L7.83418 4.5819C8.50325 4.31416 9.23383 4.16679 10.0002 4.16679C11.0642 4.16679 12.0594 4.45095 12.9167 4.94697C13.8022 5.45932 14.541 6.19807 15.0533 7.08357C15.4173 7.71277 15.6673 8.41629 15.7745 9.16679H12.3579C12.0147 8.19579 11.0887 7.50012 10.0002 7.50012C9.84433 7.50012 9.69149 7.51446 9.54316 7.54194ZM12.3579 10.8335C12.0147 11.8045 11.0887 12.5001 10.0002 12.5001C9.84433 12.5001 9.69149 12.4858 9.54316 12.4583L7.8342 15.4184C8.50325 15.6861 9.23383 15.8335 10.0002 15.8335C11.0642 15.8335 12.0594 15.5493 12.9167 15.0533C13.8022 14.541 14.5409 13.8022 15.0532 12.9167C15.4173 12.2875 15.6673 11.584 15.7745 10.8335H12.3579Z" fill="#444CE7"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/datasets/create/embedding-process/index.module.css b/web/app/components/datasets/create/embedding-process/index.module.cssindex f2ab4d85a27..1ebb006b543 100644--- a/web/app/components/datasets/create/embedding-process/index.module.css+++ b/web/app/components/datasets/create/embedding-process/index.module.css@@ -14,7 +14,24 @@border-radius: 6px;overflow: hidden;}-+.sourceItem.error {+ background: #FEE4E2;+}+.sourceItem.success {+ background: #D1FADF;+}+.progressbar {+ position: absolute;+ top: 0;+ left: 0;+ height: 100%;+ background-color: #B2CCFF;+}+.sourceItem .info {+ display: flex;+ align-items: center;+ z-index: 1;+}.sourceItem .info .name {font-weight: 500;font-size: 12px;@@ -38,6 +55,13 @@color: #05603A;}++.cost {+ @apply flex justify-between items-center text-xs text-gray-700;+}+.embeddingStatus {+ @apply flex items-center justify-between text-gray-900 font-medium text-sm mr-2;+}.commonIcon {@apply w-3 h-3 mr-1 inline-block align-middle;}@@ -57,33 +81,35 @@@apply text-xs font-medium;}-.unknownFileIcon {+.fileIcon {+ @apply w-4 h-4 mr-1 bg-center bg-no-repeat;background-image: url(../assets/unknown.svg);+ background-size: 16px;}-.csv {+.fileIcon.csv {background-image: url(../assets/csv.svg);}-.docx {+.fileIcon.docx {background-image: url(../assets/docx.svg);}-.xlsx,-.xls {+.fileIcon.xlsx,+.fileIcon.xls {background-image: url(../assets/xlsx.svg);}-.pdf {+.fileIcon.pdf {background-image: url(../assets/pdf.svg);}-.html,-.htm {+.fileIcon.html,+.fileIcon.htm {background-image: url(../assets/html.svg);}-.md,-.markdown {+.fileIcon.md,+.fileIcon.markdown {background-image: url(../assets/md.svg);}-.txt {+.fileIcon.txt {background-image: url(../assets/txt.svg);}-.json {+.fileIcon.json {background-image: url(../assets/json.svg);}diff --git a/web/app/components/datasets/create/embedding-process/index.tsx b/web/app/components/datasets/create/embedding-process/index.tsxindex 201333ffce4..7786582085c 100644--- a/web/app/components/datasets/create/embedding-process/index.tsx+++ b/web/app/components/datasets/create/embedding-process/index.tsx@@ -6,44 +6,32 @@ import { useTranslation } from 'react-i18next'import { omit } from 'lodash-es'import { ArrowRightIcon } from '@heroicons/react/24/solid'import {- RiCheckboxCircleFill,RiErrorWarningFill,- RiLoader2Fill,- RiTerminalBoxLine,} from '@remixicon/react'-import Image from 'next/image'-import { indexMethodIcon, retrievalIcon } from '../icons'-import { IndexingType } from '../step-two'-import DocumentFileIcon from '../../common/document-file-icon'+import s from './index.module.css'import cn from '@/utils/classnames'import { FieldInfo } from '@/app/components/datasets/documents/detail/metadata'import Button from '@/app/components/base/button'import type { FullDocumentDetail, IndexingStatusResponse, ProcessRuleResponse } from '@/models/datasets'import { fetchIndexingStatusBatch as doFetchIndexingStatus, fetchProcessRule } from '@/service/datasets'-import { DataSourceType, ProcessMode } from '@/models/datasets'+import { DataSourceType } from '@/models/datasets'import NotionIcon from '@/app/components/base/notion-icon'import PriorityLabel from '@/app/components/billing/priority-label'import { Plan } from '@/app/components/billing/type'import { ZapFast } from '@/app/components/base/icons/src/vender/solid/general'import UpgradeBtn from '@/app/components/billing/upgrade-btn'import { useProviderContext } from '@/context/provider-context'-import { sleep } from '@/utils'-import { RETRIEVE_METHOD } from '@/types/app'import Tooltip from '@/app/components/base/tooltip'+import { sleep } from '@/utils'type Props = {datasetId: stringbatchId: stringdocuments?: FullDocumentDetail[]indexingType?: string- retrievalMethod?: string}-const RuleDetail: FC<{- sourceData?: ProcessRuleResponse- indexingType?: string- retrievalMethod?: string-}> = ({ sourceData, indexingType, retrievalMethod }) => {+const RuleDetail: FC<{ sourceData?: ProcessRuleResponse }> = ({ sourceData }) => {const { t } = useTranslation()const segmentationRuleMap = {@@ -63,47 +51,29 @@ const RuleDetail: FC<{return t('datasetCreation.stepTwo.removeStopwords')}- const isNumber = (value: unknown) => {- return typeof value === 'number'- }-const getValue = useCallback((field: string) => {let value: string | number | undefined = '-'- const maxTokens = isNumber(sourceData?.rules?.segmentation?.max_tokens)- ? sourceData.rules.segmentation.max_tokens- : value- const childMaxTokens = isNumber(sourceData?.rules?.subchunk_segmentation?.max_tokens)- ? sourceData.rules.subchunk_segmentation.max_tokens- : valueswitch (field) {case 'mode':- value = !sourceData?.mode- ? value- : sourceData.mode === ProcessMode.general- ? (t('datasetDocuments.embedding.custom') as string)- : `${t('datasetDocuments.embedding.hierarchical')} · ${sourceData?.rules?.parent_mode === 'paragraph'- ? t('dataset.parentMode.paragraph')- : t('dataset.parentMode.fullDoc')}`+ value = sourceData?.mode === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string)breakcase 'segmentLength':- value = !sourceData?.mode- ? value- : sourceData.mode === ProcessMode.general- ? maxTokens- : `${t('datasetDocuments.embedding.parentMaxTokens')} ${maxTokens}; ${t('datasetDocuments.embedding.childMaxTokens')} ${childMaxTokens}`+ value = sourceData?.rules?.segmentation?.max_tokensbreakdefault:- value = !sourceData?.mode- ? value- : sourceData?.rules?.pre_processing_rules?.filter(rule =>- rule.enabled).map(rule => getRuleName(rule.id)).join(',')+ value = sourceData?.mode === 'automatic'+ ? (t('datasetDocuments.embedding.automatic') as string)+ // eslint-disable-next-line array-callback-return+ : sourceData?.rules?.pre_processing_rules?.map((rule) => {+ if (rule.enabled)+ return getRuleName(rule.id)+ }).filter(Boolean).join(';')break}return value- // eslint-disable-next-line react-hooks/exhaustive-deps}, [sourceData])- return <div className='flex flex-col gap-1'>+ return <div className='flex flex-col pt-8 pb-10 first:mt-0'>{Object.keys(segmentationRuleMap).map((field) => {return <FieldInfokey={field}@@ -111,43 +81,10 @@ const RuleDetail: FC<{displayedValue={String(getValue(field))}/>})}- <FieldInfo- label={t('datasetCreation.stepTwo.indexMode')}- displayedValue={t(`datasetCreation.stepTwo.${indexingType === IndexingType.ECONOMICAL ? 'economical' : 'qualified'}`) as string}- valueIcon={- <Image- className='size-4'- src={- indexingType === IndexingType.ECONOMICAL- ? indexMethodIcon.economical- : indexMethodIcon.high_quality- }- alt=''- />- }- />- <FieldInfo- label={t('datasetSettings.form.retrievalSetting.title')}- // displayedValue={t(`datasetSettings.form.retrievalSetting.${retrievalMethod}`) as string}- displayedValue={t(`dataset.retrieval.${indexingType === IndexingType.ECONOMICAL ? 'invertedIndex' : retrievalMethod}.title`) as string}- valueIcon={- <Image- className='size-4'- src={- retrievalMethod === RETRIEVE_METHOD.fullText- ? retrievalIcon.fullText- : retrievalMethod === RETRIEVE_METHOD.hybrid- ? retrievalIcon.hybrid- : retrievalIcon.vector- }- alt=''- />- }- /></div>}-const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], indexingType, retrievalMethod }) => {+const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], indexingType }) => {const { t } = useTranslation()const { enableBilling, plan } = useProviderContext()@@ -190,7 +127,6 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], index}useEffect(() => {- setIsStopQuery(false)startQueryStatus()return () => {stopQueryStatus()@@ -210,9 +146,6 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], indexconst navToDocumentList = () => {router.push(`/datasets/${datasetId}/documents`)}- const navToApiDocs = () => {- router.push('/datasets?category=api')- }const isEmbedding = useMemo(() => {return indexingStatusBatchDetail.some(indexingStatusDetail => ['indexing', 'splitting', 'parsing', 'cleaning'].includes(indexingStatusDetail?.indexing_status || ''))@@ -244,17 +177,13 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], indexreturn doc?.data_source_info.notion_page_icon}- const isSourceEmbedding = (detail: IndexingStatusResponse) =>- ['indexing', 'splitting', 'parsing', 'cleaning', 'waiting'].includes(detail.indexing_status || '')+ const isSourceEmbedding = (detail: IndexingStatusResponse) => ['indexing', 'splitting', 'parsing', 'cleaning', 'waiting'].includes(detail.indexing_status || '')return (<>- <div className="h-5 flex items-center mb-3">- <div className="flex items-center justify-between text-gray-900 font-medium text-sm mr-2">- {isEmbedding && <div className='flex items-center'>- <RiLoader2Fill className='size-4 mr-1 animate-spin' />- {t('datasetDocuments.embedding.processing')}- </div>}+ <div className='h-5 flex items-center mb-5'>+ <div className={s.embeddingStatus}>+ {isEmbedding && t('datasetDocuments.embedding.processing')}{isEmbeddingCompleted && t('datasetDocuments.embedding.completed')}</div></div>@@ -271,80 +200,69 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], index</div>)}- <div className="flex flex-col gap-0.5 pb-2">+ <div className={s.progressContainer}>{indexingStatusBatchDetail.map(indexingStatusDetail => (<div key={indexingStatusDetail.id} className={cn(- 'relative h-[26px] bg-components-progress-bar-bg rounded-md overflow-hidden',- indexingStatusDetail.indexing_status === 'error' && 'bg-state-destructive-hover-alt',- // indexingStatusDetail.indexing_status === 'completed' && 's.success',+ s.sourceItem,+ indexingStatusDetail.indexing_status === 'error' && s.error,+ indexingStatusDetail.indexing_status === 'completed' && s.success,)}>{isSourceEmbedding(indexingStatusDetail) && (- <div className="absolute top-0 left-0 h-full min-w-0.5 bg-components-progress-bar-progress border-r-[2px] border-r-components-progress-bar-progress-highlight" style={{ width: `${getSourcePercent(indexingStatusDetail)}%` }} />+ <div className={s.progressbar} style={{ width: `${getSourcePercent(indexingStatusDetail)}%` }} />)}- <div className="flex gap-1 pl-[6px] pr-2 h-full items-center z-[1]">+ <div className={`${s.info} grow`}>{getSourceType(indexingStatusDetail.id) === DataSourceType.FILE && (- // <div className={cn(- // 'shrink-0 marker:size-4 bg-center bg-no-repeat bg-contain',- // s[getFileType(getSourceName(indexingStatusDetail.id))] || s.unknownFileIcon,- // )} />- <DocumentFileIcon- className="shrink-0 size-4"- name={getSourceName(indexingStatusDetail.id)}- extension={getFileType(getSourceName(indexingStatusDetail.id))}- />+ <div className={cn(s.fileIcon, s[getFileType(getSourceName(indexingStatusDetail.id))])} />)}{getSourceType(indexingStatusDetail.id) === DataSourceType.NOTION && (<NotionIcon- className='shrink-0'+ className='shrink-0 mr-1'type='page'src={getIcon(indexingStatusDetail.id)}/>)}- <div className="grow flex items-center gap-1 w-0" title={getSourceName(indexingStatusDetail.id)}>- <div className="text-xs truncate">- {getSourceName(indexingStatusDetail.id)}- </div>- {- enableBilling && (- <PriorityLabel className='ml-0' />- )- }- </div>+ <div className={`${s.name} truncate`} title={getSourceName(indexingStatusDetail.id)}>{getSourceName(indexingStatusDetail.id)}</div>+ {+ enableBilling && (+ <PriorityLabel />+ )+ }+ </div>+ <div className='shrink-0'>{isSourceEmbedding(indexingStatusDetail) && (- <div className="shrink-0 text-xs">{`${getSourcePercent(indexingStatusDetail)}%`}</div>+ <div className={s.percent}>{`${getSourcePercent(indexingStatusDetail)}%`}</div>)}- {indexingStatusDetail.indexing_status === 'error' && (+ {indexingStatusDetail.indexing_status === 'error' && indexingStatusDetail.error && (<Tooltip- popupClassName='px-4 py-[14px] max-w-60 text-sm leading-4 text-text-secondary border-[0.5px] border-components-panel-border rounded-xl'- offset={4}- popupContent={indexingStatusDetail.error}+ popupContent={(+ <div className='max-w-[400px]'>+ {indexingStatusDetail.error}+ </div>+ )}>- <span>- <RiErrorWarningFill className='shrink-0 size-4 text-text-destructive' />- </span>+ <div className={cn(s.percent, s.error, 'flex items-center')}>+ Error+ <RiErrorWarningFill className='ml-1 w-4 h-4' />+ </div></Tooltip>)}+ {indexingStatusDetail.indexing_status === 'error' && !indexingStatusDetail.error && (+ <div className={cn(s.percent, s.error, 'flex items-center')}>+ Error+ </div>+ )}{indexingStatusDetail.indexing_status === 'completed' && (- <RiCheckboxCircleFill className='shrink-0 size-4 text-text-success' />+ <div className={cn(s.percent, s.success)}>100%</div>)}</div></div>))}</div>- <hr className="my-3 h-[1px] bg-divider-subtle border-0" />- <RuleDetail- sourceData={ruleDetail}- indexingType={indexingType}- retrievalMethod={retrievalMethod}- />- <div className='flex items-center gap-2 my-10'>- <Button className='w-fit' onClick={navToApiDocs}>- <RiTerminalBoxLine className='size-4 mr-2' />- <span>Access the API</span>- </Button>+ <RuleDetail sourceData={ruleDetail} />+ <div className='flex items-center gap-2 mt-10'><Button className='w-fit' variant='primary' onClick={navToDocumentList}><span>{t('datasetCreation.stepThree.navTo')}</span>- <ArrowRightIcon className='size-4 ml-2 stroke-current stroke-1' />+ <ArrowRightIcon className='h-4 w-4 ml-2 stroke-current stroke-1' /></Button></div></>diff --git a/web/app/components/datasets/create/file-preview/index.module.css b/web/app/components/datasets/create/file-preview/index.module.cssindex 929002e1e29..d87522e6d0b 100644--- a/web/app/components/datasets/create/file-preview/index.module.css+++ b/web/app/components/datasets/create/file-preview/index.module.css@@ -1,6 +1,6 @@.filePreview {@apply flex flex-col border-l border-gray-200 shrink-0;- width: 100%;+ width: 528px;background-color: #fcfcfd;}@@ -48,6 +48,5 @@}.fileContent {white-space: pre-line;- word-break: break-all;}\ No newline at end of filediff --git a/web/app/components/datasets/create/file-preview/index.tsx b/web/app/components/datasets/create/file-preview/index.tsxindex cb1f1d6908c..e20af64386c 100644--- a/web/app/components/datasets/create/file-preview/index.tsx+++ b/web/app/components/datasets/create/file-preview/index.tsx@@ -44,7 +44,7 @@ const FilePreview = ({}, [file])return (- <div className={cn(s.filePreview, 'h-full')}>+ <div className={cn(s.filePreview)}><div className={cn(s.previewHeader)}><div className={cn(s.title)}><span>{t('datasetCreation.stepOne.filePreview')}</span>@@ -59,7 +59,7 @@ const FilePreview = ({<div className={cn(s.previewContent)}>{loading && <div className={cn(s.loading)} />}{!loading && (- <div className={cn(s.fileContent, 'body-md-regular')}>{previewContent}</div>+ <div className={cn(s.fileContent)}>{previewContent}</div>)}</div></div>diff --git a/web/app/components/datasets/create/file-uploader/index.module.css b/web/app/components/datasets/create/file-uploader/index.module.cssindex 7d29f2ef9c2..bf5b7dcaf5b 100644--- a/web/app/components/datasets/create/file-uploader/index.module.css+++ b/web/app/components/datasets/create/file-uploader/index.module.css@@ -1,3 +1,68 @@+.fileUploader {+ @apply mb-6;+}++.fileUploader .title {+ @apply mb-2;+ font-weight: 500;+ font-size: 16px;+ line-height: 24px;+ color: #344054;+}++.fileUploader .tip {+ font-weight: 400;+ font-size: 12px;+ line-height: 18px;+ color: #667085;+}++.uploader {+ @apply relative box-border flex justify-center items-center mb-2 p-3;+ flex-direction: column;+ max-width: 640px;+ min-height: 80px;+ background: #F9FAFB;+ border: 1px dashed #EAECF0;+ border-radius: 12px;+ font-weight: 400;+ font-size: 14px;+ line-height: 20px;+ color: #667085;+}++.uploader.dragging {+ background: #F5F8FF;+ border: 1px dashed #B2CCFF;+}++.uploader .draggingCover {+ position: absolute;+ top: 0;+ left: 0;+ width: 100%;+ height: 100%;+}++.uploader .uploadIcon {+ content: '';+ display: block;+ margin-right: 8px;+ width: 24px;+ height: 24px;+ background: center no-repeat url(../assets/upload-cloud-01.svg);+ background-size: contain;+}++.uploader .browse {+ @apply pl-1 cursor-pointer;+ color: #155eef;+}++.fileList {+ @apply space-y-2;+}+.file {@apply box-border relative flex items-center justify-between;padding: 8px 12px 8px 8px;@@ -128,4 +193,4 @@.file:hover .actionWrapper .remove {display: block;-}+}\ No newline at end of filediff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsxindex e42a24cfef5..adb4bed0d16 100644--- a/web/app/components/datasets/create/file-uploader/index.tsx+++ b/web/app/components/datasets/create/file-uploader/index.tsx@@ -3,12 +3,10 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import useSWR from 'swr'-import { RiDeleteBinLine, RiUploadCloud2Line } from '@remixicon/react'-import DocumentFileIcon from '../../common/document-file-icon'+import s from './index.module.css'import cn from '@/utils/classnames'import type { CustomFile as File, FileItem } from '@/models/datasets'import { ToastContext } from '@/app/components/base/toast'-import SimplePieChart from '@/app/components/base/simple-pie-chart'import { upload } from '@/service/base'import { fetchFileUploadConfig } from '@/service/common'@@ -16,8 +14,6 @@ import { fetchSupportFileTypes } from '@/service/datasets'import I18n from '@/context/i18n'import { LanguagesSupported } from '@/i18n/language'import { IS_CE_EDITION } from '@/config'-import { useAppContext } from '@/context/app-context'-import { Theme } from '@/types/app'const FILES_NUMBER_LIMIT = 20@@ -226,9 +222,6 @@ const FileUploader = ({initialUpload(files.filter(isValid))}, [isValid, initialUpload])- const { theme } = useAppContext()- const chartColor = useMemo(() => theme === Theme.dark ? '#5289ff' : '#296dff', [theme])-useEffect(() => {dropRef.current?.addEventListener('dragenter', handleDragEnter)dropRef.current?.addEventListener('dragover', handleDragOver)@@ -243,12 +236,12 @@ const FileUploader = ({}, [handleDrop])return (- <div className="mb-5 w-[640px]">+ <div className={s.fileUploader}>{!hideUpload && (<inputref={fileUploader}id="fileUploader"- className="hidden"+ style={{ display: 'none' }}type="file"multiple={!notSupportBatchUpload}accept={ACCEPTS.join(',')}@@ -256,71 +249,52 @@ const FileUploader = ({/>)}- <div className={cn('text-text-tertiary text-sm font-semibold leading-6 mb-1', titleClassName)}>{t('datasetCreation.stepOne.uploader.title')}</div>-+ <div className={cn(s.title, titleClassName)}>{t('datasetCreation.stepOne.uploader.title')}</div>{!hideUpload && (- <div ref={dropRef} className={cn('relative box-border flex flex-col justify-center items-center gap-1 mb-2 px-4 py-3 max-w-[640px] min-h-20 leading-4 text-xs text-text-tertiary bg-components-dropzone-bg border border-dashed border-components-dropzone-border rounded-xl', dragging && 'bg-components-dropzone-bg-accent border-components-dropzone-border-accent')}>- <div className="flex justify-center items-center min-h-5 text-sm leading-4 text-text-secondary">- <RiUploadCloud2Line className='mr-2 size-5' />+ <div ref={dropRef} className={cn(s.uploader, dragging && s.dragging)}>+ <div className='flex justify-center items-center min-h-6 mb-2'>+ <span className={s.uploadIcon} /><span>{t('datasetCreation.stepOne.uploader.button')}- {supportTypes.length > 0 && (- <label className="ml-1 text-text-accent cursor-pointer" onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label>- )}+ <label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label></span></div>- <div>{t('datasetCreation.stepOne.uploader.tip', {+ <div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip', {size: fileUploadConfig.file_size_limit,supportTypes: supportTypesShowNames,})}</div>- {dragging && <div ref={dragRef} className='absolute top-0 left-0 w-full h-full' />}+ {dragging && <div ref={dragRef} className={s.draggingCover} />}</div>)}- <div className='space-y-1 max-w-[640px] cursor-default'>-+ <div className={s.fileList}>{fileList.map((fileItem, index) => (<divkey={`${fileItem.fileID}-${index}`}onClick={() => fileItem.file?.id && onPreview(fileItem.file)}className={cn(- 'flex items-center h-12 max-w-[640px] bg-components-panel-on-panel-item-bg text-xs leading-3 text-text-tertiary border border-components-panel-border rounded-lg shadow-xs',- // 'border-state-destructive-border bg-state-destructive-hover',+ s.file,+ fileItem.progress < 100 && s.uploading,)}>- <div className="shrink-0 flex justify-center items-center w-12">- <DocumentFileIcon- className="shrink-0 size-6"- name={fileItem.file.name}- extension={getFileType(fileItem.file)}- />- </div>- <div className="grow shrink flex flex-col gap-0.5">- <div className='flex w-full'>- <div className="text-sm leading-4 text-text-secondary w-0 grow truncate">{fileItem.file.name}</div>- </div>- <div className="w-full leading-3 truncate text-text-tertiary">- <span className='uppercase'>{getFileType(fileItem.file)}</span>- <span className='px-1 text-text-quaternary'>·</span>- <span>{getFileSize(fileItem.file.size)}</span>- {/* <span className='px-1 text-text-quaternary'>·</span>- <span>10k characters</span> */}- </div>+ {fileItem.progress < 100 && (+ <div className={s.progressbar} style={{ width: `${fileItem.progress}%` }} />+ )}+ <div className={s.fileInfo}>+ <div className={cn(s.fileIcon, s[getFileType(fileItem.file)])} />+ <div className={s.filename}>{fileItem.file.name}</div>+ <div className={s.size}>{getFileSize(fileItem.file.size)}</div></div>- <div className="shrink-0 flex items-center justify-end gap-1 pr-3 w-16">- {/* <span className="flex justify-center items-center w-6 h-6 cursor-pointer">- <RiErrorWarningFill className='size-4 text-text-warning' />- </span> */}+ <div className={s.actionWrapper}>{(fileItem.progress < 100 && fileItem.progress >= 0) && (- // <div className={s.percent}>{`${fileItem.progress}%`}</div>- <SimplePieChart percentage={fileItem.progress} stroke={chartColor} fill={chartColor} animationDuration={0} />+ <div className={s.percent}>{`${fileItem.progress}%`}</div>+ )}+ {fileItem.progress === 100 && (+ <div className={s.remove} onClick={(e) => {+ e.stopPropagation()+ removeFile(fileItem.fileID)+ }} />)}- <span className="flex justify-center items-center w-6 h-6 cursor-pointer" onClick={(e) => {- e.stopPropagation()- removeFile(fileItem.fileID)- }}>- <RiDeleteBinLine className='size-4 text-text-tertiary' />- </span></div></div>))}diff --git a/web/app/components/datasets/create/icons.ts b/web/app/components/datasets/create/icons.tsdeleted file mode 100644index 80c4b6c9447..00000000000--- a/web/app/components/datasets/create/icons.ts+++ /dev/null@@ -1,16 +0,0 @@-import GoldIcon from './assets/gold.svg'-import Piggybank from './assets/piggy-bank-mod.svg'-import Selection from './assets/selection-mod.svg'-import Research from './assets/research-mod.svg'-import PatternRecognition from './assets/pattern-recognition-mod.svg'--export const indexMethodIcon = {- high_quality: GoldIcon,- economical: Piggybank,-}--export const retrievalIcon = {- vector: Selection,- fullText: Research,- hybrid: PatternRecognition,-}diff --git a/web/app/components/datasets/create/index.tsx b/web/app/components/datasets/create/index.tsxindex 9556b9fad57..98098445c76 100644--- a/web/app/components/datasets/create/index.tsx+++ b/web/app/components/datasets/create/index.tsx@@ -3,10 +3,10 @@ import React, { useCallback, useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import AppUnavailable from '../../base/app-unavailable'import { ModelTypeEnum } from '../../header/account-setting/model-provider-page/declarations'+import StepsNavBar from './steps-nav-bar'import StepOne from './step-one'import StepTwo from './step-two'import StepThree from './step-three'-import { Topbar } from './top-bar'import { DataSourceType } from '@/models/datasets'import type { CrawlOptions, CrawlResultItem, DataSet, FileItem, createDocumentResponse } from '@/models/datasets'import { fetchDataSource } from '@/service/common'@@ -36,7 +36,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE)const [step, setStep] = useState(1)const [indexingTypeCache, setIndexTypeCache] = useState('')- const [retrievalMethodCache, setRetrievalMethodCache] = useState('')const [fileList, setFiles] = useState<FileItem[]>([])const [result, setResult] = useState<createDocumentResponse | undefined>()const [hasError, setHasError] = useState(false)@@ -81,9 +80,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {const updateResultCache = (res?: createDocumentResponse) => {setResult(res)}- const updateRetrievalMethodCache = (method: string) => {- setRetrievalMethodCache(method)- }const nextStep = useCallback(() => {setStep(step + 1)@@ -122,29 +118,33 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {return <AppUnavailable code={500} unknownReason={t('datasetCreation.error.unavailable') as string} />return (- <div className='flex flex-col bg-components-panel-bg' style={{ height: 'calc(100vh - 56px)' }}>- <Topbar activeIndex={step - 1} />- <div style={{ height: 'calc(100% - 52px)' }}>- {step === 1 && <StepOne- hasConnection={hasConnection}- onSetting={() => setShowAccountSettingModal({ payload: 'data-source' })}- datasetId={datasetId}- dataSourceType={dataSourceType}- dataSourceTypeDisable={!!detail?.data_source_type}- changeType={setDataSourceType}- files={fileList}- updateFile={updateFile}- updateFileList={updateFileList}- notionPages={notionPages}- updateNotionPages={updateNotionPages}- onStepChange={nextStep}- websitePages={websitePages}- updateWebsitePages={setWebsitePages}- onWebsiteCrawlProviderChange={setWebsiteCrawlProvider}- onWebsiteCrawlJobIdChange={setWebsiteCrawlJobId}- crawlOptions={crawlOptions}- onCrawlOptionsChange={setCrawlOptions}- />}+ <div className='flex' style={{ height: 'calc(100vh - 56px)' }}>+ <div className="flex flex-col w-11 sm:w-56 overflow-y-auto bg-white border-r border-gray-200 shrink-0">+ <StepsNavBar step={step} datasetId={datasetId} />+ </div>+ <div className="grow bg-white">+ <div className={step === 1 ? 'block h-full' : 'hidden'}>+ <StepOne+ hasConnection={hasConnection}+ onSetting={() => setShowAccountSettingModal({ payload: 'data-source' })}+ datasetId={datasetId}+ dataSourceType={dataSourceType}+ dataSourceTypeDisable={!!detail?.data_source_type}+ changeType={setDataSourceType}+ files={fileList}+ updateFile={updateFile}+ updateFileList={updateFileList}+ notionPages={notionPages}+ updateNotionPages={updateNotionPages}+ onStepChange={nextStep}+ websitePages={websitePages}+ updateWebsitePages={setWebsitePages}+ onWebsiteCrawlProviderChange={setWebsiteCrawlProvider}+ onWebsiteCrawlJobIdChange={setWebsiteCrawlJobId}+ crawlOptions={crawlOptions}+ onCrawlOptionsChange={setCrawlOptions}+ />+ </div>{(step === 2 && (!datasetId || (datasetId && !!detail))) && <StepTwoisAPIKeySet={!!embeddingsDefaultModel}onSetting={() => setShowAccountSettingModal({ payload: 'provider' })}@@ -158,7 +158,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {websiteCrawlJobId={websiteCrawlJobId}onStepChange={changeStep}updateIndexingTypeCache={updateIndexingTypeCache}- updateRetrievalMethodCache={updateRetrievalMethodCache}updateResultCache={updateResultCache}crawlOptions={crawlOptions}/>}@@ -166,7 +165,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {datasetId={datasetId}datasetName={detail?.name}indexingType={detail?.indexing_technique || indexingTypeCache}- retrievalMethod={detail?.retrieval_model_dict?.search_method || retrievalMethodCache}creationCache={result}/>}</div>diff --git a/web/app/components/datasets/create/notion-page-preview/index.tsx b/web/app/components/datasets/create/notion-page-preview/index.tsxindex f658f213e85..8225e56f040 100644--- a/web/app/components/datasets/create/notion-page-preview/index.tsx+++ b/web/app/components/datasets/create/notion-page-preview/index.tsx@@ -44,7 +44,7 @@ const NotionPagePreview = ({}, [currentPage])return (- <div className={cn(s.filePreview, 'h-full')}>+ <div className={cn(s.filePreview)}><div className={cn(s.previewHeader)}><div className={cn(s.title)}><span>{t('datasetCreation.stepOne.pagePreview')}</span>@@ -64,7 +64,7 @@ const NotionPagePreview = ({<div className={cn(s.previewContent)}>{loading && <div className={cn(s.loading)} />}{!loading && (- <div className={cn(s.fileContent, 'body-md-regular')}>{previewContent}</div>+ <div className={cn(s.fileContent)}>{previewContent}</div>)}</div></div>diff --git a/web/app/components/datasets/create/step-one/index.module.css b/web/app/components/datasets/create/step-one/index.module.cssindex bb8dd9b895c..4e3cf67cd6c 100644--- a/web/app/components/datasets/create/step-one/index.module.css+++ b/web/app/components/datasets/create/step-one/index.module.css@@ -2,19 +2,21 @@position: sticky;top: 0;left: 0;- padding: 42px 64px 12px 0;+ padding: 42px 64px 12px;font-weight: 600;font-size: 18px;line-height: 28px;+ color: #101828;}.form {position: relative;padding: 12px 64px;+ background-color: #fff;}.dataSourceItem {- @apply box-border relative grow shrink-0 flex items-center p-3 h-14 bg-white rounded-xl cursor-pointer;+ @apply box-border relative shrink-0 flex items-center mr-3 p-3 h-14 bg-white rounded-xl cursor-pointer;border: 0.5px solid #EAECF0;box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);font-weight: 500;@@ -22,32 +24,27 @@line-height: 20px;color: #101828;}-.dataSourceItem:hover {background-color: #f5f8ff;border: 0.5px solid #B2CCFF;box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);}-.dataSourceItem.active {background-color: #f5f8ff;border: 1.5px solid #528BFF;box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);}-.dataSourceItem.disabled {background-color: #f9fafb;border: 0.5px solid #EAECF0;box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);cursor: default;}-.dataSourceItem.disabled:hover {background-color: #f9fafb;border: 0.5px solid #EAECF0;box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);}-.comingTag {@apply flex justify-center items-center bg-white;position: absolute;@@ -62,7 +59,6 @@line-height: 18px;color: #444CE7;}-.datasetIcon {@apply flex mr-2 w-8 h-8 rounded-lg bg-center bg-no-repeat;background-color: #F5FAFF;@@ -70,18 +66,15 @@background-size: 16px;border: 0.5px solid #D1E9FF;}-.dataSourceItem:active .datasetIcon,.dataSourceItem:hover .datasetIcon {background-color: #F5F8FF;border: 0.5px solid #E0EAFF;}-.datasetIcon.notion {background-image: url(../assets/notion.svg);background-size: 20px;}-.datasetIcon.web {background-image: url(../assets/web.svg);}@@ -97,12 +90,29 @@background-color: #eaecf0;}+.OtherCreationOption {+ @apply flex items-center cursor-pointer;+ font-weight: 500;+ font-size: 13px;+ line-height: 18px;+ color: #155EEF;+}+.OtherCreationOption::before {+ content: '';+ display: block;+ margin-right: 4px;+ width: 16px;+ height: 16px;+ background: center no-repeat url(../assets/folder-plus.svg);+ background-size: contain;+}+.notionConnectionTip {display: flex;flex-direction: column;align-items: flex-start;padding: 24px;- width: 640px;+ max-width: 640px;background: #F9FAFB;border-radius: 16px;}@@ -128,7 +138,6 @@line-height: 24px;color: #374151;}-.notionConnectionTip .title::after {content: '';position: absolute;@@ -139,7 +148,6 @@background: center no-repeat url(../assets/Icon-3-dots.svg);background-size: contain;}-.notionConnectionTip .tip {margin-bottom: 20px;font-style: normal;@@ -147,4 +155,4 @@font-size: 13px;line-height: 18px;color: #6B7280;-}\ No newline at end of file+}diff --git a/web/app/components/datasets/create/step-one/index.tsx b/web/app/components/datasets/create/step-one/index.tsxindex 2cca003b397..643932e9ae2 100644--- a/web/app/components/datasets/create/step-one/index.tsx+++ b/web/app/components/datasets/create/step-one/index.tsx@@ -1,7 +1,6 @@'use client'import React, { useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'-import { RiArrowRightLine, RiFolder6Line } from '@remixicon/react'import FilePreview from '../file-preview'import FileUploader from '../file-uploader'import NotionPagePreview from '../notion-page-preview'@@ -18,7 +17,6 @@ import { NotionPageSelector } from '@/app/components/base/notion-page-selector'import { useDatasetDetailContext } from '@/context/dataset-detail'import { useProviderContext } from '@/context/provider-context'import VectorSpaceFull from '@/app/components/billing/vector-space-full'-import classNames from '@/utils/classnames'type IStepOneProps = {datasetId?: string@@ -122,174 +120,143 @@ const StepOne = ({return trueif (isShowVectorSpaceFull)return true- return false- }, [files, isShowVectorSpaceFull])+ return false+ }, [files])return (<div className='flex w-full h-full'>- <div className='w-1/2 h-full overflow-y-auto relative'>- <div className='flex justify-end'>- <div className={classNames(s.form)}>- {- shouldShowDataSourceTypeList && (- <div className={classNames(s.stepHeader, 'z-10 text-text-secondary bg-components-panel-bg-blur')}>{t('datasetCreation.steps.one')}</div>- )- }- {- shouldShowDataSourceTypeList && (- <div className='flex items-center mb-8 flex-wrap gap-4'>- <div- className={cn(- s.dataSourceItem,- dataSourceType === DataSourceType.FILE && s.active,- dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,- )}- onClick={() => {- if (dataSourceTypeDisable)- return- changeType(DataSourceType.FILE)- hideFilePreview()- hideNotionPagePreview()- }}- >- <span className={cn(s.datasetIcon)} />- {t('datasetCreation.stepOne.dataSourceType.file')}- </div>- <div- className={cn(- s.dataSourceItem,- dataSourceType === DataSourceType.NOTION && s.active,- dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled,- )}- onClick={() => {- if (dataSourceTypeDisable)- return- changeType(DataSourceType.NOTION)- hideFilePreview()- hideNotionPagePreview()- }}- >- <span className={cn(s.datasetIcon, s.notion)} />- {t('datasetCreation.stepOne.dataSourceType.notion')}- </div>- <div- className={cn(- s.dataSourceItem,- dataSourceType === DataSourceType.WEB && s.active,- dataSourceTypeDisable && dataSourceType !== DataSourceType.WEB && s.disabled,- )}- onClick={() => changeType(DataSourceType.WEB)}- >- <span className={cn(s.datasetIcon, s.web)} />- {t('datasetCreation.stepOne.dataSourceType.web')}- </div>+ <div className='grow overflow-y-auto relative'>+ {+ shouldShowDataSourceTypeList && (+ <div className={s.stepHeader}>{t('datasetCreation.steps.one')}</div>+ )+ }+ <div className={s.form}>+ {+ shouldShowDataSourceTypeList && (+ <div className='flex items-center mb-8 flex-wrap gap-y-4'>+ <div+ className={cn(+ s.dataSourceItem,+ dataSourceType === DataSourceType.FILE && s.active,+ dataSourceTypeDisable && dataSourceType !== DataSourceType.FILE && s.disabled,+ )}+ onClick={() => {+ if (dataSourceTypeDisable)+ return+ changeType(DataSourceType.FILE)+ hideFilePreview()+ hideNotionPagePreview()+ }}+ >+ <span className={cn(s.datasetIcon)} />+ {t('datasetCreation.stepOne.dataSourceType.file')}</div>- )- }- {dataSourceType === DataSourceType.FILE && (- <>- <FileUploader- fileList={files}- titleClassName={!shouldShowDataSourceTypeList ? 'mt-[30px] !mb-[44px] !text-lg !font-semibold !text-gray-900' : undefined}- prepareFileList={updateFileList}- onFileListUpdate={updateFileList}- onFileUpdate={updateFile}- onPreview={updateCurrentFile}- notSupportBatchUpload={notSupportBatchUpload}- />- {isShowVectorSpaceFull && (- <div className='max-w-[640px] mb-4'>- <VectorSpaceFull />- </div>- )}- <div className="flex justify-end gap-2 max-w-[640px]">- {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}- <Button disabled={nextDisabled} variant='primary' onClick={onStepChange}>- <span className="flex gap-0.5 px-[10px]">- <span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>- <RiArrowRightLine className="size-4" />- </span>- </Button>+ <div+ className={cn(+ s.dataSourceItem,+ dataSourceType === DataSourceType.NOTION && s.active,+ dataSourceTypeDisable && dataSourceType !== DataSourceType.NOTION && s.disabled,+ )}+ onClick={() => {+ if (dataSourceTypeDisable)+ return+ changeType(DataSourceType.NOTION)+ hideFilePreview()+ hideNotionPagePreview()+ }}+ >+ <span className={cn(s.datasetIcon, s.notion)} />+ {t('datasetCreation.stepOne.dataSourceType.notion')}</div>- </>- )}- {dataSourceType === DataSourceType.NOTION && (- <>- {!hasConnection && <NotionConnector onSetting={onSetting} />}- {hasConnection && (- <>- <div className='mb-8 w-[640px]'>- <NotionPageSelector- value={notionPages.map(page => page.page_id)}- onSelect={updateNotionPages}- onPreview={updateCurrentPage}- />- </div>- {isShowVectorSpaceFull && (- <div className='max-w-[640px] mb-4'>- <VectorSpaceFull />- </div>- )}- <div className="flex justify-end gap-2 max-w-[640px]">- {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}- <Button disabled={isShowVectorSpaceFull || !notionPages.length} variant='primary' onClick={onStepChange}>- <span className="flex gap-0.5 px-[10px]">- <span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>- <RiArrowRightLine className="size-4" />- </span>- </Button>- </div>- </>- )}- </>- )}- {dataSourceType === DataSourceType.WEB && (- <>- <div className={cn('mb-8 w-[640px]', !shouldShowDataSourceTypeList && 'mt-12')}>- <Website- onPreview={setCurrentWebsite}- checkedCrawlResult={websitePages}- onCheckedCrawlResultChange={updateWebsitePages}- onCrawlProviderChange={onWebsiteCrawlProviderChange}- onJobIdChange={onWebsiteCrawlJobIdChange}- crawlOptions={crawlOptions}- onCrawlOptionsChange={onCrawlOptionsChange}- />+ <div+ className={cn(+ s.dataSourceItem,+ dataSourceType === DataSourceType.WEB && s.active,+ dataSourceTypeDisable && dataSourceType !== DataSourceType.WEB && s.disabled,+ )}+ onClick={() => changeType(DataSourceType.WEB)}+ >+ <span className={cn(s.datasetIcon, s.web)} />+ {t('datasetCreation.stepOne.dataSourceType.web')}+ </div>+ </div>+ )+ }+ {dataSourceType === DataSourceType.FILE && (+ <>+ <FileUploader+ fileList={files}+ titleClassName={!shouldShowDataSourceTypeList ? 'mt-[30px] !mb-[44px] !text-lg !font-semibold !text-gray-900' : undefined}+ prepareFileList={updateFileList}+ onFileListUpdate={updateFileList}+ onFileUpdate={updateFile}+ onPreview={updateCurrentFile}+ notSupportBatchUpload={notSupportBatchUpload}+ />+ {isShowVectorSpaceFull && (+ <div className='max-w-[640px] mb-4'>+ <VectorSpaceFull /></div>- {isShowVectorSpaceFull && (- <div className='max-w-[640px] mb-4'>- <VectorSpaceFull />+ )}+ <Button disabled={nextDisabled} className={s.submitButton} variant='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>+ </>+ )}+ {dataSourceType === DataSourceType.NOTION && (+ <>+ {!hasConnection && <NotionConnector onSetting={onSetting} />}+ {hasConnection && (+ <>+ <div className='mb-8 w-[640px]'>+ <NotionPageSelector+ value={notionPages.map(page => page.page_id)}+ onSelect={updateNotionPages}+ onPreview={updateCurrentPage}+ /></div>- )}- <div className="flex justify-end gap-2 max-w-[640px]">- {/* <Button>{t('datasetCreation.stepOne.cancel')}</Button> */}- <Button disabled={isShowVectorSpaceFull || !websitePages.length} variant='primary' onClick={onStepChange}>- <span className="flex gap-0.5 px-[10px]">- <span className="px-0.5">{t('datasetCreation.stepOne.button')}</span>- <RiArrowRightLine className="size-4" />- </span>- </Button>+ {isShowVectorSpaceFull && (+ <div className='max-w-[640px] mb-4'>+ <VectorSpaceFull />+ </div>+ )}+ <Button disabled={isShowVectorSpaceFull || !notionPages.length} className={s.submitButton} variant='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>+ </>+ )}+ </>+ )}+ {dataSourceType === DataSourceType.WEB && (+ <>+ <div className={cn('mb-8 w-[640px]', !shouldShowDataSourceTypeList && 'mt-12')}>+ <Website+ onPreview={setCurrentWebsite}+ checkedCrawlResult={websitePages}+ onCheckedCrawlResultChange={updateWebsitePages}+ onCrawlProviderChange={onWebsiteCrawlProviderChange}+ onJobIdChange={onWebsiteCrawlJobIdChange}+ crawlOptions={crawlOptions}+ onCrawlOptionsChange={onCrawlOptionsChange}+ />+ </div>+ {isShowVectorSpaceFull && (+ <div className='max-w-[640px] mb-4'>+ <VectorSpaceFull /></div>- </>- )}- {!datasetId && (- <>- <div className={s.dividerLine} />- <span className="inline-flex items-center cursor-pointer text-[13px] leading-4 text-text-accent" onClick={modalShowHandle}>- <RiFolder6Line className="size-4 mr-1" />- {t('datasetCreation.stepOne.emptyDatasetCreation')}- </span>- </>- )}- </div>- <EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} />+ )}+ <Button disabled={isShowVectorSpaceFull || !websitePages.length} className={s.submitButton} variant='primary' onClick={onStepChange}>{t('datasetCreation.stepOne.button')}</Button>+ </>+ )}+ {!datasetId && (+ <>+ <div className={s.dividerLine} />+ <div onClick={modalShowHandle} className={s.OtherCreationOption}>{t('datasetCreation.stepOne.emptyDatasetCreation')}</div>+ </>+ )}</div>+ <EmptyDatasetCreationModal show={showModal} onHide={modalCloseHandle} /></div>- <div className='w-1/2 h-full overflow-y-auto'>- {currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}- {currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />}- {currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />}- </div>+ {currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}+ {currentNotionPage && <NotionPagePreview currentPage={currentNotionPage} hidePreview={hideNotionPagePreview} />}+ {currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />}</div>)}diff --git a/web/app/components/datasets/create/step-three/index.tsx b/web/app/components/datasets/create/step-three/index.tsxindex 8d979616d13..804a196ed5a 100644--- a/web/app/components/datasets/create/step-three/index.tsx+++ b/web/app/components/datasets/create/step-three/index.tsx@@ -1,51 +1,45 @@'use client'import React from 'react'import { useTranslation } from 'react-i18next'-import { RiBookOpenLine } from '@remixicon/react'import EmbeddingProcess from '../embedding-process'+import s from './index.module.css'+import cn from '@/utils/classnames'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'import type { FullDocumentDetail, createDocumentResponse } from '@/models/datasets'-import AppIcon from '@/app/components/base/app-icon'type StepThreeProps = {datasetId?: stringdatasetName?: stringindexingType?: string- retrievalMethod?: stringcreationCache?: createDocumentResponse}-const StepThree = ({ datasetId, datasetName, indexingType, creationCache, retrievalMethod }: StepThreeProps) => {+const StepThree = ({ datasetId, datasetName, indexingType, creationCache }: StepThreeProps) => {const { t } = useTranslation()const media = useBreakpoints()const isMobile = media === MediaType.mobilereturn (- <div className="flex justify-center w-full max-h-full h-full overflow-y-auto">- <div className="grow shrink-0 h-full max-w-[960px] overflow-y-auto px-14 sm:px-16">- <div className="mx-auto max-w-[640px]">+ <div className='flex w-full h-full'>+ <div className={'h-full w-full overflow-y-scroll px-6 sm:px-16'}>+ <div className='max-w-[636px]'>{!datasetId && (<>- <div className="pt-10">- <div className="mb-1 text-xl leading-[22px] font-semibold text-text-primary">{t('datasetCreation.stepThree.creationTitle')}</div>- <div className="mb-7 text-[13px] leading-4 text-text-tertiary">{t('datasetCreation.stepThree.creationContent')}</div>- <div className="flex gap-4">- <AppIcon {...creationCache?.dataset} className="size-14 text-2xl self-center" />- <div className="grow flex flex-col gap-1">- <div className="text-[13px] leading-6 font-semibold">{t('datasetCreation.stepThree.label')}</div>- <div className="w-full px-3 py-2 text-[13px] leading-4 bg-components-input-bg-normal rounded-lg truncate">{datasetName || creationCache?.dataset?.name}</div>- </div>- </div>+ <div className={s.creationInfo}>+ <div className={s.title}>{t('datasetCreation.stepThree.creationTitle')}</div>+ <div className={s.content}>{t('datasetCreation.stepThree.creationContent')}</div>+ <div className={s.label}>{t('datasetCreation.stepThree.label')}</div>+ <div className={s.datasetName}>{datasetName || creationCache?.dataset?.name}</div></div>- <hr className="my-6 h-[1px] bg-divider-subtle border-0" />+ <div className={s.dividerLine} /></>)}{datasetId && (- <div className="pt-10">- <div className="mb-1 text-xl leading-[22px] font-semibold text-text-primary">{t('datasetCreation.stepThree.additionTitle')}</div>- <div className="mb-7 text-[13px] leading-4 text-text-tertiary">{`${t('datasetCreation.stepThree.additionP1')} ${datasetName || creationCache?.dataset?.name} ${t('datasetCreation.stepThree.additionP2')}`}</div>+ <div className={s.creationInfo}>+ <div className={s.title}>{t('datasetCreation.stepThree.additionTitle')}</div>+ <div className={s.content}>{`${t('datasetCreation.stepThree.additionP1')} ${datasetName || creationCache?.dataset?.name} ${t('datasetCreation.stepThree.additionP2')}`}</div></div>)}<EmbeddingProcess@@ -53,21 +47,16 @@ const StepThree = ({ datasetId, datasetName, indexingType, creationCache, retriebatchId={creationCache?.batch || ''}documents={creationCache?.documents as FullDocumentDetail[]}indexingType={indexingType || creationCache?.dataset?.indexing_technique}- retrievalMethod={retrievalMethod || creationCache?.dataset?.retrieval_model?.search_method}/></div></div>- {!isMobile && (- <div className="shrink-0 pt-[88px] pr-8 text-xs">- <div className="flex flex-col gap-3 w-[328px] p-6 text-text-tertiary bg-background-section rounded-xl">- <div className="flex justify-center items-center size-10 bg-components-card-bg rounded-[10px] shadow-lg">- <RiBookOpenLine className="size-5 text-text-accent" />- </div>- <div className="text-base font-semibold text-text-secondary">{t('datasetCreation.stepThree.sideTipTitle')}</div>- <div className="text-text-tertiary">{t('datasetCreation.stepThree.sideTipContent')}</div>- </div>+ {!isMobile && <div className={cn(s.sideTip)}>+ <div className={s.tipCard}>+ <span className={s.icon} />+ <div className={s.title}>{t('datasetCreation.stepThree.sideTipTitle')}</div>+ <div className={s.content}>{t('datasetCreation.stepThree.sideTipContent')}</div></div>- )}+ </div>}</div>)}diff --git a/web/app/components/datasets/create/step-two/index.module.css b/web/app/components/datasets/create/step-two/index.module.cssindex 178cbeba857..f89d6d67ea7 100644--- a/web/app/components/datasets/create/step-two/index.module.css+++ b/web/app/components/datasets/create/step-two/index.module.css@@ -13,6 +13,18 @@z-index: 10;}+.form {+ @apply px-16 pb-8;+}++.form .label {+ @apply pt-6 pb-2 flex items-center;+ font-weight: 500;+ font-size: 16px;+ line-height: 24px;+ color: #344054;+}+.segmentationItem {min-height: 68px;}@@ -63,10 +75,6 @@cursor: pointer;}-.disabled {- cursor: not-allowed !important;-}-.indexItem.disabled:hover {background-color: #fcfcfd;border-color: #f2f4f7;@@ -79,7 +87,8 @@}.radioItem {- @apply relative mb-2 rounded-xl border border-components-option-card-option-border cursor-pointer bg-components-option-card-option-bg;+ @apply relative mb-2 rounded-xl border border-gray-100 cursor-pointer;+ background-color: #fcfcfd;}.radioItem.segmentationItem.custom {@@ -137,7 +146,7 @@}.typeIcon.economical {- background-image: url(../assets/piggy-bank-mod.svg);+ background-image: url(../assets/piggy-bank-01.svg);}.radioItem .radio {@@ -238,7 +247,7 @@}.ruleItem {- @apply flex items-center py-1.5;+ @apply flex items-center;}.formFooter {@@ -385,6 +394,19 @@max-width: 524px;}+.previewHeader {+ position: sticky;+ top: 0;+ left: 0;+ padding-top: 42px;+ background-color: #fff;+ font-weight: 600;+ font-size: 18px;+ line-height: 28px;+ color: #101828;+ z-index: 10;+}+/** `fixed` must under `previewHeader` because of style override would not work*/@@ -410,4 +432,4 @@font-size: 12px;line-height: 18px;}-}+}\ No newline at end of filediff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsxindex 0d7202967a5..f915c68fef0 100644--- a/web/app/components/datasets/create/step-two/index.tsx+++ b/web/app/components/datasets/create/step-two/index.tsx@@ -1,80 +1,65 @@'use client'-import type { FC, PropsWithChildren } from 'react'-import React, { useCallback, useEffect, useRef, useState } from 'react'+import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'+import { useBoolean } from 'ahooks'+import { XMarkIcon } from '@heroicons/react/20/solid'+import { RocketLaunchIcon } from '@heroicons/react/24/outline'import {- RiAlertFill,- RiArrowLeftLine,- RiSearchEyeLine,+ RiCloseLine,} from '@remixicon/react'import Link from 'next/link'-import Image from 'next/image'-import { useHover } from 'ahooks'-import SettingCog from '../assets/setting-gear-mod.svg'-import OrangeEffect from '../assets/option-card-effect-orange.svg'-import FamilyMod from '../assets/family-mod.svg'-import Note from '../assets/note-mod.svg'-import FileList from '../assets/file-list-3-fill.svg'-import { indexMethodIcon } from '../icons'-import { PreviewContainer } from '../../preview/container'-import { ChunkContainer, QAPreview } from '../../chunk'-import { PreviewHeader } from '../../preview/header'-import { FormattedText } from '../../formatted-text/formatted'-import { PreviewSlice } from '../../formatted-text/flavours/preview-slice'-import PreviewDocumentPicker from '../../common/document-picker/preview-document-picker'+import { groupBy } from 'lodash-es'+import PreviewItem, { PreviewType } from './preview-item'+import LanguageSelect from './language-select'import s from './index.module.css'import unescape from './unescape'import escape from './escape'-import { OptionCard } from './option-card'-import LanguageSelect from './language-select'-import { DelimiterInput, MaxLengthInput, OverlapInput } from './inputs'import cn from '@/utils/classnames'-import type { CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, DocumentItem, FullDocumentDetail, ParentMode, PreProcessingRule, ProcessRule, Rules, createDocumentResponse } from '@/models/datasets'-+import type { CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, FileIndexingEstimateResponse, FullDocumentDetail, IndexingEstimateParams, NotionInfo, PreProcessingRule, ProcessRule, Rules, createDocumentResponse } from '@/models/datasets'+import {+ createDocument,+ createFirstDocument,+ fetchFileIndexingEstimate as didFetchFileIndexingEstimate,+ fetchDefaultProcessRule,+} from '@/service/datasets'import Button from '@/app/components/base/button'+import Input from '@/app/components/base/input'+import Loading from '@/app/components/base/loading'import FloatRightContainer from '@/app/components/base/float-right-container'import RetrievalMethodConfig from '@/app/components/datasets/common/retrieval-method-config'import EconomicalRetrievalMethodConfig from '@/app/components/datasets/common/economical-retrieval-method-config'import { type RetrievalConfig } from '@/types/app'import { ensureRerankModelSelected, isReRankModelSelected } from '@/app/components/datasets/common/check-rerank-model'import Toast from '@/app/components/base/toast'+import { formatNumber } from '@/utils/format'import type { NotionPage } from '@/models/common'import { DataSourceProvider } from '@/models/common'-import { ChunkingMode, DataSourceType, RerankingModeEnum } from '@/models/datasets'+import { DataSourceType, DocForm } from '@/models/datasets'+import NotionIcon from '@/app/components/base/notion-icon'+import Switch from '@/app/components/base/switch'+import { MessageChatSquare } from '@/app/components/base/icons/src/public/common'import { useDatasetDetailContext } from '@/context/dataset-detail'import I18n from '@/context/i18n'+import { IS_CE_EDITION } from '@/config'import { RETRIEVE_METHOD } from '@/types/app'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'+import Tooltip from '@/app/components/base/tooltip'import { useDefaultModel, useModelList, useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'import { LanguagesSupported } from '@/i18n/language'import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'-import Checkbox from '@/app/components/base/checkbox'-import RadioCard from '@/app/components/base/radio-card'-import { IS_CE_EDITION } from '@/config'-import Divider from '@/app/components/base/divider'-import { getNotionInfo, getWebsiteInfo, useCreateDocument, useCreateFirstDocument, useFetchDefaultProcessRule, useFetchFileIndexingEstimateForFile, useFetchFileIndexingEstimateForNotion, useFetchFileIndexingEstimateForWeb } from '@/service/knowledge/use-create-dataset'-import Badge from '@/app/components/base/badge'-import { SkeletonContainer, SkeletonPoint, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton'-import Tooltip from '@/app/components/base/tooltip'-import CustomDialog from '@/app/components/base/dialog'-import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'-import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'--const TextLabel: FC<PropsWithChildren> = (props) => {- return <label className='text-text-secondary system-sm-semibold'>{props.children}</label>-}+import { Globe01 } from '@/app/components/base/icons/src/vender/line/mapsAndTravel'+type ValueOf<T> = T[keyof T]type StepTwoProps = {isSetting?: booleandocumentDetail?: FullDocumentDetailisAPIKeySet: booleanonSetting: () => voiddatasetId?: string- indexingType?: IndexingType- retrievalMethod?: string+ indexingType?: ValueOf<IndexingType>dataSourceType: DataSourceTypefiles: CustomFile[]notionPages?: NotionPage[]@@ -84,48 +69,21 @@ type StepTwoProps = {websiteCrawlJobId?: stringonStepChange?: (delta: number) => voidupdateIndexingTypeCache?: (type: string) => void- updateRetrievalMethodCache?: (method: string) => voidupdateResultCache?: (res: createDocumentResponse) => voidonSave?: () => voidonCancel?: () => void}-export enum SegmentType {+enum SegmentType {AUTO = 'automatic',CUSTOM = 'custom',}-export enum IndexingType {+enum IndexingType {QUALIFIED = 'high_quality',ECONOMICAL = 'economy',}const DEFAULT_SEGMENT_IDENTIFIER = '\\n\\n'-const DEFAULT_MAXMIMUM_CHUNK_LENGTH = 500-const DEFAULT_OVERLAP = 50--type ParentChildConfig = {- chunkForContext: ParentMode- parent: {- delimiter: string- maxLength: number- }- child: {- delimiter: string- maxLength: number- }-}--const defaultParentChildConfig: ParentChildConfig = {- chunkForContext: 'paragraph',- parent: {- delimiter: '\\n\\n',- maxLength: 500,- },- child: {- delimiter: '\\n',- maxLength: 200,- },-}const StepTwo = ({isSetting,@@ -146,7 +104,6 @@ const StepTwo = ({updateResultCache,onSave,onCancel,- updateRetrievalMethodCache,}: StepTwoProps) => {const { t } = useTranslation()const { locale } = useContext(I18n)@@ -154,166 +111,66 @@ const StepTwo = ({const isMobile = media === MediaType.mobileconst { dataset: currentDataset, mutateDatasetRes } = useDatasetDetailContext()-- const isInUpload = Boolean(currentDataset)- const isUploadInEmptyDataset = isInUpload && !currentDataset?.doc_form- const isNotUploadInEmptyDataset = !isUploadInEmptyDataset- const isInInit = !isInUpload && !isSetting-const isInCreatePage = !datasetId || (datasetId && !currentDataset?.data_source_type)const dataSourceType = isInCreatePage ? inCreatePageDataSourceType : currentDataset?.data_source_type- const [segmentationType, setSegmentationType] = useState<SegmentType>(SegmentType.CUSTOM)+ const scrollRef = useRef<HTMLDivElement>(null)+ const [scrolled, setScrolled] = useState(false)+ const previewScrollRef = useRef<HTMLDivElement>(null)+ const [previewScrolled, setPreviewScrolled] = useState(false)+ const [segmentationType, setSegmentationType] = useState<SegmentType>(SegmentType.AUTO)const [segmentIdentifier, doSetSegmentIdentifier] = useState(DEFAULT_SEGMENT_IDENTIFIER)- const setSegmentIdentifier = useCallback((value: string, canEmpty?: boolean) => {- doSetSegmentIdentifier(value ? escape(value) : (canEmpty ? '' : DEFAULT_SEGMENT_IDENTIFIER))+ const setSegmentIdentifier = useCallback((value: string) => {+ doSetSegmentIdentifier(value ? escape(value) : DEFAULT_SEGMENT_IDENTIFIER)}, [])- const [maxChunkLength, setMaxChunkLength] = useState(DEFAULT_MAXMIMUM_CHUNK_LENGTH) // default chunk length+ const [maxChunkLength, setMaxChunkLength] = useState(4000) // default chunk lengthconst [limitMaxChunkLength, setLimitMaxChunkLength] = useState(4000)- const [overlap, setOverlap] = useState(DEFAULT_OVERLAP)+ const [overlap, setOverlap] = useState(50)const [rules, setRules] = useState<PreProcessingRule[]>([])const [defaultConfig, setDefaultConfig] = useState<Rules>()const hasSetIndexType = !!indexingType- const [indexType, setIndexType] = useState<IndexingType>(+ const [indexType, setIndexType] = useState<ValueOf<IndexingType>>((indexingType|| isAPIKeySet)? IndexingType.QUALIFIED: IndexingType.ECONOMICAL,)-- const [previewFile, setPreviewFile] = useState<DocumentItem>(- (datasetId && documentDetail)- ? documentDetail.file- : files[0],- )- const [previewNotionPage, setPreviewNotionPage] = useState<NotionPage>(- (datasetId && documentDetail)- ? documentDetail.notion_page- : notionPages[0],- )-- const [previewWebsitePage, setPreviewWebsitePage] = useState<CrawlResultItem>(- (datasetId && documentDetail)- ? documentDetail.website_page- : websitePages[0],- )-- // QA Related- const [isLanguageSelectDisabled, _setIsLanguageSelectDisabled] = useState(false)- const [isQAConfirmDialogOpen, setIsQAConfirmDialogOpen] = useState(false)- const [docForm, setDocForm] = useState<ChunkingMode>(- (datasetId && documentDetail) ? documentDetail.doc_form as ChunkingMode : ChunkingMode.text,+ const [isLanguageSelectDisabled, setIsLanguageSelectDisabled] = useState(false)+ const [docForm, setDocForm] = useState<DocForm | string>(+ (datasetId && documentDetail) ? documentDetail.doc_form : DocForm.TEXT,)- const handleChangeDocform = (value: ChunkingMode) => {- if (value === ChunkingMode.qa && indexType === IndexingType.ECONOMICAL) {- setIsQAConfirmDialogOpen(true)- return- }- if (value === ChunkingMode.parentChild && indexType === IndexingType.ECONOMICAL)- setIndexType(IndexingType.QUALIFIED)- setDocForm(value)- // eslint-disable-next-line @typescript-eslint/no-use-before-define- currentEstimateMutation.reset()- }-const [docLanguage, setDocLanguage] = useState<string>((datasetId && documentDetail) ? documentDetail.doc_language : (locale !== LanguagesSupported[1] ? 'English' : 'Chinese'),)+ const [QATipHide, setQATipHide] = useState(false)+ const [previewSwitched, setPreviewSwitched] = useState(false)+ const [showPreview, { setTrue: setShowPreview, setFalse: hidePreview }] = useBoolean()+ const [customFileIndexingEstimate, setCustomFileIndexingEstimate] = useState<FileIndexingEstimateResponse | null>(null)+ const [automaticFileIndexingEstimate, setAutomaticFileIndexingEstimate] = useState<FileIndexingEstimateResponse | null>(null)- const [parentChildConfig, setParentChildConfig] = useState<ParentChildConfig>(defaultParentChildConfig)+ const fileIndexingEstimate = (() => {+ return segmentationType === SegmentType.AUTO ? automaticFileIndexingEstimate : customFileIndexingEstimate+ })()+ const [isCreating, setIsCreating] = useState(false)- const getIndexing_technique = () => indexingType || indexType- const currentDocForm = currentDataset?.doc_form || docForm+ const scrollHandle = (e: Event) => {+ if ((e.target as HTMLDivElement).scrollTop > 0)+ setScrolled(true)- const getProcessRule = (): ProcessRule => {- if (currentDocForm === ChunkingMode.parentChild) {- return {- rules: {- pre_processing_rules: rules,- segmentation: {- separator: unescape(- parentChildConfig.parent.delimiter,- ),- max_tokens: parentChildConfig.parent.maxLength,- },- parent_mode: parentChildConfig.chunkForContext,- subchunk_segmentation: {- separator: unescape(parentChildConfig.child.delimiter),- max_tokens: parentChildConfig.child.maxLength,- },- },- mode: 'hierarchical',- } as ProcessRule- }- return {- rules: {- pre_processing_rules: rules,- segmentation: {- separator: unescape(segmentIdentifier),- max_tokens: maxChunkLength,- chunk_overlap: overlap,- },- }, // api will check this. It will be removed after api refactored.- mode: segmentationType,- } as ProcessRule+ else+ setScrolled(false)}- const fileIndexingEstimateQuery = useFetchFileIndexingEstimateForFile({- docForm: currentDocForm,- docLanguage,- dataSourceType: DataSourceType.FILE,- files: previewFile- ? [files.find(file => file.name === previewFile.name)!]- : files,- indexingTechnique: getIndexing_technique() as any,- processRule: getProcessRule(),- dataset_id: datasetId!,- })- const notionIndexingEstimateQuery = useFetchFileIndexingEstimateForNotion({- docForm: currentDocForm,- docLanguage,- dataSourceType: DataSourceType.NOTION,- notionPages: [previewNotionPage],- indexingTechnique: getIndexing_technique() as any,- processRule: getProcessRule(),- dataset_id: datasetId || '',- })-- const websiteIndexingEstimateQuery = useFetchFileIndexingEstimateForWeb({- docForm: currentDocForm,- docLanguage,- dataSourceType: DataSourceType.WEB,- websitePages: [previewWebsitePage],- crawlOptions,- websiteCrawlProvider,- websiteCrawlJobId,- indexingTechnique: getIndexing_technique() as any,- processRule: getProcessRule(),- dataset_id: datasetId || '',- })-- const currentEstimateMutation = dataSourceType === DataSourceType.FILE- ? fileIndexingEstimateQuery- : dataSourceType === DataSourceType.NOTION- ? notionIndexingEstimateQuery- : websiteIndexingEstimateQuery-- const fetchEstimate = useCallback(() => {- if (dataSourceType === DataSourceType.FILE)- fileIndexingEstimateQuery.mutate()-- if (dataSourceType === DataSourceType.NOTION)- notionIndexingEstimateQuery.mutate()+ const previewScrollHandle = (e: Event) => {+ if ((e.target as HTMLDivElement).scrollTop > 0)+ setPreviewScrolled(true)- if (dataSourceType === DataSourceType.WEB)- websiteIndexingEstimateQuery.mutate()- }, [dataSourceType, fileIndexingEstimateQuery, notionIndexingEstimateQuery, websiteIndexingEstimateQuery])-- const estimate- = dataSourceType === DataSourceType.FILE- ? fileIndexingEstimateQuery.data- : dataSourceType === DataSourceType.NOTION- ? notionIndexingEstimateQuery.data- : websiteIndexingEstimateQuery.data+ else+ setPreviewScrolled(false)+ }+ const getFileName = (name: string) => {+ const arr = name.split('.')+ return arr.slice(0, -1).join('.')+ }const getRuleName = (key: string) => {if (key === 'remove_extra_spaces')@@ -341,20 +198,128 @@ const StepTwo = ({if (defaultConfig) {setSegmentIdentifier(defaultConfig.segmentation.separator)setMaxChunkLength(defaultConfig.segmentation.max_tokens)- setOverlap(defaultConfig.segmentation.chunk_overlap!)+ setOverlap(defaultConfig.segmentation.chunk_overlap)setRules(defaultConfig.pre_processing_rules)}- setParentChildConfig(defaultParentChildConfig)}- const updatePreview = () => {- if (segmentationType === SegmentType.CUSTOM && maxChunkLength > 4000) {- Toast.notify({ type: 'error', message: t('datasetCreation.stepTwo.maxLengthCheck') })+ const fetchFileIndexingEstimate = async (docForm = DocForm.TEXT, language?: string) => {+ // eslint-disable-next-line @typescript-eslint/no-use-before-define+ const res = await didFetchFileIndexingEstimate(getFileIndexingEstimateParams(docForm, language)!)+ if (segmentationType === SegmentType.CUSTOM)+ setCustomFileIndexingEstimate(res)+ else+ setAutomaticFileIndexingEstimate(res)+ }++ const confirmChangeCustomConfig = () => {+ if (segmentationType === SegmentType.CUSTOM && maxChunkLength > limitMaxChunkLength) {+ Toast.notify({ type: 'error', message: t('datasetCreation.stepTwo.maxLengthCheck', { limit: limitMaxChunkLength }) })return}- fetchEstimate()+ setCustomFileIndexingEstimate(null)+ setShowPreview()+ fetchFileIndexingEstimate()+ setPreviewSwitched(false)+ }++ const getIndexing_technique = () => indexingType || indexType++ const getProcessRule = () => {+ const processRule: ProcessRule = {+ rules: {} as any, // api will check this. It will be removed after api refactored.+ mode: segmentationType,+ }+ if (segmentationType === SegmentType.CUSTOM) {+ const ruleObj = {+ pre_processing_rules: rules,+ segmentation: {+ separator: unescape(segmentIdentifier),+ max_tokens: maxChunkLength,+ chunk_overlap: overlap,+ },+ }+ processRule.rules = ruleObj+ }+ return processRule+ }++ const getNotionInfo = () => {+ const workspacesMap = groupBy(notionPages, 'workspace_id')+ const workspaces = Object.keys(workspacesMap).map((workspaceId) => {+ return {+ workspaceId,+ pages: workspacesMap[workspaceId],+ }+ })+ return workspaces.map((workspace) => {+ return {+ workspace_id: workspace.workspaceId,+ pages: workspace.pages.map((page) => {+ const { page_id, page_name, page_icon, type } = page+ return {+ page_id,+ page_name,+ page_icon,+ type,+ }+ }),+ }+ }) as NotionInfo[]+ }++ const getWebsiteInfo = () => {+ return {+ provider: websiteCrawlProvider,+ job_id: websiteCrawlJobId,+ urls: websitePages.map(page => page.source_url),+ only_main_content: crawlOptions?.only_main_content,+ }}+ const getFileIndexingEstimateParams = (docForm: DocForm, language?: string): IndexingEstimateParams | undefined => {+ if (dataSourceType === DataSourceType.FILE) {+ return {+ info_list: {+ data_source_type: dataSourceType,+ file_info_list: {+ file_ids: files.map(file => file.id) as string[],+ },+ },+ indexing_technique: getIndexing_technique() as string,+ process_rule: getProcessRule(),+ doc_form: docForm,+ doc_language: language || docLanguage,+ dataset_id: datasetId as string,+ }+ }+ if (dataSourceType === DataSourceType.NOTION) {+ return {+ info_list: {+ data_source_type: dataSourceType,+ notion_info_list: getNotionInfo(),+ },+ indexing_technique: getIndexing_technique() as string,+ process_rule: getProcessRule(),+ doc_form: docForm,+ doc_language: language || docLanguage,+ dataset_id: datasetId as string,+ }+ }+ if (dataSourceType === DataSourceType.WEB) {+ return {+ info_list: {+ data_source_type: dataSourceType,+ website_info_list: getWebsiteInfo(),+ },+ indexing_technique: getIndexing_technique() as string,+ process_rule: getProcessRule(),+ doc_form: docForm,+ doc_language: language || docLanguage,+ dataset_id: datasetId as string,+ }+ }+ }const {modelList: rerankModelList,defaultModel: rerankDefaultModel,@@ -386,14 +351,13 @@ const StepTwo = ({if (isSetting) {params = {original_document_id: documentDetail?.id,- doc_form: currentDocForm,+ doc_form: docForm,doc_language: docLanguage,process_rule: getProcessRule(),// eslint-disable-next-line @typescript-eslint/no-use-before-defineretrieval_model: retrievalConfig, // Readonly. If want to changed, just go to settings page.embedding_model: embeddingModel.model, // Readonlyembedding_model_provider: embeddingModel.provider, // Readonly- indexing_technique: getIndexing_technique(),} as CreateDocumentReq}else { // create@@ -413,12 +377,8 @@ const StepTwo = ({}const postRetrievalConfig = ensureRerankModelSelected({rerankDefaultModel: rerankDefaultModel!,- retrievalConfig: {- // eslint-disable-next-line @typescript-eslint/no-use-before-define- ...retrievalConfig,- // eslint-disable-next-line @typescript-eslint/no-use-before-define- reranking_enable: retrievalConfig.reranking_mode === RerankingModeEnum.RerankingModel,- },+ // eslint-disable-next-line @typescript-eslint/no-use-before-define+ retrievalConfig,indexMethod: indexMethod as string,})params = {@@ -430,7 +390,7 @@ const StepTwo = ({},indexing_technique: getIndexing_technique(),process_rule: getProcessRule(),- doc_form: currentDocForm,+ doc_form: docForm,doc_language: docLanguage,retrieval_model: postRetrievalConfig,@@ -443,36 +403,29 @@ const StepTwo = ({}}if (dataSourceType === DataSourceType.NOTION)- params.data_source.info_list.notion_info_list = getNotionInfo(notionPages)+ params.data_source.info_list.notion_info_list = getNotionInfo()- if (dataSourceType === DataSourceType.WEB) {- params.data_source.info_list.website_info_list = getWebsiteInfo({- websiteCrawlProvider,- websiteCrawlJobId,- websitePages,- })- }+ if (dataSourceType === DataSourceType.WEB)+ params.data_source.info_list.website_info_list = getWebsiteInfo()}return params}- const fetchDefaultProcessRuleMutation = useFetchDefaultProcessRule({- onSuccess(data) {- const separator = data.rules.segmentation.separator+ const getRules = async () => {+ try {+ const res = await fetchDefaultProcessRule({ url: '/datasets/process-rule' })+ const separator = res.rules.segmentation.separatorsetSegmentIdentifier(separator)- setMaxChunkLength(data.rules.segmentation.max_tokens)- setOverlap(data.rules.segmentation.chunk_overlap!)- setRules(data.rules.pre_processing_rules)- setDefaultConfig(data.rules)- setLimitMaxChunkLength(data.limits.indexing_max_segmentation_tokens_length)- },- onError(error) {- Toast.notify({- type: 'error',- message: `${error}`,- })- },- })+ setMaxChunkLength(res.rules.segmentation.max_tokens)+ setLimitMaxChunkLength(res.limits.indexing_max_segmentation_tokens_length)+ setOverlap(res.rules.segmentation.chunk_overlap)+ setRules(res.rules.pre_processing_rules)+ setDefaultConfig(res.rules)+ }+ catch (err) {+ console.log(err)+ }+ }const getRulesFromDetail = () => {if (documentDetail) {@@ -482,7 +435,7 @@ const StepTwo = ({const overlap = rules.segmentation.chunk_overlapsetSegmentIdentifier(separator)setMaxChunkLength(max)- setOverlap(overlap!)+ setOverlap(overlap)setRules(rules.pre_processing_rules)setDefaultConfig(rules)}@@ -490,81 +443,119 @@ const StepTwo = ({const getDefaultMode = () => {if (documentDetail)- // @ts-expect-error fix after api refactoredsetSegmentationType(documentDetail.dataset_process_rule.mode)}- const createFirstDocumentMutation = useCreateFirstDocument({- onError(error) {- Toast.notify({- type: 'error',- message: `${error}`,- })- },- })- const createDocumentMutation = useCreateDocument(datasetId!, {- onError(error) {+ const createHandle = async () => {+ if (isCreating)+ return+ setIsCreating(true)+ try {+ let res+ const params = getCreationParams()+ if (!params)+ return false++ setIsCreating(true)+ if (!datasetId) {+ res = await createFirstDocument({+ body: params as CreateDocumentReq,+ })+ updateIndexingTypeCache && updateIndexingTypeCache(indexType as string)+ updateResultCache && updateResultCache(res)+ }+ else {+ res = await createDocument({+ datasetId,+ body: params as CreateDocumentReq,+ })+ updateIndexingTypeCache && updateIndexingTypeCache(indexType as string)+ updateResultCache && updateResultCache(res)+ }+ if (mutateDatasetRes)+ mutateDatasetRes()+ onStepChange && onStepChange(+1)+ isSetting && onSave && onSave()+ }+ catch (err) {Toast.notify({type: 'error',- message: `${error}`,+ message: `${err}`,})- },- })-- const isCreating = createFirstDocumentMutation.isPending || createDocumentMutation.isPending+ }+ finally {+ setIsCreating(false)+ }+ }- const createHandle = async () => {- const params = getCreationParams()- if (!params)- return false+ const handleSwitch = (state: boolean) => {+ if (state)+ setDocForm(DocForm.QA)+ else+ setDocForm(DocForm.TEXT)+ }- if (!datasetId) {- await createFirstDocumentMutation.mutateAsync(- params,- {- onSuccess(data) {- updateIndexingTypeCache && updateIndexingTypeCache(indexType as string)- updateResultCache && updateResultCache(data)- // eslint-disable-next-line @typescript-eslint/no-use-before-define- updateRetrievalMethodCache && updateRetrievalMethodCache(retrievalConfig.search_method as string)- },- },- )+ const previewSwitch = async (language?: string) => {+ setPreviewSwitched(true)+ setIsLanguageSelectDisabled(true)+ if (segmentationType === SegmentType.AUTO)+ setAutomaticFileIndexingEstimate(null)+ else+ setCustomFileIndexingEstimate(null)+ try {+ await fetchFileIndexingEstimate(DocForm.QA, language)}- else {- await createDocumentMutation.mutateAsync(params, {- onSuccess(data) {- updateIndexingTypeCache && updateIndexingTypeCache(indexType as string)- updateResultCache && updateResultCache(data)- },- })+ finally {+ setIsLanguageSelectDisabled(false)}- if (mutateDatasetRes)- mutateDatasetRes()- onStepChange && onStepChange(+1)- isSetting && onSave && onSave()}- const changeToEconomicalType = () => {- if (docForm !== ChunkingMode.text)- return+ const handleSelect = (language: string) => {+ setDocLanguage(language)+ // Switch language, re-cutter+ if (docForm === DocForm.QA && previewSwitched)+ previewSwitch(language)+ }- if (!hasSetIndexType)+ const changeToEconomicalType = () => {+ if (!hasSetIndexType) {setIndexType(IndexingType.ECONOMICAL)+ setDocForm(DocForm.TEXT)+ }}useEffect(() => {// fetch rulesif (!isSetting) {- fetchDefaultProcessRuleMutation.mutate('/datasets/process-rule')+ getRules()}else {getRulesFromDetail()getDefaultMode()}- // eslint-disable-next-line react-hooks/exhaustive-deps}, [])+ useEffect(() => {+ scrollRef.current?.addEventListener('scroll', scrollHandle)+ return () => {+ scrollRef.current?.removeEventListener('scroll', scrollHandle)+ }+ }, [])++ useLayoutEffect(() => {+ if (showPreview) {+ previewScrollRef.current?.addEventListener('scroll', previewScrollHandle)+ return () => {+ previewScrollRef.current?.removeEventListener('scroll', previewScrollHandle)+ }+ }+ }, [showPreview])++ useEffect(() => {+ if (indexingType === IndexingType.ECONOMICAL && docForm === DocForm.QA)+ setDocForm(DocForm.TEXT)+ }, [indexingType, docForm])+useEffect(() => {// get indexing type by propsif (indexingType)@@ -574,6 +565,20 @@ const StepTwo = ({setIndexType(isAPIKeySet ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL)}, [isAPIKeySet, indexingType, datasetId])+ useEffect(() => {+ if (segmentationType === SegmentType.AUTO) {+ setAutomaticFileIndexingEstimate(null)+ !isMobile && setShowPreview()+ fetchFileIndexingEstimate()+ setPreviewSwitched(false)+ }+ else {+ hidePreview()+ setCustomFileIndexingEstimate(null)+ setPreviewSwitched(false)+ }+ }, [segmentationType, indexType])+const [retrievalConfig, setRetrievalConfig] = useState(currentDataset?.retrieval_model_dict || {search_method: RETRIEVE_METHOD.semantic,reranking_enable: false,@@ -586,589 +591,433 @@ const StepTwo = ({score_threshold: 0.5,} as RetrievalConfig)- const economyDomRef = useRef<HTMLDivElement>(null)- const isHoveringEconomy = useHover(economyDomRef)-return (<div className='flex w-full h-full'>- <div className={cn('relative h-full w-1/2 py-6 overflow-y-auto', isMobile ? 'px-4' : 'px-12')}>- <div className={'system-md-semibold mb-1'}>{t('datasetCreation.stepTwo.segmentation')}</div>- {((isInUpload && [ChunkingMode.text, ChunkingMode.qa].includes(currentDataset!.doc_form))- || isUploadInEmptyDataset- || isInInit)- && <OptionCard- className='bg-background-section mb-2'- title={t('datasetCreation.stepTwo.general')}- icon={<Image width={20} height={20} src={SettingCog} alt={t('datasetCreation.stepTwo.general')} />}- activeHeaderClassName='bg-dataset-option-card-blue-gradient'- description={t('datasetCreation.stepTwo.generalTip')}- isActive={- [ChunkingMode.text, ChunkingMode.qa].includes(currentDocForm)- }- onSwitched={() =>- handleChangeDocform(ChunkingMode.text)- }- actions={- <>- <Button variant={'secondary-accent'} onClick={() => updatePreview()}>- <RiSearchEyeLine className='h-4 w-4 mr-0.5' />- {t('datasetCreation.stepTwo.previewChunk')}- </Button>- <Button variant={'ghost'} onClick={resetRules}>- {t('datasetCreation.stepTwo.reset')}- </Button>- </>- }- noHighlight={isInUpload && isNotUploadInEmptyDataset}- >- <div className='flex flex-col gap-y-4'>- <div className='flex gap-3'>- <DelimiterInput- value={segmentIdentifier}- onChange={e => setSegmentIdentifier(e.target.value, true)}- />- <MaxLengthInput- unit='tokens'- value={maxChunkLength}- onChange={setMaxChunkLength}- />- <OverlapInput- unit='tokens'- value={overlap}- min={1}- onChange={setOverlap}- />+ <div ref={scrollRef} className='relative h-full w-full overflow-y-scroll'>+ <div className={cn(s.pageHeader, scrolled && s.fixed, isMobile && '!px-6')}>+ <span>{t('datasetCreation.steps.two')}</span>+ {(isMobile || !showPreview) && (+ <Button+ className='border-[0.5px] !h-8 hover:outline hover:outline-[0.5px] hover:outline-gray-300 text-gray-700 font-medium bg-white shadow-[0px_1px_2px_0px_rgba(16,24,40,0.05)]'+ onClick={setShowPreview}+ >+ <Tooltip>+ <div className="flex flex-row items-center">+ <RocketLaunchIcon className="h-4 w-4 mr-1.5 stroke-[1.8px]" />+ <span className="text-[13px]">{t('datasetCreation.stepTwo.previewTitleButton')}</span>+ </div>+ </Tooltip>+ </Button>+ )}+ </div>+ <div className={cn(s.form, isMobile && '!px-4')}>+ <div className={s.label}>{t('datasetCreation.stepTwo.segmentation')}</div>+ <div className='max-w-[640px]'>+ <div+ className={cn(+ s.radioItem,+ s.segmentationItem,+ segmentationType === SegmentType.AUTO && s.active,+ )}+ onClick={() => setSegmentationType(SegmentType.AUTO)}+ >+ <span className={cn(s.typeIcon, s.auto)} />+ <span className={cn(s.radio)} />+ <div className={s.typeHeader}>+ <div className={s.title}>{t('datasetCreation.stepTwo.auto')}</div>+ <div className={s.tip}>{t('datasetCreation.stepTwo.autoDescription')}</div></div>- <div className='w-full flex flex-col'>- <div className='flex items-center gap-x-2'>- <div className='inline-flex shrink-0'>- <TextLabel>{t('datasetCreation.stepTwo.rules')}</TextLabel>+ </div>+ <div+ className={cn(+ s.radioItem,+ s.segmentationItem,+ segmentationType === SegmentType.CUSTOM && s.active,+ segmentationType === SegmentType.CUSTOM && s.custom,+ )}+ onClick={() => setSegmentationType(SegmentType.CUSTOM)}+ >+ <span className={cn(s.typeIcon, s.customize)} />+ <span className={cn(s.radio)} />+ <div className={s.typeHeader}>+ <div className={s.title}>{t('datasetCreation.stepTwo.custom')}</div>+ <div className={s.tip}>{t('datasetCreation.stepTwo.customDescription')}</div>+ </div>+ {segmentationType === SegmentType.CUSTOM && (+ <div className={s.typeFormBody}>+ <div className={s.formRow}>+ <div className='w-full'>+ <div className={s.label}>+ {t('datasetCreation.stepTwo.separator')}+ <Tooltip+ popupContent={+ <div className='max-w-[200px]'>+ {t('datasetCreation.stepTwo.separatorTip')}+ </div>+ }+ />+ </div>+ <Input+ type="text"+ className='h-9'+ placeholder={t('datasetCreation.stepTwo.separatorPlaceholder') || ''} value={segmentIdentifier}+ onChange={e => setSegmentIdentifier(e.target.value)}+ />+ </div></div>- <Divider className='grow' bgStyle='gradient' />- </div>- <div className='mt-1'>- {rules.map(rule => (- <div key={rule.id} className={s.ruleItem} onClick={() => {- ruleChangeHandle(rule.id)- }}>- <Checkbox- checked={rule.enabled}+ <div className={s.formRow}>+ <div className='w-full'>+ <div className={s.label}>{t('datasetCreation.stepTwo.maxLength')}</div>+ <Input+ type="number"+ className='h-9'+ placeholder={t('datasetCreation.stepTwo.maxLength') || ''}+ value={maxChunkLength}+ max={limitMaxChunkLength}+ min={1}+ onChange={e => setMaxChunkLength(parseInt(e.target.value.replace(/^0+/, ''), 10))}/>- <label className="ml-2 system-sm-regular cursor-pointer text-text-secondary">{getRuleName(rule.id)}</label></div>- ))}- {IS_CE_EDITION && <>- <Divider type='horizontal' className='my-4 bg-divider-subtle' />- <div className='flex items-center py-0.5'>- <div className='flex items-center' onClick={() => {- if (currentDataset?.doc_form)- return- if (docForm === ChunkingMode.qa)- handleChangeDocform(ChunkingMode.text)- else- handleChangeDocform(ChunkingMode.qa)- }}>- <Checkbox- checked={currentDocForm === ChunkingMode.qa}- disabled={!!currentDataset?.doc_form}+ </div>+ <div className={s.formRow}>+ <div className='w-full'>+ <div className={s.label}>+ {t('datasetCreation.stepTwo.overlap')}+ <Tooltip+ popupContent={+ <div className='max-w-[200px]'>+ {t('datasetCreation.stepTwo.overlapTip')}+ </div>+ }/>- <label className="ml-2 system-sm-regular cursor-pointer text-text-secondary">- {t('datasetCreation.stepTwo.useQALanguage')}- </label></div>- <LanguageSelect- currentLanguage={docLanguage || locale}- onSelect={setDocLanguage}- disabled={currentDocForm !== ChunkingMode.qa}+ <Input+ type="number"+ className='h-9'+ placeholder={t('datasetCreation.stepTwo.overlap') || ''}+ value={overlap}+ min={1}+ onChange={e => setOverlap(parseInt(e.target.value.replace(/^0+/, ''), 10))}/>- <Tooltip popupContent={t('datasetCreation.stepTwo.QATip')} /></div>- {currentDocForm === ChunkingMode.qa && (- <div- style={{- background: 'linear-gradient(92deg, rgba(247, 144, 9, 0.1) 0%, rgba(255, 255, 255, 0.00) 100%)',- }}- className='h-10 mt-2 flex items-center gap-2 rounded-xl backdrop-blur-[5px] border-components-panel-border border shadow-xs px-3 text-xs'- >- <RiAlertFill className='size-4 text-text-warning-secondary' />- <span className='system-xs-medium text-text-primary'>- {t('datasetCreation.stepTwo.QATip')}- </span>- </div>- )}- </>}- </div>- </div>- </div>- </OptionCard>}- {- (- (isInUpload && currentDataset!.doc_form === ChunkingMode.parentChild)- || isUploadInEmptyDataset- || isInInit- )- && <OptionCard- title={t('datasetCreation.stepTwo.parentChild')}- icon={<Image width={20} height={20} src={FamilyMod} alt={t('datasetCreation.stepTwo.parentChild')} />}- effectImg={OrangeEffect.src}- activeHeaderClassName='bg-dataset-option-card-orange-gradient'- description={t('datasetCreation.stepTwo.parentChildTip')}- isActive={currentDocForm === ChunkingMode.parentChild}- onSwitched={() => handleChangeDocform(ChunkingMode.parentChild)}- actions={- <>- <Button variant={'secondary-accent'} onClick={() => updatePreview()}>- <RiSearchEyeLine className='h-4 w-4 mr-0.5' />- {t('datasetCreation.stepTwo.previewChunk')}- </Button>- <Button variant={'ghost'} onClick={resetRules}>- {t('datasetCreation.stepTwo.reset')}- </Button>- </>- }- noHighlight={isInUpload && isNotUploadInEmptyDataset}- >- <div className='flex flex-col gap-4'>- <div>- <div className='flex items-center gap-x-2'>- <div className='inline-flex shrink-0'>- <TextLabel>{t('datasetCreation.stepTwo.parentChunkForContext')}</TextLabel></div>- <Divider className='grow' bgStyle='gradient' />- </div>- <RadioCard className='mt-1'- icon={<Image src={Note} alt='' />}- title={t('datasetCreation.stepTwo.paragraph')}- description={t('datasetCreation.stepTwo.paragraphTip')}- isChosen={parentChildConfig.chunkForContext === 'paragraph'}- onChosen={() => setParentChildConfig(- {- ...parentChildConfig,- chunkForContext: 'paragraph',- },- )}- chosenConfig={- <div className='flex gap-3'>- <DelimiterInput- value={parentChildConfig.parent.delimiter}- tooltip={t('datasetCreation.stepTwo.parentChildDelimiterTip')!}- onChange={e => setParentChildConfig({- ...parentChildConfig,- parent: {- ...parentChildConfig.parent,- delimiter: e.target.value ? escape(e.target.value) : '',- },- })}- />- <MaxLengthInput- unit='tokens'- value={parentChildConfig.parent.maxLength}- onChange={value => setParentChildConfig({- ...parentChildConfig,- parent: {- ...parentChildConfig.parent,- maxLength: value,- },- })}- />+ <div className={s.formRow}>+ <div className='w-full flex flex-col gap-1'>+ <div className={s.label}>{t('datasetCreation.stepTwo.rules')}</div>+ {rules.map(rule => (+ <div key={rule.id} className={s.ruleItem}>+ <input id={rule.id} type="checkbox" checked={rule.enabled} onChange={() => ruleChangeHandle(rule.id)} className="w-4 h-4 rounded border-gray-300 text-blue-700 focus:ring-blue-700" />+ <label htmlFor={rule.id} className="ml-2 text-sm font-normal cursor-pointer text-gray-800">{getRuleName(rule.id)}</label>+ </div>+ ))}</div>- }- />- <RadioCard className='mt-2'- icon={<Image src={FileList} alt='' />}- title={t('datasetCreation.stepTwo.fullDoc')}- description={t('datasetCreation.stepTwo.fullDocTip')}- onChosen={() => setParentChildConfig(- {- ...parentChildConfig,- chunkForContext: 'full-doc',- },- )}- isChosen={parentChildConfig.chunkForContext === 'full-doc'}- />- </div>-- <div>- <div className='flex items-center gap-x-2'>- <div className='inline-flex shrink-0'>- <TextLabel>{t('datasetCreation.stepTwo.childChunkForRetrieval')}</TextLabel></div>- <Divider className='grow' bgStyle='gradient' />- </div>- <div className='flex gap-3 mt-1'>- <DelimiterInput- value={parentChildConfig.child.delimiter}- tooltip={t('datasetCreation.stepTwo.parentChildChunkDelimiterTip')!}- onChange={e => setParentChildConfig({- ...parentChildConfig,- child: {- ...parentChildConfig.child,- delimiter: e.target.value ? escape(e.target.value) : '',- },- })}- />- <MaxLengthInput- unit='tokens'- value={parentChildConfig.child.maxLength}- onChange={value => setParentChildConfig({- ...parentChildConfig,- child: {- ...parentChildConfig.child,- maxLength: value,- },- })}- />- </div>- </div>- <div>- <div className='flex items-center gap-x-2'>- <div className='inline-flex shrink-0'>- <TextLabel>{t('datasetCreation.stepTwo.rules')}</TextLabel>+ <div className={s.formFooter}>+ <Button variant="primary" className={cn(s.button)} onClick={confirmChangeCustomConfig}>{t('datasetCreation.stepTwo.preview')}</Button>+ <Button className={cn(s.button, 'ml-2')} onClick={resetRules}>{t('datasetCreation.stepTwo.reset')}</Button></div>- <Divider className='grow' bgStyle='gradient' /></div>- <div className='mt-1'>- {rules.map(rule => (- <div key={rule.id} className={s.ruleItem} onClick={() => {- ruleChangeHandle(rule.id)- }}>- <Checkbox- checked={rule.enabled}- />- <label className="ml-2 system-sm-regular cursor-pointer text-text-secondary">{getRuleName(rule.id)}</label>- </div>- ))}- </div>- </div>+ )}</div>- </OptionCard>}- <Divider className='my-5' />- <div className={'system-md-semibold mb-1'}>{t('datasetCreation.stepTwo.indexMode')}</div>- <div className='flex items-center gap-2'>- {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.QUALIFIED)) && (- <OptionCard className='flex-1'- title={<div className='flex items-center'>- {t('datasetCreation.stepTwo.qualified')}- <Badge className={cn('ml-1 h-[18px]', (!hasSetIndexType && indexType === IndexingType.QUALIFIED) ? 'border-text-accent-secondary text-text-accent-secondary' : '')} uppercase>- {t('datasetCreation.stepTwo.recommend')}- </Badge>- <span className='ml-auto'>+ </div>+ <div className={s.label}>{t('datasetCreation.stepTwo.indexMode')}</div>+ <div className='max-w-[640px]'>+ <div className='flex items-center gap-3 flex-wrap sm:flex-nowrap'>+ {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.QUALIFIED)) && (+ <div+ className={cn(+ s.radioItem,+ s.indexItem,+ !isAPIKeySet && s.disabled,+ !hasSetIndexType && indexType === IndexingType.QUALIFIED && s.active,+ hasSetIndexType && s.disabled,+ hasSetIndexType && '!w-full !min-h-[96px]',+ )}+ onClick={() => {+ if (isAPIKeySet)+ setIndexType(IndexingType.QUALIFIED)+ }}+ >+ <span className={cn(s.typeIcon, s.qualified)} />{!hasSetIndexType && <span className={cn(s.radio)} />}- </span>- </div>}- description={t('datasetCreation.stepTwo.qualifiedTip')}- icon={<Image src={indexMethodIcon.high_quality} alt='' />}- isActive={!hasSetIndexType && indexType === IndexingType.QUALIFIED}- disabled={!isAPIKeySet || hasSetIndexType}- onSwitched={() => {- if (isAPIKeySet)- setIndexType(IndexingType.QUALIFIED)- }}- />- )}-- {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.ECONOMICAL)) && (- <>- <CustomDialog show={isQAConfirmDialogOpen} onClose={() => setIsQAConfirmDialogOpen(false)} className='w-[432px]'>- <header className='pt-6 mb-4'>- <h2 className='text-lg font-semibold'>- {t('datasetCreation.stepTwo.qaSwitchHighQualityTipTitle')}- </h2>- <p className='font-normal text-sm mt-2'>- {t('datasetCreation.stepTwo.qaSwitchHighQualityTipContent')}- </p>- </header>- <div className='flex gap-2 pb-6'>- <Button className='ml-auto' onClick={() => {- setIsQAConfirmDialogOpen(false)- }}>- {t('datasetCreation.stepTwo.cancel')}- </Button>- <Button variant={'primary'} onClick={() => {- setIsQAConfirmDialogOpen(false)- setIndexType(IndexingType.QUALIFIED)- setDocForm(ChunkingMode.qa)- }}>- {t('datasetCreation.stepTwo.switch')}- </Button>+ <div className={s.typeHeader}>+ <div className={s.title}>+ {t('datasetCreation.stepTwo.qualified')}+ {!hasSetIndexType && <span className={s.recommendTag}>{t('datasetCreation.stepTwo.recommend')}</span>}+ </div>+ <div className={s.tip}>{t('datasetCreation.stepTwo.qualifiedTip')}</div>+ </div>+ {!isAPIKeySet && (+ <div className={s.warningTip}>+ <span>{t('datasetCreation.stepTwo.warning')} </span>+ <span className={s.click} onClick={onSetting}>{t('datasetCreation.stepTwo.click')}</span>+ </div>+ )}</div>- </CustomDialog>- <PortalToFollowElem- open={- isHoveringEconomy && docForm !== ChunkingMode.text- }- placement={'top'}- >- <PortalToFollowElemTrigger asChild>- <OptionCard className='flex-1'- title={t('datasetCreation.stepTwo.economical')}- description={t('datasetCreation.stepTwo.economicalTip')}- icon={<Image src={indexMethodIcon.economical} alt='' />}- isActive={!hasSetIndexType && indexType === IndexingType.ECONOMICAL}- disabled={!isAPIKeySet || hasSetIndexType || docForm !== ChunkingMode.text}- ref={economyDomRef}- onSwitched={() => {- if (isAPIKeySet && docForm === ChunkingMode.text)- setIndexType(IndexingType.ECONOMICAL)- }}- />- </PortalToFollowElemTrigger>- <PortalToFollowElemContent>- <div className='p-3 bg-components-tooltip-bg border-components-panel-border text-xs font-medium text-text-secondary rounded-lg shadow-lg'>- {- docForm === ChunkingMode.qa- ? t('datasetCreation.stepTwo.notAvailableForQA')- : t('datasetCreation.stepTwo.notAvailableForParentChild')- }+ )}++ {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.ECONOMICAL)) && (+ <div+ className={cn(+ s.radioItem,+ s.indexItem,+ !hasSetIndexType && indexType === IndexingType.ECONOMICAL && s.active,+ hasSetIndexType && s.disabled,+ hasSetIndexType && '!w-full !min-h-[96px]',+ )}+ onClick={changeToEconomicalType}+ >+ <span className={cn(s.typeIcon, s.economical)} />+ {!hasSetIndexType && <span className={cn(s.radio)} />}+ <div className={s.typeHeader}>+ <div className={s.title}>{t('datasetCreation.stepTwo.economical')}</div>+ <div className={s.tip}>{t('datasetCreation.stepTwo.economicalTip')}</div></div>- </PortalToFollowElemContent>- </PortalToFollowElem>- </>)}- </div>- {!hasSetIndexType && indexType === IndexingType.QUALIFIED && (- <div className='mt-2 h-10 p-2 flex items-center gap-x-0.5 rounded-xl border-[0.5px] border-components-panel-border overflow-hidden bg-components-panel-bg-blur backdrop-blur-[5px] shadow-xs'>- <div className='absolute top-0 left-0 right-0 bottom-0 bg-[linear-gradient(92deg,rgba(247,144,9,0.25)_0%,rgba(255,255,255,0.00)_100%)] opacity-40'></div>- <div className='p-1'>- <AlertTriangle className='size-4 text-text-warning-secondary' />+ </div>+ )}</div>- <span className='system-xs-medium'>{t('datasetCreation.stepTwo.highQualityTip')}</span>- </div>- )}- {hasSetIndexType && indexType === IndexingType.ECONOMICAL && (- <div className='mt-2 system-xs-medium'>- {t('datasetCreation.stepTwo.indexSettingTip')}- <Link className='text-text-accent' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link>- </div>- )}- {/* Embedding model */}- {indexType === IndexingType.QUALIFIED && (- <div className='mt-5'>- <div className={cn('system-md-semibold mb-1', datasetId && 'flex justify-between items-center')}>{t('datasetSettings.form.embeddingModel')}</div>- <ModelSelector- readonly={!!datasetId}- defaultModel={embeddingModel}- modelList={embeddingModelList}- onSelect={(model: DefaultModel) => {- setEmbeddingModel(model)- }}- />- {!!datasetId && (- <div className='mt-2 system-xs-medium'>+ {hasSetIndexType && indexType === IndexingType.ECONOMICAL && (+ <div className='mt-2 text-xs text-gray-500 font-medium'>{t('datasetCreation.stepTwo.indexSettingTip')}- <Link className='text-text-accent' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link>+ <Link className='text-[#155EEF]' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link></div>)}- </div>- )}- <Divider className='my-5' />- {/* Retrieval Method Config */}- <div>- {!datasetId- ? (- <div className={'mb-1'}>- <div className='system-md-semibold mb-0.5'>{t('datasetSettings.form.retrievalSetting.title')}</div>- <div className='body-xs-regular text-text-tertiary'>- <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-text-accent'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>- {t('datasetSettings.form.retrievalSetting.longDescription')}+ {IS_CE_EDITION && indexType === IndexingType.QUALIFIED && (+ <div className='mt-3 rounded-xl bg-gray-50 border border-gray-100'>+ <div className='flex justify-between items-center px-5 py-4'>+ <div className='flex justify-center items-center w-8 h-8 rounded-lg bg-indigo-50'>+ <MessageChatSquare className='w-4 h-4' />+ </div>+ <div className='grow mx-3'>+ <div className='mb-[2px] text-md font-medium text-gray-900'>{t('datasetCreation.stepTwo.QATitle')}</div>+ <div className='inline-flex items-center text-[13px] leading-[18px] text-gray-500'>+ <span className='pr-1'>{t('datasetCreation.stepTwo.QALanguage')}</span>+ <LanguageSelect currentLanguage={docLanguage} onSelect={handleSelect} disabled={isLanguageSelectDisabled} />+ </div>+ </div>+ <div className='shrink-0'>+ <Switch+ defaultValue={docForm === DocForm.QA}+ onChange={handleSwitch}+ size='md'+ />+ </div></div>+ {docForm === DocForm.QA && !QATipHide && (+ <div className='flex justify-between items-center px-5 py-2 bg-orange-50 border-t border-amber-100 rounded-b-xl text-[13px] leading-[18px] text-medium text-amber-500'>+ {t('datasetCreation.stepTwo.QATip')}+ <RiCloseLine className='w-4 h-4 text-gray-500 cursor-pointer' onClick={() => setQATipHide(true)} />+ </div>+ )}</div>- )- : (- <div className={cn('system-md-semibold mb-0.5', 'flex justify-between items-center')}>- <div>{t('datasetSettings.form.retrievalSetting.title')}</div>+ )}+ {/* Embedding model */}+ {indexType === IndexingType.QUALIFIED && (+ <div className='mb-2'>+ <div className={cn(s.label, datasetId && 'flex justify-between items-center')}>{t('datasetSettings.form.embeddingModel')}</div>+ <ModelSelector+ readonly={!!datasetId}+ defaultModel={embeddingModel}+ modelList={embeddingModelList}+ onSelect={(model: DefaultModel) => {+ setEmbeddingModel(model)+ }}+ />+ {!!datasetId && (+ <div className='mt-2 text-xs text-gray-500 font-medium'>+ {t('datasetCreation.stepTwo.indexSettingTip')}+ <Link className='text-[#155EEF]' href={`/datasets/${datasetId}/settings`}>{t('datasetCreation.stepTwo.datasetSettingLink')}</Link>+ </div>+ )}</div>)}-- <div className=''>- {- getIndexing_technique() === IndexingType.QUALIFIED+ {/* Retrieval Method Config */}+ <div>+ {!datasetId? (- <RetrievalMethodConfig- value={retrievalConfig}- onChange={setRetrievalConfig}- />+ <div className={s.label}>+ <div className='shrink-0 mr-4'>{t('datasetSettings.form.retrievalSetting.title')}</div>+ <div className='leading-[18px] text-xs font-normal text-gray-500'>+ <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-[#155eef]'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>+ {t('datasetSettings.form.retrievalSetting.longDescription')}+ </div>+ </div>): (- <EconomicalRetrievalMethodConfig- value={retrievalConfig}- onChange={setRetrievalConfig}- />- )- }- </div>- </div>+ <div className={cn(s.label, 'flex justify-between items-center')}>+ <div>{t('datasetSettings.form.retrievalSetting.title')}</div>+ </div>+ )}- {!isSetting- ? (- <div className='flex items-center mt-8 py-2'>- <Button onClick={() => onStepChange && onStepChange(-1)}>- <RiArrowLeftLine className='w-4 h-4 mr-1' />- {t('datasetCreation.stepTwo.previousStep')}- </Button>- <Button className='ml-auto' loading={isCreating} variant='primary' onClick={createHandle}>{t('datasetCreation.stepTwo.nextStep')}</Button>- </div>- )- : (- <div className='flex items-center mt-8 py-2'>- <Button loading={isCreating} variant='primary' onClick={createHandle}>{t('datasetCreation.stepTwo.save')}</Button>- <Button className='ml-2' onClick={onCancel}>{t('datasetCreation.stepTwo.cancel')}</Button>+ <div className='max-w-[640px]'>+ {+ getIndexing_technique() === IndexingType.QUALIFIED+ ? (+ <RetrievalMethodConfig+ value={retrievalConfig}+ onChange={setRetrievalConfig}+ />+ )+ : (+ <EconomicalRetrievalMethodConfig+ value={retrievalConfig}+ onChange={setRetrievalConfig}+ />+ )+ }+ </div></div>- )}- </div>- <FloatRightContainer isMobile={isMobile} isOpen={true} onClose={() => { }} footer={null}>- <PreviewContainer- header={<PreviewHeader- title={t('datasetCreation.stepTwo.preview')}- >- <div className='flex items-center gap-1'>- {dataSourceType === DataSourceType.FILE- && <PreviewDocumentPicker- files={files as Array<Required<CustomFile>>}- onChange={(selected) => {- currentEstimateMutation.reset()- setPreviewFile(selected)- currentEstimateMutation.mutate()- }}- // when it is from setting, it just has one file- value={isSetting ? (files[0]! as Required<CustomFile>) : previewFile}- />- }- {dataSourceType === DataSourceType.NOTION- && <PreviewDocumentPicker- files={- notionPages.map(page => ({- id: page.page_id,- name: page.page_name,- extension: 'md',- }))- }- onChange={(selected) => {- currentEstimateMutation.reset()- const selectedPage = notionPages.find(page => page.page_id === selected.id)- setPreviewNotionPage(selectedPage!)- currentEstimateMutation.mutate()- }}- value={{- id: previewNotionPage?.page_id || '',- name: previewNotionPage?.page_name || '',- extension: 'md',- }}- />- }- {dataSourceType === DataSourceType.WEB- && <PreviewDocumentPicker- files={- websitePages.map(page => ({- id: page.source_url,- name: page.title,- extension: 'md',- }))- }- onChange={(selected) => {- currentEstimateMutation.reset()- const selectedPage = websitePages.find(page => page.source_url === selected.id)- setPreviewWebsitePage(selectedPage!)- currentEstimateMutation.mutate()- }}- value={- {- id: previewWebsitePage?.source_url || '',- name: previewWebsitePage?.title || '',- extension: 'md',- }++ <div className={s.source}>+ <div className={s.sourceContent}>+ {dataSourceType === DataSourceType.FILE && (+ <>+ <div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.fileSource')}</div>+ <div className='flex items-center text-sm leading-6 font-medium text-gray-800'>+ <span className={cn(s.fileIcon, files.length && s[files[0].extension || ''])} />+ {getFileName(files[0].name || '')}+ {files.length > 1 && (+ <span className={s.sourceCount}>+ <span>{t('datasetCreation.stepTwo.other')}</span>+ <span>{files.length - 1}</span>+ <span>{t('datasetCreation.stepTwo.fileUnit')}</span>+ </span>+ )}+ </div>+ </>+ )}+ {dataSourceType === DataSourceType.NOTION && (+ <>+ <div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.notionSource')}</div>+ <div className='flex items-center text-sm leading-6 font-medium text-gray-800'>+ <NotionIcon+ className='shrink-0 mr-1'+ type='page'+ src={notionPages[0]?.page_icon}+ />+ {notionPages[0]?.page_name}+ {notionPages.length > 1 && (+ <span className={s.sourceCount}>+ <span>{t('datasetCreation.stepTwo.other')}</span>+ <span>{notionPages.length - 1}</span>+ <span>{t('datasetCreation.stepTwo.notionUnit')}</span>+ </span>+ )}+ </div>+ </>+ )}+ {dataSourceType === DataSourceType.WEB && (+ <>+ <div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.websiteSource')}</div>+ <div className='flex items-center text-sm leading-6 font-medium text-gray-800'>+ <Globe01 className='shrink-0 mr-1' />+ <span className='grow w-0 truncate'>{websitePages[0].source_url}</span>+ {websitePages.length > 1 && (+ <span className={s.sourceCount}>+ <span>{t('datasetCreation.stepTwo.other')}</span>+ <span>{websitePages.length - 1}</span>+ <span>{t('datasetCreation.stepTwo.webpageUnit')}</span>+ </span>+ )}+ </div>+ </>+ )}+ </div>+ <div className={s.divider} />+ <div className={s.segmentCount}>+ <div className='mb-2 text-xs font-medium text-gray-500'>{t('datasetCreation.stepTwo.estimateSegment')}</div>+ <div className='flex items-center text-sm leading-6 font-medium text-gray-800'>+ {+ fileIndexingEstimate+ ? (+ <div className='text-xs font-medium text-gray-800'>{formatNumber(fileIndexingEstimate.total_segments)} </div>+ )+ : (+ <div className={s.calculating}>{t('datasetCreation.stepTwo.calculating')}</div>+ )}- />- }- {- currentDocForm !== ChunkingMode.qa- && <Badge text={t(- 'datasetCreation.stepTwo.previewChunkCount', {- count: estimate?.total_segments || 0,- }) as string}- />- }+ </div>+ </div></div>- </PreviewHeader>}- className={cn('flex shrink-0 w-1/2 p-4 pr-0 relative h-full', isMobile && 'w-full max-w-[524px]')}- mainClassName='space-y-6'- >- {currentDocForm === ChunkingMode.qa && estimate?.qa_preview && (- estimate?.qa_preview.map((item, index) => (- <ChunkContainer- key={item.question}- label={`Chunk-${index + 1}`}- characterCount={item.question.length + item.answer.length}- >- <QAPreview qa={item} />- </ChunkContainer>- ))- )}- {currentDocForm === ChunkingMode.text && estimate?.preview && (- estimate?.preview.map((item, index) => (- <ChunkContainer- key={item.content}- label={`Chunk-${index + 1}`}- characterCount={item.content.length}- >- {item.content}- </ChunkContainer>- ))- )}- {currentDocForm === ChunkingMode.parentChild && currentEstimateMutation.data?.preview && (- estimate?.preview?.map((item, index) => {- const indexForLabel = index + 1- return (- <ChunkContainer- key={item.content}- label={`Chunk-${indexForLabel}`}- characterCount={item.content.length}- >- <FormattedText>- {item.child_chunks.map((child, index) => {- const indexForLabel = index + 1- return (- <PreviewSlice- key={child}- label={`C-${indexForLabel}`}- text={child}- tooltip={`Child-chunk-${indexForLabel} · ${child.length} Characters`}- labelInnerClassName='text-[10px] font-semibold align-bottom leading-7'- dividerClassName='leading-7'- />- )- })}- </FormattedText>- </ChunkContainer>+ {!isSetting+ ? (+ <div className='flex items-center mt-8 py-2'>+ <Button onClick={() => onStepChange && onStepChange(-1)}>{t('datasetCreation.stepTwo.previousStep')}</Button>+ <div className={s.divider} />+ <Button loading={isCreating} variant='primary' onClick={createHandle}>{t('datasetCreation.stepTwo.nextStep')}</Button>+ </div>)- })- )}- {currentEstimateMutation.isIdle && (- <div className='h-full w-full flex items-center justify-center'>- <div className='flex flex-col items-center justify-center gap-3'>- <RiSearchEyeLine className='size-10 text-text-empty-state-icon' />- <p className='text-sm text-text-tertiary'>- {t('datasetCreation.stepTwo.previewChunkTip')}- </p>+ : (+ <div className='flex items-center mt-8 py-2'>+ <Button loading={isCreating} variant='primary' onClick={createHandle}>{t('datasetCreation.stepTwo.save')}</Button>+ <Button className='ml-2' onClick={onCancel}>{t('datasetCreation.stepTwo.cancel')}</Button>+ </div>+ )}+ </div>+ </div>+ </div>+ <FloatRightContainer isMobile={isMobile} isOpen={showPreview} onClose={hidePreview} footer={null}>+ {showPreview && <div ref={previewScrollRef} className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll border-l border-[#F2F4F7]')}>+ <div className={cn(s.previewHeader, previewScrolled && `${s.fixed} pb-3`)}>+ <div className='flex items-center justify-between px-8'>+ <div className='grow flex items-center'>+ <div>{t('datasetCreation.stepTwo.previewTitle')}</div>+ {docForm === DocForm.QA && !previewSwitched && (+ <Button className='ml-2' variant='secondary-accent' onClick={() => previewSwitch()}>{t('datasetCreation.stepTwo.previewButton')}</Button>+ )}+ </div>+ <div className='flex items-center justify-center w-6 h-6 cursor-pointer' onClick={hidePreview}>+ <XMarkIcon className='h-4 w-4'></XMarkIcon></div></div>- )}- {currentEstimateMutation.isPending && (- <div className='space-y-6'>- {Array.from({ length: 10 }, (_, i) => (- <SkeletonContainer key={i}>- <SkeletonRow>- <SkeletonRectangle className="w-20" />- <SkeletonPoint />- <SkeletonRectangle className="w-24" />- </SkeletonRow>- <SkeletonRectangle className="w-full" />- <SkeletonRectangle className="w-full" />- <SkeletonRectangle className="w-[422px]" />- </SkeletonContainer>- ))}+ {docForm === DocForm.QA && !previewSwitched && (+ <div className='px-8 pr-12 text-xs text-gray-500'>+ <span>{t('datasetCreation.stepTwo.previewSwitchTipStart')}</span>+ <span className='text-amber-600'>{t('datasetCreation.stepTwo.previewSwitchTipEnd')}</span>+ </div>+ )}+ </div>+ <div className='my-4 px-8 space-y-4'>+ {previewSwitched && docForm === DocForm.QA && fileIndexingEstimate?.qa_preview && (+ <>+ {fileIndexingEstimate?.qa_preview.map((item, index) => (+ <PreviewItem type={PreviewType.QA} key={item.question} qa={item} index={index + 1} />+ ))}+ </>+ )}+ {(docForm === DocForm.TEXT || !previewSwitched) && fileIndexingEstimate?.preview && (+ <>+ {fileIndexingEstimate?.preview.map((item, index) => (+ <PreviewItem type={PreviewType.TEXT} key={item} content={item} index={index + 1} />+ ))}+ </>+ )}+ {previewSwitched && docForm === DocForm.QA && !fileIndexingEstimate?.qa_preview && (+ <div className='flex items-center justify-center h-[200px]'>+ <Loading type='area' />+ </div>+ )}+ {!previewSwitched && !fileIndexingEstimate?.preview && (+ <div className='flex items-center justify-center h-[200px]'>+ <Loading type='area' />+ </div>+ )}+ </div>+ </div>}+ {!showPreview && (+ <div className={cn(s.sideTip)}>+ <div className={s.tipCard}>+ <span className={s.icon} />+ <div className={s.title}>{t('datasetCreation.stepTwo.sideTipTitle')}</div>+ <div className={s.content}>+ <p className='mb-3'>{t('datasetCreation.stepTwo.sideTipP1')}</p>+ <p className='mb-3'>{t('datasetCreation.stepTwo.sideTipP2')}</p>+ <p className='mb-3'>{t('datasetCreation.stepTwo.sideTipP3')}</p>+ <p>{t('datasetCreation.stepTwo.sideTipP4')}</p>+ </div></div>- )}- </PreviewContainer>+ </div>+ )}</FloatRightContainer></div>)diff --git a/web/app/components/datasets/create/step-two/inputs.tsx b/web/app/components/datasets/create/step-two/inputs.tsxdeleted file mode 100644index 4231f6242dc..00000000000--- a/web/app/components/datasets/create/step-two/inputs.tsx+++ /dev/null@@ -1,77 +0,0 @@-import type { FC, PropsWithChildren, ReactNode } from 'react'-import { useTranslation } from 'react-i18next'-import type { InputProps } from '@/app/components/base/input'-import Input from '@/app/components/base/input'-import Tooltip from '@/app/components/base/tooltip'-import type { InputNumberProps } from '@/app/components/base/input-number'-import { InputNumber } from '@/app/components/base/input-number'--const TextLabel: FC<PropsWithChildren> = (props) => {- return <label className='text-text-secondary text-xs font-semibold leading-none'>{props.children}</label>-}--const FormField: FC<PropsWithChildren<{ label: ReactNode }>> = (props) => {- return <div className='space-y-2 flex-1'>- <TextLabel>{props.label}</TextLabel>- {props.children}- </div>-}--export const DelimiterInput: FC<InputProps & { tooltip?: string }> = (props) => {- const { t } = useTranslation()- return <FormField label={<div className='flex items-center mb-1'>- <span className='system-sm-semibold mr-0.5'>{t('datasetCreation.stepTwo.separator')}</span>- <Tooltip- popupContent={- <div className='max-w-[200px]'>- {props.tooltip || t('datasetCreation.stepTwo.separatorTip')}- </div>- }- />- </div>}>- <Input- type="text"- className='h-9'- placeholder={t('datasetCreation.stepTwo.separatorPlaceholder')!}- {...props}- />- </FormField>-}--export const MaxLengthInput: FC<InputNumberProps> = (props) => {- const { t } = useTranslation()- return <FormField label={<div className='system-sm-semibold mb-1'>- {t('datasetCreation.stepTwo.maxLength')}- </div>}>- <InputNumber- type="number"- className='h-9'- placeholder={'≤ 4000'}- max={4000}- min={1}- {...props}- />- </FormField>-}--export const OverlapInput: FC<InputNumberProps> = (props) => {- const { t } = useTranslation()- return <FormField label={<div className='flex items-center mb-1'>- <span className='system-sm-semibold'>{t('datasetCreation.stepTwo.overlap')}</span>- <Tooltip- popupContent={- <div className='max-w-[200px]'>- {t('datasetCreation.stepTwo.overlapTip')}- </div>- }- />- </div>}>- <InputNumber- type="number"- className='h-9'- placeholder={t('datasetCreation.stepTwo.overlap') || ''}- min={1}- {...props}- />- </FormField>-}diff --git a/web/app/components/datasets/create/step-two/language-select/index.tsx b/web/app/components/datasets/create/step-two/language-select/index.tsxindex 9cbf1a40d13..41f3e0abb55 100644--- a/web/app/components/datasets/create/step-two/language-select/index.tsx+++ b/web/app/components/datasets/create/step-two/language-select/index.tsx@@ -1,7 +1,7 @@'use client'import type { FC } from 'react'import React from 'react'-import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react'+import { RiArrowDownSLine } from '@remixicon/react'import cn from '@/utils/classnames'import Popover from '@/app/components/base/popover'import { languages } from '@/i18n/language'@@ -22,40 +22,25 @@ const LanguageSelect: FC<ILanguageSelectProps> = ({manualClosetrigger='click'disabled={disabled}- popupClassName='z-20'htmlContent={- <div className='w-full p-1'>+ <div className='w-full py-1'>{languages.filter(language => language.supported).map(({ prompt_name }) => (<divkey={prompt_name}- className='w-full py-2 px-3 inline-flex items-center justify-between hover:bg-state-base-hover rounded-lg cursor-pointer'- onClick={() => onSelect(prompt_name)}- >- <span className='text-text-secondary system-sm-medium'>{prompt_name}</span>- {(currentLanguage === prompt_name) && <RiCheckLine className='size-4 text-text-accent' />}+ className='py-2 px-3 mx-1 flex items-center gap-2 hover:bg-gray-100 rounded-lg cursor-pointer text-gray-700 text-sm'+ onClick={() => onSelect(prompt_name)}>{prompt_name}</div>))}</div>}btnElement={- <div className={cn('inline-flex items-center gap-x-[1px]', disabled && 'cursor-not-allowed')}>- <span className={cn(- 'px-[3px] system-xs-semibold text-components-button-tertiary-text',- disabled ? 'text-components-button-tertiary-text-disabled' : '',- )}>- {currentLanguage}- </span>- <RiArrowDownSLine className={cn(- 'size-3.5 text-components-button-tertiary-text',- disabled ? 'text-components-button-tertiary-text-disabled' : '',- )} />+ <div className='inline-flex items-center'>+ <span className='pr-[2px] text-xs leading-[18px] font-medium'>{currentLanguage}</span>+ <RiArrowDownSLine className='w-3 h-3 opacity-60' /></div>}- btnClassName={() => cn(- '!border-0 rounded-md !px-1.5 !py-1 !mx-1 !bg-components-button-tertiary-bg !hover:bg-components-button-tertiary-bg',- disabled ? 'bg-components-button-tertiary-bg-disabled' : '',- )}- className='!w-[140px] h-fit !z-20 !translate-x-0 !left-1'+ btnClassName={open => cn('!border-0 !px-0 !py-0 !bg-inherit !hover:bg-inherit', open ? 'text-blue-600' : 'text-gray-500')}+ className='!w-[120px] h-fit !z-20 !translate-x-0 !left-[-16px]'/>)}diff --git a/web/app/components/datasets/create/step-two/option-card.tsx b/web/app/components/datasets/create/step-two/option-card.tsxdeleted file mode 100644index d0efdaabb1c..00000000000--- a/web/app/components/datasets/create/step-two/option-card.tsx+++ /dev/null@@ -1,98 +0,0 @@-import { type ComponentProps, type FC, type ReactNode, forwardRef } from 'react'-import Image from 'next/image'-import classNames from '@/utils/classnames'--const TriangleArrow: FC<ComponentProps<'svg'>> = props => (- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="11" viewBox="0 0 24 11" fill="none" {...props}>- <path d="M9.87868 1.12132C11.0503 -0.0502525 12.9497 -0.0502525 14.1213 1.12132L23.3137 10.3137H0.686292L9.87868 1.12132Z" fill="currentColor"/>- </svg>-)--type OptionCardHeaderProps = {- icon: ReactNode- title: ReactNode- description: string- isActive?: boolean- activeClassName?: string- effectImg?: string-}--export const OptionCardHeader: FC<OptionCardHeaderProps> = (props) => {- const { icon, title, description, isActive, activeClassName, effectImg } = props- return <div className={classNames(- 'flex h-full overflow-hidden rounded-t-xl relative',- isActive && activeClassName,- )}>- <div className='size-14 flex items-center justify-center relative overflow-hidden'>- {isActive && effectImg && <Image src={effectImg} className='absolute top-0 left-0 w-full h-full' alt='' width={56} height={56} />}- <div className='p-1'>- <div className='size-8 rounded-lg border p-1.5 shadow-md border-components-panel-border-subtle justify-center flex bg-background-default-dodge'>- {icon}- </div>- </div>- </div>- <TriangleArrow- className='absolute left-4 -bottom-1.5 text-components-panel-bg'- />- <div className='flex-1 space-y-0.5 py-3 pr-4'>- <div className='text-text-secondary system-md-semibold'>{title}</div>- <div className='text-text-tertiary system-xs-regular'>{description}</div>- </div>- </div>-}--type OptionCardProps = {- icon: ReactNode- className?: string- activeHeaderClassName?: string- title: ReactNode- description: string- isActive?: boolean- actions?: ReactNode- effectImg?: string- onSwitched?: () => void- noHighlight?: boolean- disabled?: boolean-} & Omit<ComponentProps<'div'>, 'title' | 'onClick'>--export const OptionCard: FC<OptionCardProps> = forwardRef((props, ref) => {- const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSwitched, noHighlight, disabled, ...rest } = props- return <div- className={classNames(- 'rounded-xl bg-components-option-card-option-bg shadow-xs',- (isActive && !noHighlight)- ? 'border-[1.5px] border-components-option-card-option-selected-border'- : 'border border-components-option-card-option-border',- disabled && 'opacity-50',- className,- )}- style={{- ...style,- }}- onClick={() => {- if (!isActive && !disabled)- onSwitched?.()- }}- {...rest}- ref={ref}- >- <OptionCardHeader- icon={icon}- title={title}- description={description}- isActive={isActive && !noHighlight}- activeClassName={activeHeaderClassName}- effectImg={effectImg}- />- {/** Body */}- {isActive && (children || actions) && <div className='py-3 px-4 bg-components-panel-bg rounded-b-xl'>- {children}- {actions && <div className='flex gap-2 mt-4'>- {actions}- </div>- }- </div>}- </div>-})--OptionCard.displayName = 'OptionCard'diff --git a/web/app/components/datasets/create/stepper/index.tsx b/web/app/components/datasets/create/stepper/index.tsxdeleted file mode 100644index 317c1a76eec..00000000000--- a/web/app/components/datasets/create/stepper/index.tsx+++ /dev/null@@ -1,27 +0,0 @@-import { type FC, Fragment } from 'react'-import type { Step } from './step'-import { StepperStep } from './step'--export type StepperProps = {- steps: Step[]- activeIndex: number-}--export const Stepper: FC<StepperProps> = (props) => {- const { steps, activeIndex } = props- return <div className='flex items-center gap-3'>- {steps.map((step, index) => {- const isLast = index === steps.length - 1- return (- <Fragment key={index}>- <StepperStep- {...step}- activeIndex={activeIndex}- index={index}- />- {!isLast && <div className='w-4 h-px bg-divider-deep' />}- </Fragment>- )- })}- </div>-}diff --git a/web/app/components/datasets/create/stepper/step.tsx b/web/app/components/datasets/create/stepper/step.tsxdeleted file mode 100644index c230de1a6e7..00000000000--- a/web/app/components/datasets/create/stepper/step.tsx+++ /dev/null@@ -1,46 +0,0 @@-import type { FC } from 'react'-import classNames from '@/utils/classnames'--export type Step = {- name: string-}--export type StepperStepProps = Step & {- index: number- activeIndex: number-}--export const StepperStep: FC<StepperStepProps> = (props) => {- const { name, activeIndex, index } = props- const isActive = index === activeIndex- const isDisabled = activeIndex < index- const label = isActive ? `STEP ${index + 1}` : `${index + 1}`- return <div className='flex items-center gap-2'>- <div className={classNames(- 'h-5 px-2 py-1 rounded-3xl flex-col justify-center items-center gap-2 inline-flex',- isActive- ? 'bg-state-accent-solid'- : !isDisabled- ? 'border border-text-quaternary'- : 'border border-divider-deep',- )}>- <div className={classNames(- 'text-center system-2xs-semibold-uppercase',- isActive- ? 'text-text-primary-on-surface'- : !isDisabled- ? 'text-text-tertiary'- : 'text-text-quaternary',- )}>- {label}- </div>- </div>- <div className={classNames('system-xs-medium-uppercase',- isActive- ? 'text-text-accent system-xs-semibold-uppercase'- : !isDisabled- ? 'text-text-tertiary'- : 'text-text-quaternary',- )}>{name}</div>- </div>-}diff --git a/web/app/components/datasets/create/top-bar/index.tsx b/web/app/components/datasets/create/top-bar/index.tsxdeleted file mode 100644index 20ba7158db5..00000000000--- a/web/app/components/datasets/create/top-bar/index.tsx+++ /dev/null@@ -1,41 +0,0 @@-import type { FC } from 'react'-import { RiArrowLeftLine } from '@remixicon/react'-import Link from 'next/link'-import { useTranslation } from 'react-i18next'-import { Stepper, type StepperProps } from '../stepper'-import classNames from '@/utils/classnames'--export type TopbarProps = Pick<StepperProps, 'activeIndex'> & {- className?: string-}--const STEP_T_MAP: Record<number, string> = {- 1: 'datasetCreation.steps.one',- 2: 'datasetCreation.steps.two',- 3: 'datasetCreation.steps.three',-}--export const Topbar: FC<TopbarProps> = (props) => {- const { className, ...rest } = props- const { t } = useTranslation()- return <div className={classNames('flex shrink-0 h-[52px] items-center justify-between relative border-b border-b-divider-subtle', className)}>- <Link href={'/datasets'} className="h-12 pl-2 pr-6 py-2 justify-start items-center gap-1 inline-flex">- <div className='p-2'>- <RiArrowLeftLine className='size-4 text-text-primary' />- </div>- <p className="text-text-primary system-sm-semibold-uppercase">- {t('datasetCreation.steps.header.creation')}- </p>- </Link>- <div className={- 'top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 absolute'- }>- <Stepper- steps={Array.from({ length: 3 }, (_, i) => ({- name: t(STEP_T_MAP[i + 1]),- }))}- {...rest}- />- </div>- </div>-}diff --git a/web/app/components/datasets/create/website/base/error-message.tsx b/web/app/components/datasets/create/website/base/error-message.tsxindex f061c4624e9..aa337ec4bf5 100644--- a/web/app/components/datasets/create/website/base/error-message.tsx+++ b/web/app/components/datasets/create/website/base/error-message.tsx@@ -18,7 +18,7 @@ const ErrorMessage: FC<Props> = ({return (<div className={cn(className, 'py-2 px-4 border-t border-gray-200 bg-[#FFFAEB]')}><div className='flex items-center h-5'>- <AlertTriangle className='mr-2 w-4 h-4 text-text-warning-secondary' />+ <AlertTriangle className='mr-2 w-4 h-4 text-[#F79009]' /><div className='text-sm font-medium text-[#DC6803]'>{title}</div></div>{errorMsg && (diff --git a/web/app/components/datasets/create/website/jina-reader/index.tsx b/web/app/components/datasets/create/website/jina-reader/index.tsxindex 1c133f935c0..51d77d71214 100644--- a/web/app/components/datasets/create/website/jina-reader/index.tsx+++ b/web/app/components/datasets/create/website/jina-reader/index.tsx@@ -94,6 +94,7 @@ const JinaReader: FC<Props> = ({const waitForCrawlFinished = useCallback(async (jobId: string) => {try {const res = await checkJinaReaderTaskStatus(jobId) as any+ console.log('res', res)if (res.status === 'completed') {return {isError: false,diff --git a/web/app/components/datasets/create/website/preview.tsx b/web/app/components/datasets/create/website/preview.tsxindex 5180a834423..65abe83ed77 100644--- a/web/app/components/datasets/create/website/preview.tsx+++ b/web/app/components/datasets/create/website/preview.tsx@@ -18,7 +18,7 @@ const WebsitePreview = ({const { t } = useTranslation()return (- <div className={cn(s.filePreview, 'h-full')}>+ <div className={cn(s.filePreview)}><div className={cn(s.previewHeader)}><div className={cn(s.title)}><span>{t('datasetCreation.stepOne.pagePreview')}</span>@@ -32,7 +32,7 @@ const WebsitePreview = ({<div className='truncate leading-[18px] text-xs font-normal text-gray-500' title={payload.source_url}>{payload.source_url}</div></div><div className={cn(s.previewContent)}>- <div className={cn(s.fileContent, 'body-md-regular')}>{payload.markdown}</div>+ <div className={cn(s.fileContent)}>{payload.markdown}</div></div></div>)diff --git a/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx b/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsxindex 6602244a480..36216aa7c89 100644--- a/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx+++ b/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx@@ -7,7 +7,7 @@ import {import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'-import { ChunkingMode } from '@/models/datasets'+import { DocForm } from '@/models/datasets'import I18n from '@/context/i18n'import { LanguagesSupported } from '@/i18n/language'@@ -32,18 +32,18 @@ const CSV_TEMPLATE_CN = [['内容 2'],]-const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {+const CSVDownload: FC<{ docForm: DocForm }> = ({ docForm }) => {const { t } = useTranslation()const { locale } = useContext(I18n)const { CSVDownloader, Type } = useCSVDownloader()const getTemplate = () => {if (locale === LanguagesSupported[1]) {- if (docForm === ChunkingMode.qa)+ if (docForm === DocForm.QA)return CSV_TEMPLATE_QA_CNreturn CSV_TEMPLATE_CN}- if (docForm === ChunkingMode.qa)+ if (docForm === DocForm.QA)return CSV_TEMPLATE_QA_ENreturn CSV_TEMPLATE_EN}@@ -52,7 +52,7 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {<div className='mt-6'><div className='text-sm text-gray-900 font-medium'>{t('share.generation.csvStructureTitle')}</div><div className='mt-2 max-h-[500px] overflow-auto'>- {docForm === ChunkingMode.qa && (+ {docForm === DocForm.QA && (<table className='table-fixed w-full border-separate border-spacing-0 border border-gray-200 rounded-lg text-xs'><thead className='text-gray-500'><tr>@@ -72,7 +72,7 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {</tbody></table>)}- {docForm === ChunkingMode.text && (+ {docForm === DocForm.TEXT && (<table className='table-fixed w-full border-separate border-spacing-0 border border-gray-200 rounded-lg text-xs'><thead className='text-gray-500'><tr>@@ -97,7 +97,7 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {bom={true}data={getTemplate()}>- <div className='flex items-center h-[18px] space-x-1 text-text-accent text-xs font-medium'>+ <div className='flex items-center h-[18px] space-x-1 text-[#155EEF] text-xs font-medium'><DownloadIcon className='w-3 h-3 mr-1' />{t('datasetDocuments.list.batchModal.template')}</div>diff --git a/web/app/components/datasets/documents/detail/batch-modal/index.tsx b/web/app/components/datasets/documents/detail/batch-modal/index.tsxindex c666ba67152..139a364cb40 100644--- a/web/app/components/datasets/documents/detail/batch-modal/index.tsx+++ b/web/app/components/datasets/documents/detail/batch-modal/index.tsx@@ -7,11 +7,11 @@ import CSVUploader from './csv-uploader'import CSVDownloader from './csv-downloader'import Button from '@/app/components/base/button'import Modal from '@/app/components/base/modal'-import type { ChunkingMode } from '@/models/datasets'+import type { DocForm } from '@/models/datasets'export type IBatchModalProps = {isShow: boolean- docForm: ChunkingMode+ docForm: DocFormonCancel: () => voidonConfirm: (file: File) => void}diff --git a/web/app/components/datasets/documents/detail/completed/InfiniteVirtualList.tsx b/web/app/components/datasets/documents/detail/completed/InfiniteVirtualList.tsxnew file mode 100644index 00000000000..7b510bcf21b--- /dev/null+++ b/web/app/components/datasets/documents/detail/completed/InfiniteVirtualList.tsx@@ -0,0 +1,98 @@+import type { CSSProperties, FC } from 'react'+import React from 'react'+import { FixedSizeList as List } from 'react-window'+import InfiniteLoader from 'react-window-infinite-loader'+import SegmentCard from './SegmentCard'+import s from './style.module.css'+import type { SegmentDetailModel } from '@/models/datasets'++type IInfiniteVirtualListProps = {+ hasNextPage?: boolean // Are there more items to load? (This information comes from the most recent API request.)+ isNextPageLoading: boolean // Are we currently loading a page of items? (This may be an in-flight flag in your Redux store for example.)+ items: Array<SegmentDetailModel[]> // Array of items loaded so far.+ loadNextPage: () => Promise<void> // Callback function responsible for loading the next page of items.+ onClick: (detail: SegmentDetailModel) => void+ onChangeSwitch: (segId: string, enabled: boolean) => Promise<void>+ onDelete: (segId: string) => Promise<void>+ archived?: boolean+ embeddingAvailable: boolean+}++const InfiniteVirtualList: FC<IInfiniteVirtualListProps> = ({+ hasNextPage,+ isNextPageLoading,+ items,+ loadNextPage,+ onClick: onClickCard,+ onChangeSwitch,+ onDelete,+ archived,+ embeddingAvailable,+}) => {+ // If there are more items to be loaded then add an extra row to hold a loading indicator.+ const itemCount = hasNextPage ? items.length + 1 : items.length++ // Only load 1 page of items at a time.+ // Pass an empty callback to InfiniteLoader in case it asks us to load more than once.+ const loadMoreItems = isNextPageLoading ? () => { } : loadNextPage++ // Every row is loaded except for our loading indicator row.+ const isItemLoaded = (index: number) => !hasNextPage || index < items.length++ // Render an item or a loading indicator.+ const Item = ({ index, style }: { index: number; style: CSSProperties }) => {+ let content+ if (!isItemLoaded(index)) {+ content = (+ <>+ {[1, 2, 3].map(v => (+ <SegmentCard key={v} loading={true} detail={{ position: v } as any} />+ ))}+ </>+ )+ }+ else {+ content = items[index].map(segItem => (+ <SegmentCard+ key={segItem.id}+ detail={segItem}+ onClick={() => onClickCard(segItem)}+ onChangeSwitch={onChangeSwitch}+ onDelete={onDelete}+ loading={false}+ archived={archived}+ embeddingAvailable={embeddingAvailable}+ />+ ))+ }++ return (+ <div style={style} className={s.cardWrapper}>+ {content}+ </div>+ )+ }++ return (+ <InfiniteLoader+ itemCount={itemCount}+ isItemLoaded={isItemLoaded}+ loadMoreItems={loadMoreItems}+ >+ {({ onItemsRendered, ref }) => (+ <List+ ref={ref}+ className="List"+ height={800}+ width={'100%'}+ itemSize={200}+ itemCount={itemCount}+ onItemsRendered={onItemsRendered}+ >+ {Item}+ </List>+ )}+ </InfiniteLoader>+ )+}+export default InfiniteVirtualListdiff --git a/web/app/components/datasets/documents/detail/completed/SegmentCard.tsx b/web/app/components/datasets/documents/detail/completed/SegmentCard.tsxindex 264d62b68a4..5b76acc9360 100644--- a/web/app/components/datasets/documents/detail/completed/SegmentCard.tsx+++ b/web/app/components/datasets/documents/detail/completed/SegmentCard.tsx@@ -6,9 +6,9 @@ import {RiDeleteBinLine,} from '@remixicon/react'import { StatusItem } from '../../list'-import style from '../../style.module.css'+import { DocumentTitle } from '../index'import s from './style.module.css'-import { SegmentIndexTag } from './common/segment-index-tag'+import { SegmentIndexTag } from './index'import cn from '@/utils/classnames'import Confirm from '@/app/components/base/confirm'import Switch from '@/app/components/base/switch'@@ -31,22 +31,6 @@ const ProgressBar: FC<{ percent: number; loading: boolean }> = ({ percent, loadi)}-type DocumentTitleProps = {- extension?: string- name?: string- iconCls?: string- textCls?: string- wrapperCls?: string-}--const DocumentTitle: FC<DocumentTitleProps> = ({ extension, name, iconCls, textCls, wrapperCls }) => {- const localExtension = extension?.toLowerCase() || name?.split('.')?.pop()?.toLowerCase()- return <div className={cn('flex items-center justify-start flex-1', wrapperCls)}>- <div className={cn(s[`${localExtension || 'txt'}Icon`], style.titleIcon, iconCls)}></div>- <span className={cn('font-semibold text-lg text-gray-900 ml-1', textCls)}> {name || '--'}</span>- </div>-}-export type UsageScene = 'doc' | 'hitTesting'type ISegmentCardProps = {diff --git a/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx b/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsxdeleted file mode 100644index 085bfddc163..00000000000--- a/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx+++ /dev/null@@ -1,134 +0,0 @@-import React, { type FC, useMemo, useState } from 'react'-import { useTranslation } from 'react-i18next'-import {- RiCloseLine,- RiExpandDiagonalLine,-} from '@remixicon/react'-import ActionButtons from './common/action-buttons'-import ChunkContent from './common/chunk-content'-import Dot from './common/dot'-import { SegmentIndexTag } from './common/segment-index-tag'-import { useSegmentListContext } from './index'-import type { ChildChunkDetail, ChunkingMode } from '@/models/datasets'-import { useEventEmitterContextContext } from '@/context/event-emitter'-import { formatNumber } from '@/utils/format'-import classNames from '@/utils/classnames'-import Divider from '@/app/components/base/divider'-import { formatTime } from '@/utils/time'--type IChildSegmentDetailProps = {- chunkId: string- childChunkInfo?: Partial<ChildChunkDetail> & { id: string }- onUpdate: (segmentId: string, childChunkId: string, content: string) => void- onCancel: () => void- docForm: ChunkingMode-}--/**- * Show all the contents of the segment- */-const ChildSegmentDetail: FC<IChildSegmentDetailProps> = ({- chunkId,- childChunkInfo,- onUpdate,- onCancel,- docForm,-}) => {- const { t } = useTranslation()- const [content, setContent] = useState(childChunkInfo?.content || '')- const { eventEmitter } = useEventEmitterContextContext()- const [loading, setLoading] = useState(false)- const fullScreen = useSegmentListContext(s => s.fullScreen)- const toggleFullScreen = useSegmentListContext(s => s.toggleFullScreen)-- eventEmitter?.useSubscription((v) => {- if (v === 'update-child-segment')- setLoading(true)- if (v === 'update-child-segment-done')- setLoading(false)- })-- const handleCancel = () => {- onCancel()- setContent(childChunkInfo?.content || '')- }-- const handleSave = () => {- onUpdate(chunkId, childChunkInfo?.id || '', content)- }-- const wordCountText = useMemo(() => {- const count = content.length- return `${formatNumber(count)} ${t('datasetDocuments.segment.characters', { count })}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [content.length])-- const EditTimeText = useMemo(() => {- const timeText = formatTime({- date: (childChunkInfo?.updated_at ?? 0) * 1000,- dateFormat: 'MM/DD/YYYY h:mm:ss',- })- return `${t('datasetDocuments.segment.editedAt')} ${timeText}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [childChunkInfo?.updated_at])-- return (- <div className={'flex flex-col h-full'}>- <div className={classNames('flex items-center justify-between', fullScreen ? 'py-3 pr-4 pl-6 border border-divider-subtle' : 'pt-3 pr-3 pl-4')}>- <div className='flex flex-col'>- <div className='text-text-primary system-xl-semibold'>{t('datasetDocuments.segment.editChildChunk')}</div>- <div className='flex items-center gap-x-2'>- <SegmentIndexTag positionId={childChunkInfo?.position || ''} labelPrefix={t('datasetDocuments.segment.childChunk') as string} />- <Dot />- <span className='text-text-tertiary system-xs-medium'>{wordCountText}</span>- <Dot />- <span className='text-text-tertiary system-xs-medium'>- {EditTimeText}- </span>- </div>- </div>- <div className='flex items-center'>- {fullScreen && (- <>- <ActionButtons- handleCancel={handleCancel}- handleSave={handleSave}- loading={loading}- isChildChunk={true}- />- <Divider type='vertical' className='h-3.5 bg-divider-regular ml-4 mr-2' />- </>- )}- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer mr-1' onClick={toggleFullScreen}>- <RiExpandDiagonalLine className='w-4 h-4 text-text-tertiary' />- </div>- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer' onClick={onCancel}>- <RiCloseLine className='w-4 h-4 text-text-tertiary' />- </div>- </div>- </div>- <div className={classNames('flex grow w-full', fullScreen ? 'flex-row justify-center px-6 pt-6' : 'py-3 px-4')}>- <div className={classNames('break-all overflow-hidden whitespace-pre-line h-full', fullScreen ? 'w-1/2' : 'w-full')}>- <ChunkContent- docForm={docForm}- question={content}- onQuestionChange={content => setContent(content)}- isEditMode={true}- />- </div>- </div>- {!fullScreen && (- <div className='flex items-center justify-end p-4 pt-3 border-t-[1px] border-t-divider-subtle'>- <ActionButtons- handleCancel={handleCancel}- handleSave={handleSave}- loading={loading}- isChildChunk={true}- />- </div>- )}- </div>- )-}--export default React.memo(ChildSegmentDetail)diff --git a/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx b/web/app/components/datasets/documents/detail/completed/child-segment-list.tsxdeleted file mode 100644index 1615ea98cf0..00000000000--- a/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx+++ /dev/null@@ -1,195 +0,0 @@-import { type FC, useMemo, useState } from 'react'-import { RiArrowDownSLine, RiArrowRightSLine } from '@remixicon/react'-import { useTranslation } from 'react-i18next'-import { EditSlice } from '../../../formatted-text/flavours/edit-slice'-import { useDocumentContext } from '../index'-import { FormattedText } from '../../../formatted-text/formatted'-import Empty from './common/empty'-import FullDocListSkeleton from './skeleton/full-doc-list-skeleton'-import { useSegmentListContext } from './index'-import type { ChildChunkDetail } from '@/models/datasets'-import Input from '@/app/components/base/input'-import classNames from '@/utils/classnames'-import Divider from '@/app/components/base/divider'-import { formatNumber } from '@/utils/format'--type IChildSegmentCardProps = {- childChunks: ChildChunkDetail[]- parentChunkId: string- handleInputChange?: (value: string) => void- handleAddNewChildChunk?: (parentChunkId: string) => void- enabled: boolean- onDelete?: (segId: string, childChunkId: string) => Promise<void>- onClickSlice?: (childChunk: ChildChunkDetail) => void- total?: number- inputValue?: string- onClearFilter?: () => void- isLoading?: boolean- focused?: boolean-}--const ChildSegmentList: FC<IChildSegmentCardProps> = ({- childChunks,- parentChunkId,- handleInputChange,- handleAddNewChildChunk,- enabled,- onDelete,- onClickSlice,- total,- inputValue,- onClearFilter,- isLoading,- focused = false,-}) => {- const { t } = useTranslation()- const parentMode = useDocumentContext(s => s.parentMode)- const currChildChunk = useSegmentListContext(s => s.currChildChunk)-- const [collapsed, setCollapsed] = useState(true)-- const toggleCollapse = () => {- setCollapsed(!collapsed)- }-- const isParagraphMode = useMemo(() => {- return parentMode === 'paragraph'- }, [parentMode])-- const isFullDocMode = useMemo(() => {- return parentMode === 'full-doc'- }, [parentMode])-- const contentOpacity = useMemo(() => {- return (enabled || focused) ? '' : 'opacity-50 group-hover/card:opacity-100'- }, [enabled, focused])-- const totalText = useMemo(() => {- const isSearch = inputValue !== '' && isFullDocMode- if (!isSearch) {- const text = isFullDocMode- ? !total- ? '--'- : formatNumber(total)- : formatNumber(childChunks.length)- const count = isFullDocMode- ? text === '--'- ? 0- : total- : childChunks.length- return `${text} ${t('datasetDocuments.segment.childChunks', { count })}`- }- else {- const text = !total ? '--' : formatNumber(total)- const count = text === '--' ? 0 : total- return `${count} ${t('datasetDocuments.segment.searchResults', { count })}`- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isFullDocMode, total, childChunks.length, inputValue])-- return (- <div className={classNames(- 'flex flex-col',- contentOpacity,- isParagraphMode ? 'pt-1 pb-2' : 'px-3 grow',- (isFullDocMode && isLoading) && 'overflow-y-hidden',- )}>- {isFullDocMode ? <Divider type='horizontal' className='h-[1px] bg-divider-subtle my-1' /> : null}- <div className={classNames('flex items-center justify-between', isFullDocMode ? 'pt-2 pb-3 sticky -top-2 left-0 bg-background-default' : '')}>- <div className={classNames(- 'h-7 flex items-center pl-1 pr-3 rounded-lg',- isParagraphMode && 'cursor-pointer',- (isParagraphMode && collapsed) && 'bg-dataset-child-chunk-expand-btn-bg',- isFullDocMode && 'pl-0',- )}- onClick={(event) => {- event.stopPropagation()- toggleCollapse()- }}- >- {- isParagraphMode- ? collapsed- ? (- <RiArrowRightSLine className='w-4 h-4 text-text-secondary opacity-50 mr-0.5' />- )- : (<RiArrowDownSLine className='w-4 h-4 text-text-secondary mr-0.5' />)- : null- }- <span className='text-text-secondary system-sm-semibold-uppercase'>{totalText}</span>- <span className={classNames('text-text-quaternary text-xs font-medium pl-1.5', isParagraphMode ? 'hidden group-hover/card:inline-block' : '')}>·</span>- <button- type='button'- className={classNames(- 'px-1.5 py-1 text-components-button-secondary-accent-text system-xs-semibold-uppercase',- isParagraphMode ? 'hidden group-hover/card:inline-block' : '',- (isFullDocMode && isLoading) ? 'text-components-button-secondary-accent-text-disabled' : '',- )}- onClick={(event) => {- event.stopPropagation()- handleAddNewChildChunk?.(parentChunkId)- }}- disabled={isLoading}- >- {t('common.operation.add')}- </button>- </div>- {isFullDocMode- ? <Input- showLeftIcon- showClearIcon- wrapperClassName='!w-52'- value={inputValue}- onChange={e => handleInputChange?.(e.target.value)}- onClear={() => handleInputChange?.('')}- />- : null}- </div>- {isLoading ? <FullDocListSkeleton /> : null}- {((isFullDocMode && !isLoading) || !collapsed)- ? <div className={classNames('flex gap-x-0.5', isFullDocMode ? 'grow mb-6' : 'items-center')}>- {isParagraphMode && (- <div className='self-stretch'>- <Divider type='vertical' className='w-[2px] mx-[7px] bg-text-accent-secondary' />- </div>- )}- {childChunks.length > 0- ? <FormattedText className={classNames('w-full !leading-6 flex flex-col', isParagraphMode ? 'gap-y-2' : 'gap-y-3')}>- {childChunks.map((childChunk) => {- const edited = childChunk.updated_at !== childChunk.created_at- const focused = currChildChunk?.childChunkInfo?.id === childChunk.id- return <EditSlice- key={childChunk.id}- label={`C-${childChunk.position}${edited ? ` · ${t('datasetDocuments.segment.edited')}` : ''}`}- text={childChunk.content}- onDelete={() => onDelete?.(childChunk.segment_id, childChunk.id)}- labelClassName={focused ? 'bg-state-accent-solid text-text-primary-on-surface' : ''}- labelInnerClassName={'text-[10px] font-semibold align-bottom leading-6'}- contentClassName={classNames('!leading-6', focused ? 'bg-state-accent-hover-alt text-text-primary' : '')}- showDivider={false}- onClick={(e) => {- e.stopPropagation()- onClickSlice?.(childChunk)- }}- offsetOptions={({ rects }) => {- return {- mainAxis: isFullDocMode ? -rects.floating.width : 12 - rects.floating.width,- crossAxis: (20 - rects.floating.height) / 2,- }- }}- />- })}- </FormattedText>- : inputValue !== ''- ? <div className='h-full w-full'>- <Empty onClearFilter={onClearFilter!} />- </div>- : null- }- </div>- : null}- </div>- )-}--export default ChildSegmentListdiff --git a/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx b/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsxdeleted file mode 100644index 1238d98a9c5..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/action-buttons.tsx+++ /dev/null@@ -1,86 +0,0 @@-import React, { type FC, useMemo } from 'react'-import { useTranslation } from 'react-i18next'-import { useKeyPress } from 'ahooks'-import { useDocumentContext } from '../../index'-import Button from '@/app/components/base/button'-import { getKeyboardKeyCodeBySystem, getKeyboardKeyNameBySystem } from '@/app/components/workflow/utils'--type IActionButtonsProps = {- handleCancel: () => void- handleSave: () => void- loading: boolean- actionType?: 'edit' | 'add'- handleRegeneration?: () => void- isChildChunk?: boolean-}--const ActionButtons: FC<IActionButtonsProps> = ({- handleCancel,- handleSave,- loading,- actionType = 'edit',- handleRegeneration,- isChildChunk = false,-}) => {- const { t } = useTranslation()- const mode = useDocumentContext(s => s.mode)- const parentMode = useDocumentContext(s => s.parentMode)-- useKeyPress(['esc'], (e) => {- e.preventDefault()- handleCancel()- })-- useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.s`, (e) => {- e.preventDefault()- if (loading)- return- handleSave()- }- , { exactMatch: true, useCapture: true })-- const isParentChildParagraphMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'paragraph'- }, [mode, parentMode])-- return (- <div className='flex items-center gap-x-2'>- <Button- onClick={handleCancel}- >- <div className='flex items-center gap-x-1'>- <span className='text-components-button-secondary-text system-sm-medium'>{t('common.operation.cancel')}</span>- <span className='px-[1px] bg-components-kbd-bg-gray rounded-[4px] text-text-tertiary system-kbd'>ESC</span>- </div>- </Button>- {(isParentChildParagraphMode && actionType === 'edit' && !isChildChunk)- ? <Button- onClick={handleRegeneration}- disabled={loading}- >- <span className='text-components-button-secondary-text system-sm-medium'>- {t('common.operation.saveAndRegenerate')}- </span>- </Button>- : null- }- <Button- variant='primary'- onClick={handleSave}- disabled={loading}- >- <div className='flex items-center gap-x-1'>- <span className='text-components-button-primary-text'>{t('common.operation.save')}</span>- <div className='flex items-center gap-x-0.5'>- <span className='w-4 h-4 bg-components-kbd-bg-white rounded-[4px] text-text-primary-on-surface system-kbd capitalize'>{getKeyboardKeyNameBySystem('ctrl')}</span>- <span className='w-4 h-4 bg-components-kbd-bg-white rounded-[4px] text-text-primary-on-surface system-kbd'>S</span>- </div>- </div>- </Button>- </div>- )-}--ActionButtons.displayName = 'ActionButtons'--export default React.memo(ActionButtons)diff --git a/web/app/components/datasets/documents/detail/completed/common/add-another.tsx b/web/app/components/datasets/documents/detail/completed/common/add-another.tsxdeleted file mode 100644index 444560e55f7..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/add-another.tsx+++ /dev/null@@ -1,32 +0,0 @@-import React, { type FC } from 'react'-import { useTranslation } from 'react-i18next'-import classNames from '@/utils/classnames'-import Checkbox from '@/app/components/base/checkbox'--type AddAnotherProps = {- className?: string- isChecked: boolean- onCheck: () => void-}--const AddAnother: FC<AddAnotherProps> = ({- className,- isChecked,- onCheck,-}) => {- const { t } = useTranslation()-- return (- <div className={classNames('flex items-center gap-x-1 pl-1', className)}>- <Checkbox- key='add-another-checkbox'- className='shrink-0'- checked={isChecked}- onCheck={onCheck}- />- <span className='text-text-tertiary system-xs-medium'>{t('datasetDocuments.segment.addAnother')}</span>- </div>- )-}--export default React.memo(AddAnother)diff --git a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsxdeleted file mode 100644index 3dd3689b64f..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx+++ /dev/null@@ -1,103 +0,0 @@-import React, { type FC } from 'react'-import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react'-import { useTranslation } from 'react-i18next'-import { useBoolean } from 'ahooks'-import Divider from '@/app/components/base/divider'-import classNames from '@/utils/classnames'-import Confirm from '@/app/components/base/confirm'--const i18nPrefix = 'dataset.batchAction'-type IBatchActionProps = {- className?: string- selectedIds: string[]- onBatchEnable: () => void- onBatchDisable: () => void- onBatchDelete: () => Promise<void>- onArchive?: () => void- onCancel: () => void-}--const BatchAction: FC<IBatchActionProps> = ({- className,- selectedIds,- onBatchEnable,- onBatchDisable,- onArchive,- onBatchDelete,- onCancel,-}) => {- const { t } = useTranslation()- const [isShowDeleteConfirm, {- setTrue: showDeleteConfirm,- setFalse: hideDeleteConfirm,- }] = useBoolean(false)- const [isDeleting, {- setTrue: setIsDeleting,- }] = useBoolean(false)-- const handleBatchDelete = async () => {- setIsDeleting()- await onBatchDelete()- hideDeleteConfirm()- }- return (- <div className={classNames('w-full flex justify-center gap-x-2', className)}>- <div className='flex items-center gap-x-1 p-1 rounded-[10px] bg-components-actionbar-bg-accent border border-components-actionbar-border-accent shadow-xl shadow-shadow-shadow-5 backdrop-blur-[5px]'>- <div className='inline-flex items-center gap-x-2 pl-2 pr-3 py-1'>- <span className='w-5 h-5 flex items-center justify-center px-1 py-0.5 bg-text-accent rounded-md text-text-primary-on-surface text-xs font-medium'>- {selectedIds.length}- </span>- <span className='text-text-accent text-[13px] font-semibold leading-[16px]'>{t(`${i18nPrefix}.selected`)}</span>- </div>- <Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' />- <div className='flex items-center gap-x-0.5 px-3 py-2'>- <RiCheckboxCircleLine className='w-4 h-4 text-components-button-ghost-text' />- <button type='button' className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchEnable}>- {t(`${i18nPrefix}.enable`)}- </button>- </div>- <div className='flex items-center gap-x-0.5 px-3 py-2'>- <RiCloseCircleLine className='w-4 h-4 text-components-button-ghost-text' />- <button type='button' className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onBatchDisable}>- {t(`${i18nPrefix}.disable`)}- </button>- </div>- {onArchive && (- <div className='flex items-center gap-x-0.5 px-3 py-2'>- <RiArchive2Line className='w-4 h-4 text-components-button-ghost-text' />- <button type='button' className='px-0.5 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onArchive}>- {t(`${i18nPrefix}.archive`)}- </button>- </div>- )}- <div className='flex items-center gap-x-0.5 px-3 py-2'>- <RiDeleteBinLine className='w-4 h-4 text-components-button-destructive-ghost-text' />- <button type='button' className='px-0.5 text-components-button-destructive-ghost-text text-[13px] font-medium leading-[16px]' onClick={showDeleteConfirm}>- {t(`${i18nPrefix}.delete`)}- </button>- </div>-- <Divider type='vertical' className='mx-0.5 h-3.5 bg-divider-regular' />- <button type='button' className='px-3.5 py-2 text-components-button-ghost-text text-[13px] font-medium leading-[16px]' onClick={onCancel}>- {t(`${i18nPrefix}.cancel`)}- </button>- </div>- {- isShowDeleteConfirm && (- <Confirm- isShow- title={t('datasetDocuments.list.delete.title')}- content={t('datasetDocuments.list.delete.content')}- confirmText={t('common.operation.sure')}- onConfirm={handleBatchDelete}- onCancel={hideDeleteConfirm}- isLoading={isDeleting}- isDisabled={isDeleting}- />- )- }- </div>- )-}--export default React.memo(BatchAction)diff --git a/web/app/components/datasets/documents/detail/completed/common/chunk-content.tsx b/web/app/components/datasets/documents/detail/completed/common/chunk-content.tsxdeleted file mode 100644index e6403fa12fd..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/chunk-content.tsx+++ /dev/null@@ -1,192 +0,0 @@-import React, { useEffect, useRef, useState } from 'react'-import type { ComponentProps, FC } from 'react'-import { useTranslation } from 'react-i18next'-import { ChunkingMode } from '@/models/datasets'-import classNames from '@/utils/classnames'--type IContentProps = ComponentProps<'textarea'>--const Textarea: FC<IContentProps> = React.memo(({- value,- placeholder,- className,- disabled,- ...rest-}) => {- return (- <textarea- className={classNames(- 'disabled:bg-transparent inset-0 outline-none border-none appearance-none resize-none w-full overflow-y-auto',- className,- )}- placeholder={placeholder}- value={value}- disabled={disabled}- {...rest}- />- )-})--Textarea.displayName = 'Textarea'--type IAutoResizeTextAreaProps = ComponentProps<'textarea'> & {- containerRef: React.RefObject<HTMLDivElement>- labelRef: React.RefObject<HTMLDivElement>-}--const AutoResizeTextArea: FC<IAutoResizeTextAreaProps> = React.memo(({- className,- placeholder,- value,- disabled,- containerRef,- labelRef,- ...rest-}) => {- const textareaRef = useRef<HTMLTextAreaElement>(null)- const observerRef = useRef<ResizeObserver>()- const [maxHeight, setMaxHeight] = useState(0)-- useEffect(() => {- const textarea = textareaRef.current- if (!textarea)- return- textarea.style.height = 'auto'- const lineHeight = parseInt(getComputedStyle(textarea).lineHeight)- const textareaHeight = Math.max(textarea.scrollHeight, lineHeight)- textarea.style.height = `${textareaHeight}px`- }, [value])-- useEffect(() => {- const container = containerRef.current- const label = labelRef.current- if (!container || !label)- return- const updateMaxHeight = () => {- const containerHeight = container.clientHeight- const labelHeight = label.clientHeight- const padding = 32- const space = 12- const maxHeight = Math.floor((containerHeight - 2 * labelHeight - padding - space) / 2)- setMaxHeight(maxHeight)- }- updateMaxHeight()- observerRef.current = new ResizeObserver(updateMaxHeight)- observerRef.current.observe(container)- return () => {- observerRef.current?.disconnect()- }- }, [])-- return (- <textarea- ref={textareaRef}- className={classNames(- 'disabled:bg-transparent inset-0 outline-none border-none appearance-none resize-none w-full',- className,- )}- style={{- maxHeight,- }}- placeholder={placeholder}- value={value}- disabled={disabled}- {...rest}- />- )-})--AutoResizeTextArea.displayName = 'AutoResizeTextArea'--type IQATextAreaProps = {- question: string- answer?: string- onQuestionChange: (question: string) => void- onAnswerChange?: (answer: string) => void- isEditMode?: boolean-}--const QATextArea: FC<IQATextAreaProps> = React.memo(({- question,- answer,- onQuestionChange,- onAnswerChange,- isEditMode = true,-}) => {- const { t } = useTranslation()- const containerRef = useRef<HTMLDivElement>(null)- const labelRef = useRef<HTMLDivElement>(null)-- return (- <div ref={containerRef} className='h-full overflow-hidden'>- <div ref={labelRef} className='text-text-tertiary text-xs font-medium mb-1'>QUESTION</div>- <AutoResizeTextArea- className='text-text-secondary text-sm tracking-[-0.07px] caret-[#295EFF]'- value={question}- placeholder={t('datasetDocuments.segment.questionPlaceholder') || ''}- onChange={e => onQuestionChange(e.target.value)}- disabled={!isEditMode}- containerRef={containerRef}- labelRef={labelRef}- />- <div className='text-text-tertiary text-xs font-medium mb-1 mt-6'>ANSWER</div>- <AutoResizeTextArea- className='text-text-secondary text-sm tracking-[-0.07px] caret-[#295EFF]'- value={answer}- placeholder={t('datasetDocuments.segment.answerPlaceholder') || ''}- onChange={e => onAnswerChange?.(e.target.value)}- disabled={!isEditMode}- autoFocus- containerRef={containerRef}- labelRef={labelRef}- />- </div>- )-})--QATextArea.displayName = 'QATextArea'--type IChunkContentProps = {- question: string- answer?: string- onQuestionChange: (question: string) => void- onAnswerChange?: (answer: string) => void- isEditMode?: boolean- docForm: ChunkingMode-}--const ChunkContent: FC<IChunkContentProps> = ({- question,- answer,- onQuestionChange,- onAnswerChange,- isEditMode,- docForm,-}) => {- const { t } = useTranslation()-- if (docForm === ChunkingMode.qa) {- return <QATextArea- question={question}- answer={answer}- onQuestionChange={onQuestionChange}- onAnswerChange={onAnswerChange}- isEditMode={isEditMode}- />- }-- return (- <Textarea- className='h-full w-full pb-6 body-md-regular text-text-secondary tracking-[-0.07px] caret-[#295EFF]'- value={question}- placeholder={t('datasetDocuments.segment.contentPlaceholder') || ''}- onChange={e => onQuestionChange(e.target.value)}- disabled={!isEditMode}- autoFocus- />- )-}--ChunkContent.displayName = 'ChunkContent'--export default React.memo(ChunkContent)diff --git a/web/app/components/datasets/documents/detail/completed/common/dot.tsx b/web/app/components/datasets/documents/detail/completed/common/dot.tsxdeleted file mode 100644index aa6a9f13b76..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/dot.tsx+++ /dev/null@@ -1,11 +0,0 @@-import React from 'react'--const Dot = () => {- return (- <div className='text-text-quaternary system-xs-medium'>·</div>- )-}--Dot.displayName = 'Dot'--export default React.memo(Dot)diff --git a/web/app/components/datasets/documents/detail/completed/common/empty.tsx b/web/app/components/datasets/documents/detail/completed/common/empty.tsxdeleted file mode 100644index cabcb6d4dbc..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/empty.tsx+++ /dev/null@@ -1,78 +0,0 @@-import React, { type FC } from 'react'-import { RiFileList2Line } from '@remixicon/react'-import { useTranslation } from 'react-i18next'--type IEmptyProps = {- onClearFilter: () => void-}--const EmptyCard = React.memo(() => {- return (- <div className='w-full h-32 rounded-xl opacity-30 bg-background-section-burn shrink-0' />- )-})--EmptyCard.displayName = 'EmptyCard'--type LineProps = {- className?: string-}--const Line = React.memo(({- className,-}: LineProps) => {- return (- <svg xmlns="http://www.w3.org/2000/svg" width="2" height="241" viewBox="0 0 2 241" fill="none" className={className}>- <path d="M1 0.5L1 240.5" stroke="url(#paint0_linear_1989_74474)"/>- <defs>- <linearGradient id="paint0_linear_1989_74474" x1="-7.99584" y1="240.5" x2="-7.88094" y2="0.50004" gradientUnits="userSpaceOnUse">- <stop stopColor="white" stopOpacity="0.01"/>- <stop offset="0.503965" stopColor="#101828" stopOpacity="0.08"/>- <stop offset="1" stopColor="white" stopOpacity="0.01"/>- </linearGradient>- </defs>- </svg>- )-})--Line.displayName = 'Line'--const Empty: FC<IEmptyProps> = ({- onClearFilter,-}) => {- const { t } = useTranslation()-- return (- <div className={'h-full relative flex items-center justify-center z-0'}>- <div className='flex flex-col items-center'>- <div className='relative z-10 flex items-center justify-center w-14 h-14 border border-divider-subtle bg-components-card-bg rounded-xl shadow-lg shadow-shadow-shadow-5'>- <RiFileList2Line className='w-6 h-6 text-text-secondary' />- <Line className='absolute -right-[1px] top-1/2 -translate-y-1/2' />- <Line className='absolute -left-[1px] top-1/2 -translate-y-1/2' />- <Line className='absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-90' />- <Line className='absolute top-full left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-90' />- </div>- <div className='text-text-tertiary system-md-regular mt-3'>- {t('datasetDocuments.segment.empty')}- </div>- <button- type='button'- className='text-text-accent system-sm-medium mt-1'- onClick={onClearFilter}- >- {t('datasetDocuments.segment.clearFilter')}- </button>- </div>- <div className='h-full w-full absolute top-0 left-0 flex flex-col gap-y-3 -z-20 overflow-hidden'>- {- Array.from({ length: 10 }).map((_, i) => (- <EmptyCard key={i} />- ))- }- </div>- <div className='h-full w-full absolute top-0 left-0 bg-dataset-chunk-list-mask-bg -z-10' />- </div>- )-}--export default React.memo(Empty)diff --git a/web/app/components/datasets/documents/detail/completed/common/full-screen-drawer.tsx b/web/app/components/datasets/documents/detail/completed/common/full-screen-drawer.tsxdeleted file mode 100644index 0d86d2de61f..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/full-screen-drawer.tsx+++ /dev/null@@ -1,35 +0,0 @@-import React, { type FC } from 'react'-import Drawer from '@/app/components/base/drawer'-import classNames from '@/utils/classnames'--type IFullScreenDrawerProps = {- isOpen: boolean- onClose?: () => void- fullScreen: boolean- children: React.ReactNode-}--const FullScreenDrawer: FC<IFullScreenDrawerProps> = ({- isOpen,- onClose = () => {},- fullScreen,- children,-}) => {- return (- <Drawer- isOpen={isOpen}- onClose={onClose}- panelClassname={classNames('!p-0 bg-components-panel-bg',- fullScreen- ? '!max-w-full !w-full'- : 'mt-16 mr-2 mb-2 !max-w-[560px] !w-[560px] border-[0.5px] border-components-panel-border rounded-xl',- )}- mask={false}- unmount- footer={null}- >- {children}- </Drawer>)-}--export default FullScreenDrawerdiff --git a/web/app/components/datasets/documents/detail/completed/common/keywords.tsx b/web/app/components/datasets/documents/detail/completed/common/keywords.tsxdeleted file mode 100644index 8c85ec1378b..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/keywords.tsx+++ /dev/null@@ -1,47 +0,0 @@-import React, { type FC } from 'react'-import { useTranslation } from 'react-i18next'-import classNames from '@/utils/classnames'-import type { SegmentDetailModel } from '@/models/datasets'-import TagInput from '@/app/components/base/tag-input'--type IKeywordsProps = {- segInfo?: Partial<SegmentDetailModel> & { id: string }- className?: string- keywords: string[]- onKeywordsChange: (keywords: string[]) => void- isEditMode?: boolean- actionType?: 'edit' | 'add' | 'view'-}--const Keywords: FC<IKeywordsProps> = ({- segInfo,- className,- keywords,- onKeywordsChange,- isEditMode,- actionType = 'view',-}) => {- const { t } = useTranslation()- return (- <div className={classNames('flex flex-col', className)}>- <div className='text-text-tertiary system-xs-medium-uppercase'>{t('datasetDocuments.segment.keywords')}</div>- <div className='text-text-tertiary w-full max-h-[200px] overflow-auto flex flex-wrap gap-1'>- {(!segInfo?.keywords?.length && actionType === 'view')- ? '-'- : (- <TagInput- items={keywords}- onChange={newKeywords => onKeywordsChange(newKeywords)}- disableAdd={!isEditMode}- disableRemove={!isEditMode || (keywords.length === 1)}- />- )- }- </div>- </div>- )-}--Keywords.displayName = 'Keywords'--export default React.memo(Keywords)diff --git a/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx b/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsxdeleted file mode 100644index c9356b7f8a8..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx+++ /dev/null@@ -1,131 +0,0 @@-import React, { type FC, useRef, useState } from 'react'-import { useTranslation } from 'react-i18next'-import { RiLoader2Line } from '@remixicon/react'-import { useCountDown } from 'ahooks'-import Modal from '@/app/components/base/modal'-import Button from '@/app/components/base/button'-import { useEventEmitterContextContext } from '@/context/event-emitter'--type IDefaultContentProps = {- onCancel: () => void- onConfirm: () => void-}--const DefaultContent: FC<IDefaultContentProps> = React.memo(({- onCancel,- onConfirm,-}) => {- const { t } = useTranslation()-- return (- <>- <div className='pb-4'>- <span className='text-text-primary title-2xl-semi-bold'>{t('datasetDocuments.segment.regenerationConfirmTitle')}</span>- <p className='text-text-secondary system-md-regular'>{t('datasetDocuments.segment.regenerationConfirmMessage')}</p>- </div>- <div className='flex justify-end gap-x-2 pt-6'>- <Button onClick={onCancel}>- {t('common.operation.cancel')}- </Button>- <Button variant='warning' destructive onClick={onConfirm}>- {t('common.operation.regenerate')}- </Button>- </div>- </>- )-})--DefaultContent.displayName = 'DefaultContent'--const RegeneratingContent: FC = React.memo(() => {- const { t } = useTranslation()-- return (- <>- <div className='pb-4'>- <span className='text-text-primary title-2xl-semi-bold'>{t('datasetDocuments.segment.regeneratingTitle')}</span>- <p className='text-text-secondary system-md-regular'>{t('datasetDocuments.segment.regeneratingMessage')}</p>- </div>- <div className='flex justify-end pt-6'>- <Button variant='warning' destructive disabled className='inline-flex items-center gap-x-0.5'>- <RiLoader2Line className='w-4 h-4 text-components-button-destructive-primary-text-disabled animate-spin' />- <span>{t('common.operation.regenerate')}</span>- </Button>- </div>- </>- )-})--RegeneratingContent.displayName = 'RegeneratingContent'--type IRegenerationCompletedContentProps = {- onClose: () => void-}--const RegenerationCompletedContent: FC<IRegenerationCompletedContentProps> = React.memo(({- onClose,-}) => {- const { t } = useTranslation()- const targetTime = useRef(Date.now() + 5000)- const [countdown] = useCountDown({- targetDate: targetTime.current,- onEnd: () => {- onClose()- },- })-- return (- <>- <div className='pb-4'>- <span className='text-text-primary title-2xl-semi-bold'>{t('datasetDocuments.segment.regenerationSuccessTitle')}</span>- <p className='text-text-secondary system-md-regular'>{t('datasetDocuments.segment.regenerationSuccessMessage')}</p>- </div>- <div className='flex justify-end pt-6'>- <Button variant='primary' onClick={onClose}>- {`${t('common.operation.close')}${countdown === 0 ? '' : `(${Math.round(countdown / 1000)})`}`}- </Button>- </div>- </>- )-})--RegenerationCompletedContent.displayName = 'RegenerationCompletedContent'--type IRegenerationModalProps = {- isShow: boolean- onConfirm: () => void- onCancel: () => void- onClose: () => void-}--const RegenerationModal: FC<IRegenerationModalProps> = ({- isShow,- onConfirm,- onCancel,- onClose,-}) => {- const [loading, setLoading] = useState(false)- const [updateSucceeded, setUpdateSucceeded] = useState(false)- const { eventEmitter } = useEventEmitterContextContext()-- eventEmitter?.useSubscription((v) => {- if (v === 'update-segment') {- setLoading(true)- setUpdateSucceeded(false)- }- if (v === 'update-segment-success')- setUpdateSucceeded(true)- if (v === 'update-segment-done')- setLoading(false)- })-- return (- <Modal isShow={isShow} onClose={() => {}} className='!max-w-[480px] !rounded-2xl'>- {!loading && !updateSucceeded && <DefaultContent onCancel={onCancel} onConfirm={onConfirm} />}- {loading && !updateSucceeded && <RegeneratingContent />}- {!loading && updateSucceeded && <RegenerationCompletedContent onClose={onClose} />}- </Modal>- )-}--export default RegenerationModaldiff --git a/web/app/components/datasets/documents/detail/completed/common/segment-index-tag.tsx b/web/app/components/datasets/documents/detail/completed/common/segment-index-tag.tsxdeleted file mode 100644index 436bfb3543c..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/segment-index-tag.tsx+++ /dev/null@@ -1,40 +0,0 @@-import React, { type FC, useMemo } from 'react'-import { Chunk } from '@/app/components/base/icons/src/public/knowledge'-import cn from '@/utils/classnames'--type ISegmentIndexTagProps = {- positionId?: string | number- label?: string- className?: string- labelPrefix?: string- iconClassName?: string- labelClassName?: string-}--export const SegmentIndexTag: FC<ISegmentIndexTagProps> = ({- positionId,- label,- className,- labelPrefix = 'Chunk',- iconClassName,- labelClassName,-}) => {- const localPositionId = useMemo(() => {- const positionIdStr = String(positionId)- if (positionIdStr.length >= 2)- return `${labelPrefix}-${positionId}`- return `${labelPrefix}-${positionIdStr.padStart(2, '0')}`- }, [positionId, labelPrefix])- return (- <div className={cn('flex items-center', className)}>- <Chunk className={cn('w-3 h-3 p-[1px] text-text-tertiary mr-0.5', iconClassName)} />- <div className={cn('text-text-tertiary system-xs-medium', labelClassName)}>- {label || localPositionId}- </div>- </div>- )-}--SegmentIndexTag.displayName = 'SegmentIndexTag'--export default React.memo(SegmentIndexTag)diff --git a/web/app/components/datasets/documents/detail/completed/common/tag.tsx b/web/app/components/datasets/documents/detail/completed/common/tag.tsxdeleted file mode 100644index bb7261ec91b..00000000000--- a/web/app/components/datasets/documents/detail/completed/common/tag.tsx+++ /dev/null@@ -1,15 +0,0 @@-import React from 'react'-import cn from '@/utils/classnames'--const Tag = ({ text, className }: { text: string; className?: string }) => {- return (- <div className={cn('inline-flex items-center gap-x-0.5', className)}>- <span className='text-text-quaternary text-xs font-medium'>#</span>- <span className='text-text-tertiary text-xs max-w-12 line-clamp-1 shrink-0'>{text}</span>- </div>- )-}--Tag.displayName = 'Tag'--export default React.memo(Tag)diff --git a/web/app/components/datasets/documents/detail/completed/display-toggle.tsx b/web/app/components/datasets/documents/detail/completed/display-toggle.tsxdeleted file mode 100644index b58b20c5f80..00000000000--- a/web/app/components/datasets/documents/detail/completed/display-toggle.tsx+++ /dev/null@@ -1,40 +0,0 @@-import React, { type FC } from 'react'-import { useTranslation } from 'react-i18next'-import { RiLineHeight } from '@remixicon/react'-import Tooltip from '@/app/components/base/tooltip'-import { Collapse } from '@/app/components/base/icons/src/public/knowledge'--type DisplayToggleProps = {- isCollapsed: boolean- toggleCollapsed: () => void-}--const DisplayToggle: FC<DisplayToggleProps> = ({- isCollapsed,- toggleCollapsed,-}) => {- const { t } = useTranslation()-- return (- <Tooltip- popupContent={isCollapsed ? t('datasetDocuments.segment.expandChunks') : t('datasetDocuments.segment.collapseChunks')}- popupClassName='text-text-secondary system-xs-medium border-[0.5px] border-components-panel-border'- >- <button- type='button'- className='flex items-center justify-center p-2 rounded-lg bg-components-button-secondary-bg- border-[0.5px] border-components-button-secondary-border shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]'- onClick={toggleCollapsed}- >- {- isCollapsed- ? <RiLineHeight className='w-4 h-4 text-components-button-secondary-text' />- : <Collapse className='w-4 h-4 text-components-button-secondary-text' />- }- </button>-- </Tooltip>- )-}--export default React.memo(DisplayToggle)diff --git a/web/app/components/datasets/documents/detail/completed/index.tsx b/web/app/components/datasets/documents/detail/completed/index.tsxindex 8385bde04b2..2c9e6ca2ea7 100644--- a/web/app/components/datasets/documents/detail/completed/index.tsx+++ b/web/app/components/datasets/documents/detail/completed/index.tsx@@ -1,79 +1,220 @@'use client'import type { FC } from 'react'-import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import React, { memo, useEffect, useMemo, useState } from 'react'import { useDebounceFn } from 'ahooks'+import { HashtagIcon } from '@heroicons/react/24/solid'import { useTranslation } from 'react-i18next'-import { createContext, useContext, useContextSelector } from 'use-context-selector'-import { useDocumentContext } from '../index'+import { useContext } from 'use-context-selector'+import { isNil, omitBy } from 'lodash-es'+import {+ RiCloseLine,+ RiEditLine,+} from '@remixicon/react'+import { StatusItem } from '../../list'+import { DocumentContext } from '../index'import { ProcessStatus } from '../segment-add'import s from './style.module.css'-import SegmentList from './segment-list'-import DisplayToggle from './display-toggle'-import BatchAction from './common/batch-action'-import SegmentDetail from './segment-detail'-import SegmentCard from './segment-card'-import ChildSegmentList from './child-segment-list'-import NewChildSegment from './new-child-segment'-import FullScreenDrawer from './common/full-screen-drawer'-import ChildSegmentDetail from './child-segment-detail'-import StatusItem from './status-item'-import Pagination from '@/app/components/base/pagination'+import InfiniteVirtualList from './InfiniteVirtualList'import cn from '@/utils/classnames'import { formatNumber } from '@/utils/format'+import Modal from '@/app/components/base/modal'+import Switch from '@/app/components/base/switch'import Divider from '@/app/components/base/divider'import Input from '@/app/components/base/input'import { ToastContext } from '@/app/components/base/toast'import type { Item } from '@/app/components/base/select'import { SimpleSelect } from '@/app/components/base/select'-import { type ChildChunkDetail, ChunkingMode, type SegmentDetailModel, type SegmentUpdater } from '@/models/datasets'-import NewSegment from '@/app/components/datasets/documents/detail/new-segment'+import { deleteSegment, disableSegment, enableSegment, fetchSegments, updateSegment } from '@/service/datasets'+import type { SegmentDetailModel, SegmentUpdater, SegmentsQuery, SegmentsResponse } from '@/models/datasets'+import { asyncRunSafe } from '@/utils'+import type { CommonResponse } from '@/models/common'+import AutoHeightTextarea from '@/app/components/base/auto-height-textarea/common'+import Button from '@/app/components/base/button'+import NewSegmentModal from '@/app/components/datasets/documents/detail/new-segment-modal'+import TagInput from '@/app/components/base/tag-input'import { useEventEmitterContextContext } from '@/context/event-emitter'-import Checkbox from '@/app/components/base/checkbox'-import {- useChildSegmentList,- useChildSegmentListKey,- useDeleteChildSegment,- useDeleteSegment,- useDisableSegment,- useEnableSegment,- useSegmentList,- useSegmentListKey,- useUpdateChildSegment,- useUpdateSegment,-} from '@/service/knowledge/use-segment'-import { useInvalid } from '@/service/use-base'-const DEFAULT_LIMIT = 10--type CurrSegmentType = {- segInfo?: SegmentDetailModel- showModal: boolean- isEditMode?: boolean+export const SegmentIndexTag: FC<{ positionId: string | number; className?: string }> = ({ positionId, className }) => {+ const localPositionId = useMemo(() => {+ const positionIdStr = String(positionId)+ if (positionIdStr.length >= 3)+ return positionId+ return positionIdStr.padStart(3, '0')+ }, [positionId])+ return (+ <div className={`text-gray-500 border border-gray-200 box-border flex items-center rounded-md italic text-[11px] pl-1 pr-1.5 font-medium ${className ?? ''}`}>+ <HashtagIcon className='w-3 h-3 text-gray-400 fill-current mr-1 stroke-current stroke-1' />+ {localPositionId}+ </div>+ )}-type CurrChildChunkType = {- childChunkInfo?: ChildChunkDetail- showModal: boolean+type ISegmentDetailProps = {+ embeddingAvailable: boolean+ segInfo?: Partial<SegmentDetailModel> & { id: string }+ onChangeSwitch?: (segId: string, enabled: boolean) => Promise<void>+ onUpdate: (segmentId: string, q: string, a: string, k: string[]) => void+ onCancel: () => void+ archived?: boolean}+/**+ * Show all the contents of the segment+ */+const SegmentDetailComponent: FC<ISegmentDetailProps> = ({+ embeddingAvailable,+ segInfo,+ archived,+ onChangeSwitch,+ onUpdate,+ onCancel,+}) => {+ const { t } = useTranslation()+ const [isEditing, setIsEditing] = useState(false)+ const [question, setQuestion] = useState(segInfo?.content || '')+ const [answer, setAnswer] = useState(segInfo?.answer || '')+ const [keywords, setKeywords] = useState<string[]>(segInfo?.keywords || [])+ const { eventEmitter } = useEventEmitterContextContext()+ const [loading, setLoading] = useState(false)++ eventEmitter?.useSubscription((v) => {+ if (v === 'update-segment')+ setLoading(true)+ else+ setLoading(false)+ })++ const handleCancel = () => {+ setIsEditing(false)+ setQuestion(segInfo?.content || '')+ setAnswer(segInfo?.answer || '')+ setKeywords(segInfo?.keywords || [])+ }+ const handleSave = () => {+ onUpdate(segInfo?.id || '', question, answer, keywords)+ }-type SegmentListContextValue = {- isCollapsed: boolean- fullScreen: boolean- toggleFullScreen: (fullscreen?: boolean) => void- currSegment: CurrSegmentType- currChildChunk: CurrChildChunkType-}+ const renderContent = () => {+ if (segInfo?.answer) {+ return (+ <>+ <div className='mb-1 text-xs font-medium text-gray-500'>QUESTION</div>+ <AutoHeightTextarea+ outerClassName='mb-4'+ className='leading-6 text-md text-gray-800'+ value={question}+ placeholder={t('datasetDocuments.segment.questionPlaceholder') || ''}+ onChange={e => setQuestion(e.target.value)}+ disabled={!isEditing}+ />+ <div className='mb-1 text-xs font-medium text-gray-500'>ANSWER</div>+ <AutoHeightTextarea+ outerClassName='mb-4'+ className='leading-6 text-md text-gray-800'+ value={answer}+ placeholder={t('datasetDocuments.segment.answerPlaceholder') || ''}+ onChange={e => setAnswer(e.target.value)}+ disabled={!isEditing}+ autoFocus+ />+ </>+ )+ }-const SegmentListContext = createContext<SegmentListContextValue>({- isCollapsed: true,- fullScreen: false,- toggleFullScreen: () => {},- currSegment: { showModal: false },- currChildChunk: { showModal: false },-})+ return (+ <AutoHeightTextarea+ className='leading-6 text-md text-gray-800'+ value={question}+ placeholder={t('datasetDocuments.segment.contentPlaceholder') || ''}+ onChange={e => setQuestion(e.target.value)}+ disabled={!isEditing}+ autoFocus+ />+ )+ }-export const useSegmentListContext = (selector: (value: SegmentListContextValue) => any) => {- return useContextSelector(SegmentListContext, selector)+ return (+ <div className={'flex flex-col relative'}>+ <div className='absolute right-0 top-0 flex items-center h-7'>+ {isEditing && (+ <>+ <Button+ onClick={handleCancel}>+ {t('common.operation.cancel')}+ </Button>+ <Button+ variant='primary'+ className='ml-3'+ onClick={handleSave}+ disabled={loading}+ >+ {t('common.operation.save')}+ </Button>+ </>+ )}+ {!isEditing && !archived && embeddingAvailable && (+ <>+ <div className='group relative flex justify-center items-center w-6 h-6 hover:bg-gray-100 rounded-md cursor-pointer'>+ <div className={cn(s.editTip, 'hidden items-center absolute -top-10 px-3 h-[34px] bg-white rounded-lg whitespace-nowrap text-xs font-semibold text-gray-700 group-hover:flex')}>{t('common.operation.edit')}</div>+ <RiEditLine className='w-4 h-4 text-gray-500' onClick={() => setIsEditing(true)} />+ </div>+ <div className='mx-3 w-[1px] h-3 bg-gray-200' />+ </>+ )}+ <div className='flex justify-center items-center w-6 h-6 cursor-pointer' onClick={onCancel}>+ <RiCloseLine className='w-4 h-4 text-gray-500' />+ </div>+ </div>+ <SegmentIndexTag positionId={segInfo?.position || ''} className='w-fit mt-[2px] mb-6' />+ <div className={s.segModalContent}>{renderContent()}</div>+ <div className={s.keywordTitle}>{t('datasetDocuments.segment.keywords')}</div>+ <div className={s.keywordWrapper}>+ {!segInfo?.keywords?.length+ ? '-'+ : (+ <TagInput+ items={keywords}+ onChange={newKeywords => setKeywords(newKeywords)}+ disableAdd={!isEditing}+ disableRemove={!isEditing || (keywords.length === 1)}+ />+ )+ }+ </div>+ <div className={cn(s.footer, s.numberInfo)}>+ <div className='flex items-center flex-wrap gap-y-2'>+ <div className={cn(s.commonIcon, s.typeSquareIcon)} /><span className='mr-8'>{formatNumber(segInfo?.word_count as number)} {t('datasetDocuments.segment.characters')}</span>+ <div className={cn(s.commonIcon, s.targetIcon)} /><span className='mr-8'>{formatNumber(segInfo?.hit_count as number)} {t('datasetDocuments.segment.hitCount')}</span>+ <div className={cn(s.commonIcon, s.bezierCurveIcon)} /><span className={s.hashText}>{t('datasetDocuments.segment.vectorHash')}{segInfo?.index_node_hash}</span>+ </div>+ <div className='flex items-center'>+ <StatusItem status={segInfo?.enabled ? 'enabled' : 'disabled'} reverse textCls='text-gray-500 text-xs' />+ {embeddingAvailable && (+ <>+ <Divider type='vertical' className='!h-2' />+ <Switch+ size='md'+ defaultValue={segInfo?.enabled}+ onChange={async (val) => {+ await onChangeSwitch?.(segInfo?.id || '', val)+ }}+ disabled={archived}+ />+ </>+ )}+ </div>+ </div>+ </div>+ )+}+export const SegmentDetail = memo(SegmentDetailComponent)++export const splitArray = (arr: any[], size = 3) => {+ if (!arr || !arr.length)+ return []+ const result = []+ for (let i = 0; i < arr.length; i += size)+ result.push(arr.slice(i, i + size))+ return result}type ICompletedProps = {@@ -82,6 +223,7 @@ type ICompletedProps = {onNewSegmentModalChange: (state: boolean) => voidimportStatus: ProcessStatus | string | undefinedarchived?: boolean+ // data: Array<{}> // all/part segments}/*** Embedding done, show list of all segments@@ -96,42 +238,22 @@ const Completed: FC<ICompletedProps> = ({}) => {const { t } = useTranslation()const { notify } = useContext(ToastContext)- const datasetId = useDocumentContext(s => s.datasetId) || ''- const documentId = useDocumentContext(s => s.documentId) || ''- const docForm = useDocumentContext(s => s.docForm)- const mode = useDocumentContext(s => s.mode)- const parentMode = useDocumentContext(s => s.parentMode)+ const { datasetId = '', documentId = '', docForm } = useContext(DocumentContext)// the current segment id and whether to show the modal- const [currSegment, setCurrSegment] = useState<CurrSegmentType>({ showModal: false })- const [currChildChunk, setCurrChildChunk] = useState<CurrChildChunkType>({ showModal: false })- const [currChunkId, setCurrChunkId] = useState('')+ const [currSegment, setCurrSegment] = useState<{ segInfo?: SegmentDetailModel; showModal: boolean }>({ showModal: false })const [inputValue, setInputValue] = useState<string>('') // the input valueconst [searchValue, setSearchValue] = useState<string>('') // the search valueconst [selectedStatus, setSelectedStatus] = useState<boolean | 'all'>('all') // the selected status, enabled/disabled/undefined- const [segments, setSegments] = useState<SegmentDetailModel[]>([]) // all segments data- const [childSegments, setChildSegments] = useState<ChildChunkDetail[]>([]) // all child segments data- const [selectedSegmentIds, setSelectedSegmentIds] = useState<string[]>([])+ const [lastSegmentsRes, setLastSegmentsRes] = useState<SegmentsResponse | undefined>(undefined)+ const [allSegments, setAllSegments] = useState<Array<SegmentDetailModel[]>>([]) // all segments data+ const [loading, setLoading] = useState(false)+ const [total, setTotal] = useState<number | undefined>()const { eventEmitter } = useEventEmitterContextContext()- const [isCollapsed, setIsCollapsed] = useState(true)- const [currentPage, setCurrentPage] = useState(1) // start from 1- const [limit, setLimit] = useState(DEFAULT_LIMIT)- const [fullScreen, setFullScreen] = useState(false)- const [showNewChildSegmentModal, setShowNewChildSegmentModal] = useState(false)-- const segmentListRef = useRef<HTMLDivElement>(null)- const childSegmentListRef = useRef<HTMLDivElement>(null)- const needScrollToBottom = useRef(false)- const statusList = useRef<Item[]>([- { value: 'all', name: t('datasetDocuments.list.index.all') },- { value: 0, name: t('datasetDocuments.list.status.disabled') },- { value: 1, name: t('datasetDocuments.list.status.enabled') },- ])const { run: handleSearch } = useDebounceFn(() => {setSearchValue(inputValue)- setCurrentPage(1)}, { wait: 500 })const handleInputChange = (value: string) => {@@ -141,145 +263,78 @@ const Completed: FC<ICompletedProps> = ({const onChangeStatus = ({ value }: Item) => {setSelectedStatus(value === 'all' ? 'all' : !!value)- setCurrentPage(1)}- const isFullDocMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'full-doc'- }, [mode, parentMode])-- const { isFetching: isLoadingSegmentList, data: segmentListData } = useSegmentList(- {+ const getSegments = async (needLastId?: boolean) => {+ const finalLastId = lastSegmentsRes?.data?.[lastSegmentsRes.data.length - 1]?.id || ''+ setLoading(true)+ const [e, res] = await asyncRunSafe<SegmentsResponse>(fetchSegments({datasetId,documentId,- params: {- page: isFullDocMode ? 1 : currentPage,- limit: isFullDocMode ? 10 : limit,- keyword: isFullDocMode ? '' : searchValue,- enabled: selectedStatus === 'all' ? 'all' : !!selectedStatus,- },- },- currentPage === 0,- )- const invalidSegmentList = useInvalid(useSegmentListKey)-- useEffect(() => {- if (segmentListData) {- setSegments(segmentListData.data || [])- if (segmentListData.total_pages < currentPage)- setCurrentPage(segmentListData.total_pages)- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [segmentListData])-- useEffect(() => {- if (segmentListRef.current && needScrollToBottom.current) {- segmentListRef.current.scrollTo({ top: segmentListRef.current.scrollHeight, behavior: 'smooth' })- needScrollToBottom.current = false- }- }, [segments])-- const { isFetching: isLoadingChildSegmentList, data: childChunkListData } = useChildSegmentList(- {- datasetId,- documentId,- segmentId: segments[0]?.id || '',- params: {- page: currentPage,- limit,+ params: omitBy({+ last_id: !needLastId ? undefined : finalLastId,+ limit: 12,keyword: searchValue,- },- },- !isFullDocMode || segments.length === 0 || currentPage === 0,- )- const invalidChildSegmentList = useInvalid(useChildSegmentListKey)-- useEffect(() => {- if (childSegmentListRef.current && needScrollToBottom.current) {- childSegmentListRef.current.scrollTo({ top: childSegmentListRef.current.scrollHeight, behavior: 'smooth' })- needScrollToBottom.current = false- }- }, [childSegments])-- useEffect(() => {- if (childChunkListData) {- setChildSegments(childChunkListData.data || [])- if (childChunkListData.total_pages < currentPage)- setCurrentPage(childChunkListData.total_pages)+ enabled: selectedStatus === 'all' ? 'all' : !!selectedStatus,+ }, isNil) as SegmentsQuery,+ }) as Promise<SegmentsResponse>)+ if (!e) {+ setAllSegments([...(!needLastId ? [] : allSegments), ...splitArray(res.data || [])])+ setLastSegmentsRes(res)+ if (!lastSegmentsRes || !needLastId)+ setTotal(res?.total || 0)}- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [childChunkListData])-- const resetList = useCallback(() => {- setSegments([])- setSelectedSegmentIds([])- invalidSegmentList()- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [])-- const resetChildList = useCallback(() => {- setChildSegments([])- invalidChildSegmentList()- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [])+ setLoading(false)+ }- const onClickCard = (detail: SegmentDetailModel, isEditMode = false) => {- setCurrSegment({ segInfo: detail, showModal: true, isEditMode })+ const resetList = () => {+ setLastSegmentsRes(undefined)+ setAllSegments([])+ setLoading(false)+ setTotal(undefined)+ getSegments(false)}- const onCloseSegmentDetail = useCallback(() => {- setCurrSegment({ showModal: false })- setFullScreen(false)- }, [])+ const onClickCard = (detail: SegmentDetailModel) => {+ setCurrSegment({ segInfo: detail, showModal: true })+ }- const { mutateAsync: enableSegment } = useEnableSegment()- const { mutateAsync: disableSegment } = useDisableSegment()+ const onCloseModal = () => {+ setCurrSegment({ ...currSegment, showModal: false })+ }- const onChangeSwitch = useCallback(async (enable: boolean, segId?: string) => {- const operationApi = enable ? enableSegment : disableSegment- await operationApi({ datasetId, documentId, segmentIds: segId ? [segId] : selectedSegmentIds }, {- onSuccess: () => {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- for (const seg of segments) {- if (segId ? seg.id === segId : selectedSegmentIds.includes(seg.id))- seg.enabled = enable+ const onChangeSwitch = async (segId: string, enabled: boolean) => {+ const opApi = enabled ? enableSegment : disableSegment+ const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, segmentId: segId }) as Promise<CommonResponse>)+ if (!e) {+ notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })+ for (const item of allSegments) {+ for (const seg of item) {+ if (seg.id === segId)+ seg.enabled = enabled}- setSegments([...segments])- },- onError: () => {- notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })- },- })- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [datasetId, documentId, selectedSegmentIds, segments])-- const { mutateAsync: deleteSegment } = useDeleteSegment()-- const onDelete = useCallback(async (segId?: string) => {- await deleteSegment({ datasetId, documentId, segmentIds: segId ? [segId] : selectedSegmentIds }, {- onSuccess: () => {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- resetList()- !segId && setSelectedSegmentIds([])- },- onError: () => {- notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })- },- })- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [datasetId, documentId, selectedSegmentIds])+ }+ setAllSegments([...allSegments])+ }+ else {+ notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })+ }+ }- const { mutateAsync: updateSegment } = useUpdateSegment()+ const onDelete = async (segId: string) => {+ const [e] = await asyncRunSafe<CommonResponse>(deleteSegment({ datasetId, documentId, segmentId: segId }) as Promise<CommonResponse>)+ if (!e) {+ notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })+ resetList()+ }+ else {+ notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })+ }+ }- const handleUpdateSegment = useCallback(async (- segmentId: string,- question: string,- answer: string,- keywords: string[],- needRegenerate = false,- ) => {+ const handleUpdateSegment = async (segmentId: string, question: string, answer: string, keywords: string[]) => {const params: SegmentUpdater = { content: '' }- if (docForm === ChunkingMode.qa) {+ if (docForm === 'qa_model') {if (!question.trim())return notify({ type: 'error', message: t('datasetDocuments.segment.questionEmpty') })if (!answer.trim())@@ -298,259 +353,55 @@ const Completed: FC<ICompletedProps> = ({if (keywords.length)params.keywords = keywords- if (needRegenerate)- params.regenerate_child_chunks = needRegenerate-- eventEmitter?.emit('update-segment')- await updateSegment({ datasetId, documentId, segmentId, body: params }, {- onSuccess(res) {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- if (!needRegenerate)- onCloseSegmentDetail()- for (const seg of segments) {+ try {+ eventEmitter?.emit('update-segment')+ const res = await updateSegment({ datasetId, documentId, segmentId, body: params })+ notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })+ onCloseModal()+ for (const item of allSegments) {+ for (const seg of item) {if (seg.id === segmentId) {seg.answer = res.data.answerseg.content = res.data.contentseg.keywords = res.data.keywordsseg.word_count = res.data.word_countseg.hit_count = res.data.hit_count+ seg.index_node_hash = res.data.index_node_hashseg.enabled = res.data.enabled- seg.updated_at = res.data.updated_at- seg.child_chunks = res.data.child_chunks}}- setSegments([...segments])- eventEmitter?.emit('update-segment-success')- },- onSettled() {- eventEmitter?.emit('update-segment-done')- },- })- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [segments, datasetId, documentId])-- useEffect(() => {- if (importStatus === ProcessStatus.COMPLETED)- resetList()- }, [importStatus, resetList])-- const onCancelBatchOperation = useCallback(() => {- setSelectedSegmentIds([])- }, [])-- const onSelected = useCallback((segId: string) => {- setSelectedSegmentIds(prev =>- prev.includes(segId)- ? prev.filter(id => id !== segId)- : [...prev, segId],- )- }, [])-- const isAllSelected = useMemo(() => {- return segments.length > 0 && segments.every(seg => selectedSegmentIds.includes(seg.id))- }, [segments, selectedSegmentIds])-- const isSomeSelected = useMemo(() => {- return segments.some(seg => selectedSegmentIds.includes(seg.id))- }, [segments, selectedSegmentIds])-- const onSelectedAll = useCallback(() => {- setSelectedSegmentIds((prev) => {- const currentAllSegIds = segments.map(seg => seg.id)- const prevSelectedIds = prev.filter(item => !currentAllSegIds.includes(item))- return [...prevSelectedIds, ...((isAllSelected || selectedSegmentIds.length > 0) ? [] : currentAllSegIds)]- })- }, [segments, isAllSelected, selectedSegmentIds])-- const totalText = useMemo(() => {- const isSearch = searchValue !== '' || selectedStatus !== 'all'- if (!isSearch) {- const total = segmentListData?.total ? formatNumber(segmentListData.total) : '--'- const count = total === '--' ? 0 : segmentListData!.total- const translationKey = (mode === 'hierarchical' && parentMode === 'paragraph')- ? 'datasetDocuments.segment.parentChunks'- : 'datasetDocuments.segment.chunks'- return `${total} ${t(translationKey, { count })}`- }- else {- const total = typeof segmentListData?.total === 'number' ? formatNumber(segmentListData.total) : 0- const count = segmentListData?.total || 0- return `${total} ${t('datasetDocuments.segment.searchResults', { count })}`- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [segmentListData?.total, mode, parentMode, searchValue, selectedStatus])-- const toggleFullScreen = useCallback(() => {- setFullScreen(!fullScreen)- }, [fullScreen])-- const viewNewlyAddedChunk = useCallback(async () => {- const totalPages = segmentListData?.total_pages || 0- const total = segmentListData?.total || 0- const newPage = Math.ceil((total + 1) / limit)- needScrollToBottom.current = true- if (newPage > totalPages) {- setCurrentPage(totalPages + 1)- }- else {- resetList()- currentPage !== totalPages && setCurrentPage(totalPages)- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [segmentListData, limit, currentPage])-- const { mutateAsync: deleteChildSegment } = useDeleteChildSegment()-- const onDeleteChildChunk = useCallback(async (segmentId: string, childChunkId: string) => {- await deleteChildSegment(- { datasetId, documentId, segmentId, childChunkId },- {- onSuccess: () => {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- if (parentMode === 'paragraph')- resetList()- else- resetChildList()- },- onError: () => {- notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })- },- },- )- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [datasetId, documentId, parentMode])-- const handleAddNewChildChunk = useCallback((parentChunkId: string) => {- setShowNewChildSegmentModal(true)- setCurrChunkId(parentChunkId)- }, [])-- const onSaveNewChildChunk = useCallback((newChildChunk?: ChildChunkDetail) => {- if (parentMode === 'paragraph') {- for (const seg of segments) {- if (seg.id === currChunkId)- seg.child_chunks?.push(newChildChunk!)}- setSegments([...segments])+ setAllSegments([...allSegments])}- else {- resetChildList()- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [parentMode, currChunkId, segments])-- const viewNewlyAddedChildChunk = useCallback(() => {- const totalPages = childChunkListData?.total_pages || 0- const total = childChunkListData?.total || 0- const newPage = Math.ceil((total + 1) / limit)- needScrollToBottom.current = true- if (newPage > totalPages) {- setCurrentPage(totalPages + 1)- }- else {- resetChildList()- currentPage !== totalPages && setCurrentPage(totalPages)+ finally {+ eventEmitter?.emit('')}- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [childChunkListData, limit, currentPage])-- const onClickSlice = useCallback((detail: ChildChunkDetail) => {- setCurrChildChunk({ childChunkInfo: detail, showModal: true })- setCurrChunkId(detail.segment_id)- }, [])-- const onCloseChildSegmentDetail = useCallback(() => {- setCurrChildChunk({ showModal: false })- setFullScreen(false)- }, [])-- const { mutateAsync: updateChildSegment } = useUpdateChildSegment()-- const handleUpdateChildChunk = useCallback(async (- segmentId: string,- childChunkId: string,- content: string,- ) => {- const params: SegmentUpdater = { content: '' }- if (!content.trim())- return notify({ type: 'error', message: t('datasetDocuments.segment.contentEmpty') })-- params.content = content+ }- eventEmitter?.emit('update-child-segment')- await updateChildSegment({ datasetId, documentId, segmentId, childChunkId, body: params }, {- onSuccess: (res) => {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- onCloseChildSegmentDetail()- if (parentMode === 'paragraph') {- for (const seg of segments) {- if (seg.id === segmentId) {- for (const childSeg of seg.child_chunks!) {- if (childSeg.id === childChunkId) {- childSeg.content = res.data.content- childSeg.type = res.data.type- childSeg.word_count = res.data.word_count- childSeg.updated_at = res.data.updated_at- }- }- }- }- setSegments([...segments])- }- else {- for (const childSeg of childSegments) {- if (childSeg.id === childChunkId) {- childSeg.content = res.data.content- childSeg.type = res.data.type- childSeg.word_count = res.data.word_count- childSeg.updated_at = res.data.updated_at- }- }- setChildSegments([...childSegments])- }- },- onSettled: () => {- eventEmitter?.emit('update-child-segment-done')- },- })- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [segments, childSegments, datasetId, documentId, parentMode])+ useEffect(() => {+ if (lastSegmentsRes !== undefined)+ getSegments(false)+ }, [selectedStatus, searchValue])- const onClearFilter = useCallback(() => {- setInputValue('')- setSearchValue('')- setSelectedStatus('all')- setCurrentPage(1)- }, [])+ useEffect(() => {+ if (importStatus === ProcessStatus.COMPLETED)+ resetList()+ }, [importStatus])return (- <SegmentListContext.Provider value={{- isCollapsed,- fullScreen,- toggleFullScreen,- currSegment,- currChildChunk,- }}>- {/* Menu Bar */}- {!isFullDocMode && <div className={s.docSearchWrapper}>- <Checkbox- className='shrink-0'- checked={isAllSelected}- mixed={!isAllSelected && isSomeSelected}- onCheck={onSelectedAll}- disabled={isLoadingSegmentList}- />- <div className={'system-sm-semibold-uppercase pl-5 text-text-secondary flex-1'}>{totalText}</div>+ <>+ <div className={s.docSearchWrapper}>+ <div className={s.totalText}>{total ? formatNumber(total) : '--'} {t('datasetDocuments.segment.paragraphs')}</div><SimpleSelectonSelect={onChangeStatus}- items={statusList.current}+ items={[+ { value: 'all', name: t('datasetDocuments.list.index.all') },+ { value: 0, name: t('datasetDocuments.list.status.disabled') },+ { value: 1, name: t('datasetDocuments.list.status.enabled') },+ ]}defaultValue={'all'}className={s.select}- wrapperClassName='h-fit mr-2'- optionWrapClassName='w-[160px]'- optionClassName='p-0'- renderOption={({ item, selected }) => <StatusItem item={item} selected={selected} />}- />+ wrapperClassName='h-fit w-[120px] mr-2' /><InputshowLeftIconshowClearIcon@@ -559,133 +410,35 @@ const Completed: FC<ICompletedProps> = ({onChange={e => handleInputChange(e.target.value)}onClear={() => handleInputChange('')}/>- <Divider type='vertical' className='h-3.5 mx-3' />- <DisplayToggle isCollapsed={isCollapsed} toggleCollapsed={() => setIsCollapsed(!isCollapsed)} />- </div>}- {/* Segment list */}- {- isFullDocMode- ? <div className={cn(- 'flex flex-col grow overflow-x-hidden',- (isLoadingSegmentList || isLoadingChildSegmentList) ? 'overflow-y-hidden' : 'overflow-y-auto',- )}>- <SegmentCard- detail={segments[0]}- onClick={() => onClickCard(segments[0])}- loading={isLoadingSegmentList}- focused={{- segmentIndex: currSegment?.segInfo?.id === segments[0]?.id,- segmentContent: currSegment?.segInfo?.id === segments[0]?.id,- }}- />- <ChildSegmentList- parentChunkId={segments[0]?.id}- onDelete={onDeleteChildChunk}- childChunks={childSegments}- handleInputChange={handleInputChange}- handleAddNewChildChunk={handleAddNewChildChunk}- onClickSlice={onClickSlice}- enabled={!archived}- total={childChunkListData?.total || 0}- inputValue={inputValue}- onClearFilter={onClearFilter}- isLoading={isLoadingSegmentList || isLoadingChildSegmentList}- />- </div>- : <SegmentList- ref={segmentListRef}- embeddingAvailable={embeddingAvailable}- isLoading={isLoadingSegmentList}- items={segments}- selectedSegmentIds={selectedSegmentIds}- onSelected={onSelected}- onChangeSwitch={onChangeSwitch}- onDelete={onDelete}- onClick={onClickCard}- archived={archived}- onDeleteChildChunk={onDeleteChildChunk}- handleAddNewChildChunk={handleAddNewChildChunk}- onClickSlice={onClickSlice}- onClearFilter={onClearFilter}- />- }- {/* Pagination */}- <Divider type='horizontal' className='w-auto h-[1px] my-0 mx-6 bg-divider-subtle' />- <Pagination- current={currentPage - 1}- onChange={cur => setCurrentPage(cur + 1)}- total={(isFullDocMode ? childChunkListData?.total : segmentListData?.total) || 0}- limit={limit}- onLimitChange={limit => setLimit(limit)}- className={isFullDocMode ? 'px-3' : ''}+ </div>+ <InfiniteVirtualList+ embeddingAvailable={embeddingAvailable}+ hasNextPage={lastSegmentsRes?.has_more ?? true}+ isNextPageLoading={loading}+ items={allSegments}+ loadNextPage={getSegments}+ onChangeSwitch={onChangeSwitch}+ onDelete={onDelete}+ onClick={onClickCard}+ archived={archived}/>- {/* Edit or view segment detail */}- <FullScreenDrawer- isOpen={currSegment.showModal}- fullScreen={fullScreen}- >+ <Modal isShow={currSegment.showModal} onClose={() => { }} className='!max-w-[640px] !overflow-visible'><SegmentDetail+ embeddingAvailable={embeddingAvailable}segInfo={currSegment.segInfo ?? { id: '' }}- docForm={docForm}- isEditMode={currSegment.isEditMode}+ onChangeSwitch={onChangeSwitch}onUpdate={handleUpdateSegment}- onCancel={onCloseSegmentDetail}- />- </FullScreenDrawer>- {/* Create New Segment */}- <FullScreenDrawer- isOpen={showNewSegmentModal}- fullScreen={fullScreen}- >- <NewSegment- docForm={docForm}- onCancel={() => {- onNewSegmentModalChange(false)- setFullScreen(false)- }}- onSave={resetList}- viewNewlyAddedChunk={viewNewlyAddedChunk}+ onCancel={onCloseModal}+ archived={archived}/>- </FullScreenDrawer>- {/* Edit or view child segment detail */}- <FullScreenDrawer- isOpen={currChildChunk.showModal}- fullScreen={fullScreen}- >- <ChildSegmentDetail- chunkId={currChunkId}- childChunkInfo={currChildChunk.childChunkInfo ?? { id: '' }}- docForm={docForm}- onUpdate={handleUpdateChildChunk}- onCancel={onCloseChildSegmentDetail}- />- </FullScreenDrawer>- {/* Create New Child Segment */}- <FullScreenDrawer- isOpen={showNewChildSegmentModal}- fullScreen={fullScreen}- >- <NewChildSegment- chunkId={currChunkId}- onCancel={() => {- setShowNewChildSegmentModal(false)- setFullScreen(false)- }}- onSave={onSaveNewChildChunk}- viewNewlyAddedChildChunk={viewNewlyAddedChildChunk}- />- </FullScreenDrawer>- {/* Batch Action Buttons */}- {selectedSegmentIds.length > 0- && <BatchAction- className='absolute left-0 bottom-16 z-20'- selectedIds={selectedSegmentIds}- onBatchEnable={onChangeSwitch.bind(null, true, '')}- onBatchDisable={onChangeSwitch.bind(null, false, '')}- onBatchDelete={onDelete.bind(null, '')}- onCancel={onCancelBatchOperation}- />}- </SegmentListContext.Provider>+ </Modal>+ <NewSegmentModal+ isShow={showNewSegmentModal}+ docForm={docForm}+ onCancel={() => onNewSegmentModalChange(false)}+ onSave={resetList}+ />+ </>)}diff --git a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx b/web/app/components/datasets/documents/detail/completed/new-child-segment.tsxdeleted file mode 100644index 55766d8ac4a..00000000000--- a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx+++ /dev/null@@ -1,175 +0,0 @@-import { memo, useMemo, useRef, useState } from 'react'-import type { FC } from 'react'-import { useTranslation } from 'react-i18next'-import { useContext } from 'use-context-selector'-import { useParams } from 'next/navigation'-import { RiCloseLine, RiExpandDiagonalLine } from '@remixicon/react'-import { useShallow } from 'zustand/react/shallow'-import { useDocumentContext } from '../index'-import { SegmentIndexTag } from './common/segment-index-tag'-import ActionButtons from './common/action-buttons'-import ChunkContent from './common/chunk-content'-import AddAnother from './common/add-another'-import Dot from './common/dot'-import { useSegmentListContext } from './index'-import { useStore as useAppStore } from '@/app/components/app/store'-import { ToastContext } from '@/app/components/base/toast'-import { type ChildChunkDetail, ChunkingMode, type SegmentUpdater } from '@/models/datasets'-import classNames from '@/utils/classnames'-import { formatNumber } from '@/utils/format'-import Divider from '@/app/components/base/divider'-import { useAddChildSegment } from '@/service/knowledge/use-segment'--type NewChildSegmentModalProps = {- chunkId: string- onCancel: () => void- onSave: (ChildChunk?: ChildChunkDetail) => void- viewNewlyAddedChildChunk?: () => void-}--const NewChildSegmentModal: FC<NewChildSegmentModalProps> = ({- chunkId,- onCancel,- onSave,- viewNewlyAddedChildChunk,-}) => {- const { t } = useTranslation()- const { notify } = useContext(ToastContext)- const [content, setContent] = useState('')- const { datasetId, documentId } = useParams<{ datasetId: string; documentId: string }>()- const [loading, setLoading] = useState(false)- const [addAnother, setAddAnother] = useState(true)- const fullScreen = useSegmentListContext(s => s.fullScreen)- const toggleFullScreen = useSegmentListContext(s => s.toggleFullScreen)- const { appSidebarExpand } = useAppStore(useShallow(state => ({- appSidebarExpand: state.appSidebarExpand,- })))- const parentMode = useDocumentContext(s => s.parentMode)-- const refreshTimer = useRef<any>(null)-- const isFullDocMode = useMemo(() => {- return parentMode === 'full-doc'- }, [parentMode])-- const CustomButton = <>- <Divider type='vertical' className='h-3 mx-1 bg-divider-regular' />- <button- type='button'- className='text-text-accent system-xs-semibold'- onClick={() => {- clearTimeout(refreshTimer.current)- viewNewlyAddedChildChunk?.()- }}>- {t('common.operation.view')}- </button>- </>-- const handleCancel = (actionType: 'esc' | 'add' = 'esc') => {- if (actionType === 'esc' || !addAnother)- onCancel()- setContent('')- }-- const { mutateAsync: addChildSegment } = useAddChildSegment()-- const handleSave = async () => {- const params: SegmentUpdater = { content: '' }-- if (!content.trim())- return notify({ type: 'error', message: t('datasetDocuments.segment.contentEmpty') })-- params.content = content-- setLoading(true)- await addChildSegment({ datasetId, documentId, segmentId: chunkId, body: params }, {- onSuccess(res) {- notify({- type: 'success',- message: t('datasetDocuments.segment.childChunkAdded'),- className: `!w-[296px] !bottom-0 ${appSidebarExpand === 'expand' ? '!left-[216px]' : '!left-14'}- !top-auto !right-auto !mb-[52px] !ml-11`,- customComponent: isFullDocMode && CustomButton,- })- handleCancel('add')- if (isFullDocMode) {- refreshTimer.current = setTimeout(() => {- onSave()- }, 3000)- }- else {- onSave(res.data)- }- },- onSettled() {- setLoading(false)- },- })- }-- const wordCountText = useMemo(() => {- const count = content.length- return `${formatNumber(count)} ${t('datasetDocuments.segment.characters', { count })}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [content.length])-- return (- <div className={'flex flex-col h-full'}>- <div className={classNames('flex items-center justify-between', fullScreen ? 'py-3 pr-4 pl-6 border border-divider-subtle' : 'pt-3 pr-3 pl-4')}>- <div className='flex flex-col'>- <div className='text-text-primary system-xl-semibold'>{t('datasetDocuments.segment.addChildChunk')}</div>- <div className='flex items-center gap-x-2'>- <SegmentIndexTag label={t('datasetDocuments.segment.newChildChunk') as string} />- <Dot />- <span className='text-text-tertiary system-xs-medium'>{wordCountText}</span>- </div>- </div>- <div className='flex items-center'>- {fullScreen && (- <>- <AddAnother className='mr-3' isChecked={addAnother} onCheck={() => setAddAnother(!addAnother)} />- <ActionButtons- handleCancel={handleCancel.bind(null, 'esc')}- handleSave={handleSave}- loading={loading}- actionType='add'- isChildChunk={true}- />- <Divider type='vertical' className='h-3.5 bg-divider-regular ml-4 mr-2' />- </>- )}- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer mr-1' onClick={toggleFullScreen}>- <RiExpandDiagonalLine className='w-4 h-4 text-text-tertiary' />- </div>- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer' onClick={handleCancel.bind(null, 'esc')}>- <RiCloseLine className='w-4 h-4 text-text-tertiary' />- </div>- </div>- </div>- <div className={classNames('flex grow w-full', fullScreen ? 'flex-row justify-center px-6 pt-6' : 'py-3 px-4')}>- <div className={classNames('break-all overflow-hidden whitespace-pre-line h-full', fullScreen ? 'w-1/2' : 'w-full')}>- <ChunkContent- docForm={ChunkingMode.parentChild}- question={content}- onQuestionChange={content => setContent(content)}- isEditMode={true}- />- </div>- </div>- {!fullScreen && (- <div className='flex items-center justify-between p-4 pt-3 border-t-[1px] border-t-divider-subtle'>- <AddAnother isChecked={addAnother} onCheck={() => setAddAnother(!addAnother)} />- <ActionButtons- handleCancel={handleCancel.bind(null, 'esc')}- handleSave={handleSave}- loading={loading}- actionType='add'- isChildChunk={true}- />- </div>- )}- </div>- )-}--export default memo(NewChildSegmentModal)diff --git a/web/app/components/datasets/documents/detail/completed/segment-card.tsx b/web/app/components/datasets/documents/detail/completed/segment-card.tsxdeleted file mode 100644index 1cadd0cf967..00000000000--- a/web/app/components/datasets/documents/detail/completed/segment-card.tsx+++ /dev/null@@ -1,280 +0,0 @@-import React, { type FC, useCallback, useMemo, useState } from 'react'-import { useTranslation } from 'react-i18next'-import { RiDeleteBinLine, RiEditLine } from '@remixicon/react'-import { StatusItem } from '../../list'-import { useDocumentContext } from '../index'-import ChildSegmentList from './child-segment-list'-import Tag from './common/tag'-import Dot from './common/dot'-import { SegmentIndexTag } from './common/segment-index-tag'-import ParentChunkCardSkeleton from './skeleton/parent-chunk-card-skeleton'-import { useSegmentListContext } from './index'-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'-import Switch from '@/app/components/base/switch'-import Divider from '@/app/components/base/divider'-import { formatNumber } from '@/utils/format'-import Confirm from '@/app/components/base/confirm'-import cn from '@/utils/classnames'-import Badge from '@/app/components/base/badge'-import { isAfter } from '@/utils/time'-import Tooltip from '@/app/components/base/tooltip'--type ISegmentCardProps = {- loading: boolean- detail?: SegmentDetailModel & { document?: { name: string } }- onClick?: () => void- onChangeSwitch?: (enabled: boolean, segId?: string) => Promise<void>- onDelete?: (segId: string) => Promise<void>- onDeleteChildChunk?: (segId: string, childChunkId: string) => Promise<void>- handleAddNewChildChunk?: (parentChunkId: string) => void- onClickSlice?: (childChunk: ChildChunkDetail) => void- onClickEdit?: () => void- className?: string- archived?: boolean- embeddingAvailable?: boolean- focused: {- segmentIndex: boolean- segmentContent: boolean- }-}--const SegmentCard: FC<ISegmentCardProps> = ({- detail = {},- onClick,- onChangeSwitch,- onDelete,- onDeleteChildChunk,- handleAddNewChildChunk,- onClickSlice,- onClickEdit,- loading = true,- className = '',- archived,- embeddingAvailable,- focused,-}) => {- const { t } = useTranslation()- const {- id,- position,- enabled,- content,- word_count,- hit_count,- answer,- keywords,- child_chunks = [],- created_at,- updated_at,- } = detail as Required<ISegmentCardProps>['detail']- const [showModal, setShowModal] = useState(false)- const isCollapsed = useSegmentListContext(s => s.isCollapsed)- const mode = useDocumentContext(s => s.mode)- const parentMode = useDocumentContext(s => s.parentMode)-- const isGeneralMode = useMemo(() => {- return mode === 'custom'- }, [mode])-- const isParentChildMode = useMemo(() => {- return mode === 'hierarchical'- }, [mode])-- const isParagraphMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'paragraph'- }, [mode, parentMode])-- const isFullDocMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'full-doc'- }, [mode, parentMode])-- const chunkEdited = useMemo(() => {- if (mode === 'hierarchical' && parentMode === 'full-doc')- return false- return isAfter(updated_at * 1000, created_at * 1000)- }, [mode, parentMode, updated_at, created_at])-- const contentOpacity = useMemo(() => {- return (enabled || focused.segmentContent) ? '' : 'opacity-50 group-hover/card:opacity-100'- }, [enabled, focused.segmentContent])-- const handleClickCard = useCallback(() => {- if (mode !== 'hierarchical' || parentMode !== 'full-doc')- onClick?.()- }, [mode, parentMode, onClick])-- const renderContent = () => {- if (answer) {- return (- <>- <div className='flex gap-x-1'>- <div className='w-4 text-[13px] font-medium leading-[20px] text-text-tertiary shrink-0'>Q</div>- <div- className={cn('text-text-secondary body-md-regular',- isCollapsed ? 'line-clamp-2' : 'line-clamp-20',- )}>- {content}- </div>- </div>- <div className='flex gap-x-1'>- <div className='w-4 text-[13px] font-medium leading-[20px] text-text-tertiary shrink-0'>A</div>- <div className={cn('text-text-secondary body-md-regular',- isCollapsed ? 'line-clamp-2' : 'line-clamp-20',- )}>- {answer}- </div>- </div>- </>- )- }- return content- }-- const wordCountText = useMemo(() => {- const total = formatNumber(word_count)- return `${total} ${t('datasetDocuments.segment.characters', { count: word_count })}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [word_count])-- const labelPrefix = useMemo(() => {- return isParentChildMode ? t('datasetDocuments.segment.parentChunk') : t('datasetDocuments.segment.chunk')- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isParentChildMode])-- if (loading)- return <ParentChunkCardSkeleton />-- return (- <div- className={cn(- 'w-full px-3 rounded-xl group/card',- isFullDocMode ? '' : 'pt-2.5 pb-2 hover:bg-dataset-chunk-detail-card-hover-bg',- focused.segmentContent ? 'bg-dataset-chunk-detail-card-hover-bg' : '',- className,- )}- onClick={handleClickCard}- >- <div className='h-5 relative flex items-center justify-between'>- <>- <div className='flex items-center gap-x-2'>- <SegmentIndexTag- className={cn(contentOpacity)}- iconClassName={focused.segmentIndex ? 'text-text-accent' : ''}- labelClassName={focused.segmentIndex ? 'text-text-accent' : ''}- positionId={position}- label={isFullDocMode ? labelPrefix : ''}- labelPrefix={labelPrefix}- />- <Dot />- <div className={cn('text-text-tertiary system-xs-medium', contentOpacity)}>{wordCountText}</div>- <Dot />- <div className={cn('text-text-tertiary system-xs-medium', contentOpacity)}>{`${formatNumber(hit_count)} ${t('datasetDocuments.segment.hitCount')}`}</div>- {chunkEdited && (- <>- <Dot />- <Badge text={t('datasetDocuments.segment.edited') as string} uppercase className={contentOpacity} />- </>- )}- </div>- {!isFullDocMode- ? <div className='flex items-center'>- <StatusItem status={enabled ? 'enabled' : 'disabled'} reverse textCls="text-text-tertiary system-xs-regular" />- {embeddingAvailable && (- <div className="absolute -top-2 -right-2.5 z-20 hidden group-hover/card:flex items-center gap-x-0.5 p-1- rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg shadow-md backdrop-blur-[5px]">- {!archived && (- <>- <Tooltip- popupContent='Edit'- popupClassName='text-text-secondary system-xs-medium'- >- <div- className='shrink-0 w-6 h-6 flex items-center justify-center rounded-lg hover:bg-state-base-hover cursor-pointer'- onClick={(e) => {- e.stopPropagation()- onClickEdit?.()- }}>- <RiEditLine className='w-4 h-4 text-text-tertiary' />- </div>- </Tooltip>- <Tooltip- popupContent='Delete'- popupClassName='text-text-secondary system-xs-medium'- >- <div className='shrink-0 w-6 h-6 flex items-center justify-center rounded-lg hover:bg-state-destructive-hover cursor-pointer group/delete'- onClick={(e) => {- e.stopPropagation()- setShowModal(true)- }- }>- <RiDeleteBinLine className='w-4 h-4 text-text-tertiary group-hover/delete:text-text-destructive' />- </div>- </Tooltip>- <Divider type="vertical" className="h-3.5 bg-divider-regular" />- </>- )}- <div- onClick={(e: React.MouseEvent<HTMLDivElement, MouseEvent>) =>- e.stopPropagation()- }- className="flex items-center"- >- <Switch- size='md'- disabled={archived || detail?.status !== 'completed'}- defaultValue={enabled}- onChange={async (val) => {- await onChangeSwitch?.(val, id)- }}- />- </div>- </div>- )}- </div>- : null}- </>- </div>- <div className={cn('text-text-secondary body-md-regular -tracking-[0.07px] mt-0.5',- contentOpacity,- isFullDocMode ? 'line-clamp-3' : isCollapsed ? 'line-clamp-2' : 'line-clamp-20',- )}>- {renderContent()}- </div>- {isGeneralMode && <div className={cn('flex flex-wrap items-center gap-2 py-1.5', contentOpacity)}>- {keywords?.map(keyword => <Tag key={keyword} text={keyword} />)}- </div>}- {- isFullDocMode- ? <button- type='button'- className='mt-0.5 mb-2 text-text-accent system-xs-semibold-uppercase'- onClick={() => onClick?.()}- >{t('common.operation.viewMore')}</button>- : null- }- {- isParagraphMode && child_chunks.length > 0- && <ChildSegmentList- parentChunkId={id}- childChunks={child_chunks}- enabled={enabled}- onDelete={onDeleteChildChunk!}- handleAddNewChildChunk={handleAddNewChildChunk}- onClickSlice={onClickSlice}- focused={focused.segmentContent}- />- }- {showModal- && <Confirm- isShow={showModal}- title={t('datasetDocuments.segment.delete')}- confirmText={t('common.operation.sure')}- onConfirm={async () => { await onDelete?.(id) }}- onCancel={() => setShowModal(false)}- />- }- </div>- )-}--export default React.memo(SegmentCard)diff --git a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx b/web/app/components/datasets/documents/detail/completed/segment-detail.tsxdeleted file mode 100644index 307a5cfb800..00000000000--- a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx+++ /dev/null@@ -1,190 +0,0 @@-import React, { type FC, useMemo, useState } from 'react'-import { useTranslation } from 'react-i18next'-import {- RiCloseLine,- RiExpandDiagonalLine,-} from '@remixicon/react'-import { useDocumentContext } from '../index'-import ActionButtons from './common/action-buttons'-import ChunkContent from './common/chunk-content'-import Keywords from './common/keywords'-import RegenerationModal from './common/regeneration-modal'-import { SegmentIndexTag } from './common/segment-index-tag'-import Dot from './common/dot'-import { useSegmentListContext } from './index'-import { ChunkingMode, type SegmentDetailModel } from '@/models/datasets'-import { useEventEmitterContextContext } from '@/context/event-emitter'-import { formatNumber } from '@/utils/format'-import classNames from '@/utils/classnames'-import Divider from '@/app/components/base/divider'--type ISegmentDetailProps = {- segInfo?: Partial<SegmentDetailModel> & { id: string }- onUpdate: (segmentId: string, q: string, a: string, k: string[], needRegenerate?: boolean) => void- onCancel: () => void- isEditMode?: boolean- docForm: ChunkingMode-}--/**- * Show all the contents of the segment- */-const SegmentDetail: FC<ISegmentDetailProps> = ({- segInfo,- onUpdate,- onCancel,- isEditMode,- docForm,-}) => {- const { t } = useTranslation()- const [question, setQuestion] = useState(segInfo?.content || '')- const [answer, setAnswer] = useState(segInfo?.answer || '')- const [keywords, setKeywords] = useState<string[]>(segInfo?.keywords || [])- const { eventEmitter } = useEventEmitterContextContext()- const [loading, setLoading] = useState(false)- const [showRegenerationModal, setShowRegenerationModal] = useState(false)- const fullScreen = useSegmentListContext(s => s.fullScreen)- const toggleFullScreen = useSegmentListContext(s => s.toggleFullScreen)- const mode = useDocumentContext(s => s.mode)- const parentMode = useDocumentContext(s => s.parentMode)-- eventEmitter?.useSubscription((v) => {- if (v === 'update-segment')- setLoading(true)- if (v === 'update-segment-done')- setLoading(false)- })-- const handleCancel = () => {- onCancel()- setQuestion(segInfo?.content || '')- setAnswer(segInfo?.answer || '')- setKeywords(segInfo?.keywords || [])- }-- const handleSave = () => {- onUpdate(segInfo?.id || '', question, answer, keywords)- }-- const handleRegeneration = () => {- setShowRegenerationModal(true)- }-- const onCancelRegeneration = () => {- setShowRegenerationModal(false)- }-- const onConfirmRegeneration = () => {- onUpdate(segInfo?.id || '', question, answer, keywords, true)- }-- const isParentChildMode = useMemo(() => {- return mode === 'hierarchical'- }, [mode])-- const isFullDocMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'full-doc'- }, [mode, parentMode])-- const titleText = useMemo(() => {- return isEditMode ? t('datasetDocuments.segment.editChunk') : t('datasetDocuments.segment.chunkDetail')- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isEditMode])-- const isQAModel = useMemo(() => {- return docForm === ChunkingMode.qa- }, [docForm])-- const wordCountText = useMemo(() => {- const contentLength = isQAModel ? (question.length + answer.length) : question.length- const total = formatNumber(isEditMode ? contentLength : segInfo!.word_count as number)- const count = isEditMode ? contentLength : segInfo!.word_count as number- return `${total} ${t('datasetDocuments.segment.characters', { count })}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isEditMode, question.length, answer.length, segInfo?.word_count, isQAModel])-- const labelPrefix = useMemo(() => {- return isParentChildMode ? t('datasetDocuments.segment.parentChunk') : t('datasetDocuments.segment.chunk')- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [isParentChildMode])-- return (- <div className={'flex flex-col h-full'}>- <div className={classNames('flex items-center justify-between', fullScreen ? 'py-3 pr-4 pl-6 border border-divider-subtle' : 'pt-3 pr-3 pl-4')}>- <div className='flex flex-col'>- <div className='text-text-primary system-xl-semibold'>{titleText}</div>- <div className='flex items-center gap-x-2'>- <SegmentIndexTag positionId={segInfo?.position || ''} label={isFullDocMode ? labelPrefix : ''} labelPrefix={labelPrefix} />- <Dot />- <span className='text-text-tertiary system-xs-medium'>{wordCountText}</span>- </div>- </div>- <div className='flex items-center'>- {isEditMode && fullScreen && (- <>- <ActionButtons- handleCancel={handleCancel}- handleRegeneration={handleRegeneration}- handleSave={handleSave}- loading={loading}- />- <Divider type='vertical' className='h-3.5 bg-divider-regular ml-4 mr-2' />- </>- )}- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer mr-1' onClick={toggleFullScreen}>- <RiExpandDiagonalLine className='w-4 h-4 text-text-tertiary' />- </div>- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer' onClick={onCancel}>- <RiCloseLine className='w-4 h-4 text-text-tertiary' />- </div>- </div>- </div>- <div className={classNames(- 'flex grow',- fullScreen ? 'w-full flex-row justify-center px-6 pt-6 gap-x-8' : 'flex-col gap-y-1 py-3 px-4',- !isEditMode && 'pb-0',- )}>- <div className={classNames('break-all overflow-hidden whitespace-pre-line', fullScreen ? 'w-1/2' : 'grow')}>- <ChunkContent- docForm={docForm}- question={question}- answer={answer}- onQuestionChange={question => setQuestion(question)}- onAnswerChange={answer => setAnswer(answer)}- isEditMode={isEditMode}- />- </div>- {mode === 'custom' && <Keywords- className={fullScreen ? 'w-1/5' : ''}- actionType={isEditMode ? 'edit' : 'view'}- segInfo={segInfo}- keywords={keywords}- isEditMode={isEditMode}- onKeywordsChange={keywords => setKeywords(keywords)}- />}- </div>- {isEditMode && !fullScreen && (- <div className='flex items-center justify-end p-4 pt-3 border-t-[1px] border-t-divider-subtle'>- <ActionButtons- handleCancel={handleCancel}- handleRegeneration={handleRegeneration}- handleSave={handleSave}- loading={loading}- />- </div>- )}- {- showRegenerationModal && (- <RegenerationModal- isShow={showRegenerationModal}- onConfirm={onConfirmRegeneration}- onCancel={onCancelRegeneration}- onClose={onCancelRegeneration}- />- )- }- </div>- )-}--export default React.memo(SegmentDetail)diff --git a/web/app/components/datasets/documents/detail/completed/segment-list.tsx b/web/app/components/datasets/documents/detail/completed/segment-list.tsxdeleted file mode 100644index c31345ff3be..00000000000--- a/web/app/components/datasets/documents/detail/completed/segment-list.tsx+++ /dev/null@@ -1,116 +0,0 @@-import React, { type ForwardedRef, useMemo } from 'react'-import { useDocumentContext } from '../index'-import SegmentCard from './segment-card'-import Empty from './common/empty'-import GeneralListSkeleton from './skeleton/general-list-skeleton'-import ParagraphListSkeleton from './skeleton/paragraph-list-skeleton'-import { useSegmentListContext } from './index'-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'-import Checkbox from '@/app/components/base/checkbox'-import Divider from '@/app/components/base/divider'--type ISegmentListProps = {- isLoading: boolean- items: SegmentDetailModel[]- selectedSegmentIds: string[]- onSelected: (segId: string) => void- onClick: (detail: SegmentDetailModel, isEditMode?: boolean) => void- onChangeSwitch: (enabled: boolean, segId?: string,) => Promise<void>- onDelete: (segId: string) => Promise<void>- onDeleteChildChunk: (sgId: string, childChunkId: string) => Promise<void>- handleAddNewChildChunk: (parentChunkId: string) => void- onClickSlice: (childChunk: ChildChunkDetail) => void- archived?: boolean- embeddingAvailable: boolean- onClearFilter: () => void-}--const SegmentList = React.forwardRef(({- isLoading,- items,- selectedSegmentIds,- onSelected,- onClick: onClickCard,- onChangeSwitch,- onDelete,- onDeleteChildChunk,- handleAddNewChildChunk,- onClickSlice,- archived,- embeddingAvailable,- onClearFilter,-}: ISegmentListProps,-ref: ForwardedRef<HTMLDivElement>,-) => {- const mode = useDocumentContext(s => s.mode)- const parentMode = useDocumentContext(s => s.parentMode)- const currSegment = useSegmentListContext(s => s.currSegment)- const currChildChunk = useSegmentListContext(s => s.currChildChunk)-- const Skeleton = useMemo(() => {- return (mode === 'hierarchical' && parentMode === 'paragraph') ? ParagraphListSkeleton : GeneralListSkeleton- }, [mode, parentMode])-- // Loading skeleton- if (isLoading)- return <Skeleton />- // Search result is empty- if (items.length === 0) {- return (- <div className='h-full pl-6'>- <Empty onClearFilter={onClearFilter} />- </div>- )- }- return (- <div ref={ref} className={'flex flex-col grow overflow-y-auto'}>- {- items.map((segItem) => {- const isLast = items[items.length - 1].id === segItem.id- const segmentIndexFocused- = currSegment?.segInfo?.id === segItem.id- || (!currSegment && currChildChunk?.childChunkInfo?.segment_id === segItem.id)- const segmentContentFocused = currSegment?.segInfo?.id === segItem.id- || currChildChunk?.childChunkInfo?.segment_id === segItem.id- return (- <div key={segItem.id} className='flex items-start gap-x-2'>- <Checkbox- key={`${segItem.id}-checkbox`}- className='shrink-0 mt-3.5'- checked={selectedSegmentIds.includes(segItem.id)}- onCheck={() => onSelected(segItem.id)}- />- <div className='grow'>- <SegmentCard- key={`${segItem.id}-card`}- detail={segItem}- onClick={() => onClickCard(segItem, true)}- onChangeSwitch={onChangeSwitch}- onClickEdit={() => onClickCard(segItem, true)}- onDelete={onDelete}- onDeleteChildChunk={onDeleteChildChunk}- handleAddNewChildChunk={handleAddNewChildChunk}- onClickSlice={onClickSlice}- loading={false}- archived={archived}- embeddingAvailable={embeddingAvailable}- focused={{- segmentIndex: segmentIndexFocused,- segmentContent: segmentContentFocused,- }}- />- {!isLast && <div className='w-full px-3'>- <Divider type='horizontal' className='bg-divider-subtle my-1' />- </div>}- </div>- </div>- )- })- }- </div>- )-})--SegmentList.displayName = 'SegmentList'--export default SegmentListdiff --git a/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsxdeleted file mode 100644index 7ae5e8c4f2b..00000000000--- a/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx+++ /dev/null@@ -1,25 +0,0 @@-import React from 'react'--const Slice = React.memo(() => {- return (- <div className='flex flex-col gap-y-1'>- <div className='w-full h-5 bg-state-base-hover flex items-center'>- <span className='w-[30px] h-5 bg-state-base-hover-alt' />- </div>- <div className='w-2/3 h-5 bg-state-base-hover' />- </div>- )-})--Slice.displayName = 'Slice'--const FullDocListSkeleton = () => {- return (- <div className='w-full grow flex flex-col gap-y-3 relative z-10 overflow-y-hidden'>- <div className='absolute top-0 left-0 bottom-14 w-full h-full bg-dataset-chunk-list-mask-bg z-20' />- {[...Array(15)].map((_, index) => <Slice key={index} />)}- </div>- )-}--export default React.memo(FullDocListSkeleton)diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsxdeleted file mode 100644index c9b9c0887b5..00000000000--- a/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx+++ /dev/null@@ -1,74 +0,0 @@-import React from 'react'-import {- SkeletonContainer,- SkeletonPoint,- SkeletonRectangle,- SkeletonRow,-} from '@/app/components/base/skeleton'-import Checkbox from '@/app/components/base/checkbox'-import Divider from '@/app/components/base/divider'--const CardSkelton = React.memo(() => {- return (- <SkeletonContainer className='p-1 pb-2 gap-y-0'>- <SkeletonContainer className='px-2 pt-1.5 gap-y-0.5'>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-[72px] bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonRow className='grow justify-end gap-1'>- <SkeletonRectangle className='w-12 bg-text-quaternary' />- <SkeletonRectangle className='w-2 bg-text-quaternary mx-1' />- </SkeletonRow>- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-2/3 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- <SkeletonContainer className='px-2 py-1.5'>- <SkeletonRow>- <SkeletonRectangle className='w-14 bg-text-quaternary' />- <SkeletonRectangle className='w-[88px] bg-text-quaternary' />- <SkeletonRectangle className='w-14 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- </SkeletonContainer>- )-})--CardSkelton.displayName = 'CardSkelton'--const GeneralListSkeleton = () => {- return (- <div className='relative flex flex-col grow overflow-y-hidden z-10'>- <div className='absolute top-0 left-0 w-full h-full bg-dataset-chunk-list-mask-bg z-20' />- {[...Array(10)].map((_, index) => {- return (- <div key={index} className='flex items-start gap-x-2'>- <Checkbox- key={`${index}-checkbox`}- className='shrink-0 mt-3.5'- disabled- />- <div className='grow'>- <CardSkelton />- {index !== 9 && <div className='w-full px-3'>- <Divider type='horizontal' className='bg-divider-subtle my-1' />- </div>}- </div>- </div>- )- })}- </div>- )-}--export default React.memo(GeneralListSkeleton)diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsxdeleted file mode 100644index 4e88d49f91d..00000000000--- a/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx+++ /dev/null@@ -1,76 +0,0 @@-import React from 'react'-import { RiArrowRightSLine } from '@remixicon/react'-import {- SkeletonContainer,- SkeletonPoint,- SkeletonRectangle,- SkeletonRow,-} from '@/app/components/base/skeleton'-import Checkbox from '@/app/components/base/checkbox'-import Divider from '@/app/components/base/divider'--const CardSkelton = React.memo(() => {- return (- <SkeletonContainer className='p-1 pb-2 gap-y-0'>- <SkeletonContainer className='px-2 pt-1.5 gap-y-0.5'>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-[72px] bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonRow className='grow justify-end gap-1'>- <SkeletonRectangle className='w-12 bg-text-quaternary' />- <SkeletonRectangle className='w-2 bg-text-quaternary mx-1' />- </SkeletonRow>- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-2/3 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- <SkeletonContainer className='p-1 pb-2'>- <SkeletonRow>- <SkeletonRow className='h-7 pl-1 pr-3 gap-x-0.5 rounded-lg bg-dataset-child-chunk-expand-btn-bg'>- <RiArrowRightSLine className='w-4 h-4 text-text-secondary opacity-20' />- <SkeletonRectangle className='w-32 bg-text-quaternary' />- </SkeletonRow>- </SkeletonRow>- </SkeletonContainer>- </SkeletonContainer>- )-})--CardSkelton.displayName = 'CardSkelton'--const ParagraphListSkeleton = () => {- return (- <div className='relative flex flex-col h-full overflow-y-hidden z-10'>- <div className='absolute top-0 left-0 w-full h-full bg-dataset-chunk-list-mask-bg z-20' />- {[...Array(10)].map((_, index) => {- return (- <div key={index} className='flex items-start gap-x-2'>- <Checkbox- key={`${index}-checkbox`}- className='shrink-0 mt-3.5'- disabled- />- <div className='grow'>- <CardSkelton />- {index !== 9 && <div className='w-full px-3'>- <Divider type='horizontal' className='bg-divider-subtle my-1' />- </div>}- </div>- </div>- )- })}- </div>- )-}--export default React.memo(ParagraphListSkeleton)diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/parent-chunk-card-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/parent-chunk-card-skeleton.tsxdeleted file mode 100644index 46f5cccc032..00000000000--- a/web/app/components/datasets/documents/detail/completed/skeleton/parent-chunk-card-skeleton.tsx+++ /dev/null@@ -1,45 +0,0 @@-import React from 'react'-import { useTranslation } from 'react-i18next'-import {- SkeletonContainer,- SkeletonPoint,- SkeletonRectangle,- SkeletonRow,-} from '@/app/components/base/skeleton'--const ParentChunkCardSkelton = () => {- const { t } = useTranslation()- return (- <div className='flex flex-col pb-2'>- <SkeletonContainer className='p-1 pb-0 gap-y-0'>- <SkeletonContainer className='px-2 pt-1.5 gap-y-0.5'>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-[72px] bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-2/3 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- </SkeletonContainer>- <div className='flex items-center px-3 mt-0.5'>- <button type='button' className='pt-0.5 text-components-button-secondary-accent-text-disabled system-xs-semibold-uppercase' disabled>- {t('common.operation.viewMore')}- </button>- </div>- </div>- )-}--ParentChunkCardSkelton.displayName = 'ParentChunkCardSkelton'--export default React.memo(ParentChunkCardSkelton)diff --git a/web/app/components/datasets/documents/detail/completed/status-item.tsx b/web/app/components/datasets/documents/detail/completed/status-item.tsxdeleted file mode 100644index 06cf70338d3..00000000000--- a/web/app/components/datasets/documents/detail/completed/status-item.tsx+++ /dev/null@@ -1,22 +0,0 @@-import React, { type FC } from 'react'-import { RiCheckLine } from '@remixicon/react'-import type { Item } from '@/app/components/base/select'--type IStatusItemProps = {- item: Item- selected: boolean-}--const StatusItem: FC<IStatusItemProps> = ({- item,- selected,-}) => {- return (- <div className='flex items-center justify-between py-1.5 px-2'>- <span className='system-md-regular'>{item.name}</span>- {selected && <RiCheckLine className='w-4 h-4 text-text-accent' />}- </div>- )-}--export default React.memo(StatusItem)diff --git a/web/app/components/datasets/documents/detail/completed/style.module.css b/web/app/components/datasets/documents/detail/completed/style.module.cssindex 902ef22eb69..7633d532096 100644--- a/web/app/components/datasets/documents/detail/completed/style.module.css+++ b/web/app/components/datasets/documents/detail/completed/style.module.css@@ -1,5 +1,14 @@+/* .cardWrapper {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(290px, auto));+ grid-gap: 16px;+ grid-auto-rows: 180px;+} */+.totalText {+ @apply text-gray-900 font-medium text-base flex-1;+}.docSearchWrapper {- @apply sticky w-full -top-3 flex items-center mb-3 justify-between z-[11] flex-wrap gap-y-1 pr-3;+ @apply sticky w-full py-1 -top-3 bg-white flex items-center mb-3 justify-between z-10 flex-wrap gap-y-1;}.listContainer {height: calc(100% - 3.25rem);@@ -32,7 +41,7 @@@apply text-primary-600 font-semibold text-xs absolute right-0 hidden h-12 pl-12 items-center;}.select {- @apply h-8 py-0 pr-5 w-[100px] shadow-none !important;+ @apply h-8 py-0 bg-gray-50 hover:bg-gray-100 rounded-lg shadow-none !important;}.segModalContent {@apply h-96 text-gray-800 text-base break-all overflow-y-scroll;diff --git a/web/app/components/datasets/documents/detail/embedding/index.tsx b/web/app/components/datasets/documents/detail/embedding/index.tsxindex c6a90a0e29e..1bc6c91c2ae 100644--- a/web/app/components/datasets/documents/detail/embedding/index.tsx+++ b/web/app/components/datasets/documents/detail/embedding/index.tsx@@ -1,52 +1,59 @@-import type { FC } from 'react'+import type { FC, SVGProps } from 'react'import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import useSWR from 'swr'+import { useRouter } from 'next/navigation'import { useContext } from 'use-context-selector'import { useTranslation } from 'react-i18next'import { omit } from 'lodash-es'-import { RiLoader2Line, RiPauseCircleLine, RiPlayCircleLine } from '@remixicon/react'-import Image from 'next/image'+import { ArrowRightIcon } from '@heroicons/react/24/solid'+import SegmentCard from '../completed/SegmentCard'import { FieldInfo } from '../metadata'-import { useDocumentContext } from '../index'-import { IndexingType } from '../../../create/step-two'-import { indexMethodIcon, retrievalIcon } from '../../../create/icons'-import EmbeddingSkeleton from './skeleton'-import { RETRIEVE_METHOD } from '@/types/app'+import style from '../completed/style.module.css'+import { DocumentContext } from '../index'+import s from './style.module.css'import cn from '@/utils/classnames'+import Button from '@/app/components/base/button'import Divider from '@/app/components/base/divider'import { ToastContext } from '@/app/components/base/toast'-import { ProcessMode, type ProcessRuleResponse } from '@/models/datasets'+import type { FullDocumentDetail, ProcessRuleResponse } from '@/models/datasets'import type { CommonResponse } from '@/models/common'import { asyncRunSafe, sleep } from '@/utils'-import {- fetchIndexingStatus as doFetchIndexingStatus,- fetchProcessRule,- pauseDocIndexing,- resumeDocIndexing,-} from '@/service/datasets'+import { fetchIndexingStatus as doFetchIndexingStatus, fetchProcessRule, pauseDocIndexing, resumeDocIndexing } from '@/service/datasets'+import StopEmbeddingModal from '@/app/components/datasets/create/stop-embedding-modal'-type IEmbeddingDetailProps = {+type Props = {+ detail?: FullDocumentDetail+ stopPosition?: 'top' | 'bottom'datasetId?: stringdocumentId?: string- indexingType?: IndexingType- retrievalMethod?: RETRIEVE_METHOD+ indexingType?: stringdetailUpdate: VoidFunction}-type IRuleDetailProps = {- sourceData?: ProcessRuleResponse- indexingType?: IndexingType- retrievalMethod?: RETRIEVE_METHOD+const StopIcon = ({ className }: SVGProps<SVGElement>) => {+ return <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>+ <g clipPath="url(#clip0_2328_2798)">+ <path d="M1.5 3.9C1.5 3.05992 1.5 2.63988 1.66349 2.31901C1.8073 2.03677 2.03677 1.8073 2.31901 1.66349C2.63988 1.5 3.05992 1.5 3.9 1.5H8.1C8.94008 1.5 9.36012 1.5 9.68099 1.66349C9.96323 1.8073 10.1927 2.03677 10.3365 2.31901C10.5 2.63988 10.5 3.05992 10.5 3.9V8.1C10.5 8.94008 10.5 9.36012 10.3365 9.68099C10.1927 9.96323 9.96323 10.1927 9.68099 10.3365C9.36012 10.5 8.94008 10.5 8.1 10.5H3.9C3.05992 10.5 2.63988 10.5 2.31901 10.3365C2.03677 10.1927 1.8073 9.96323 1.66349 9.68099C1.5 9.36012 1.5 8.94008 1.5 8.1V3.9Z" stroke="#344054" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </g>+ <defs>+ <clipPath id="clip0_2328_2798">+ <rect width="12" height="12" fill="white" />+ </clipPath>+ </defs>+ </svg>}-const RuleDetail: FC<IRuleDetailProps> = React.memo(({- sourceData,- indexingType,- retrievalMethod,-}) => {+const ResumeIcon = ({ className }: SVGProps<SVGElement>) => {+ return <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>+ <path d="M10 3.5H5C3.34315 3.5 2 4.84315 2 6.5C2 8.15685 3.34315 9.5 5 9.5H10M10 3.5L8 1.5M10 3.5L8 5.5" stroke="#344054" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </svg>+}++const RuleDetail: FC<{ sourceData?: ProcessRuleResponse; docName?: string }> = ({ sourceData, docName }) => {const { t } = useTranslation()const segmentationRuleMap = {+ docName: t('datasetDocuments.embedding.docName'),mode: t('datasetDocuments.embedding.mode'),segmentLength: t('datasetDocuments.embedding.segmentLength'),textCleaning: t('datasetDocuments.embedding.textCleaning'),@@ -63,106 +70,48 @@ const RuleDetail: FC<IRuleDetailProps> = React.memo(({return t('datasetCreation.stepTwo.removeStopwords')}- const isNumber = (value: unknown) => {- return typeof value === 'number'- }-const getValue = useCallback((field: string) => {let value: string | number | undefined = '-'- const maxTokens = isNumber(sourceData?.rules?.segmentation?.max_tokens)- ? sourceData.rules.segmentation.max_tokens- : value- const childMaxTokens = isNumber(sourceData?.rules?.subchunk_segmentation?.max_tokens)- ? sourceData.rules.subchunk_segmentation.max_tokens- : valueswitch (field) {+ case 'docName':+ value = docName+ breakcase 'mode':- value = !sourceData?.mode- ? value- : sourceData.mode === ProcessMode.general- ? (t('datasetDocuments.embedding.custom') as string)- : `${t('datasetDocuments.embedding.hierarchical')} · ${sourceData?.rules?.parent_mode === 'paragraph'- ? t('dataset.parentMode.paragraph')- : t('dataset.parentMode.fullDoc')}`+ value = sourceData?.mode === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string)breakcase 'segmentLength':- value = !sourceData?.mode- ? value- : sourceData.mode === ProcessMode.general- ? maxTokens- : `${t('datasetDocuments.embedding.parentMaxTokens')} ${maxTokens}; ${t('datasetDocuments.embedding.childMaxTokens')} ${childMaxTokens}`+ value = sourceData?.rules?.segmentation?.max_tokensbreakdefault:- value = !sourceData?.mode- ? value- : sourceData?.rules?.pre_processing_rules?.filter(rule =>- rule.enabled).map(rule => getRuleName(rule.id)).join(',')+ value = sourceData?.mode === 'automatic'+ ? (t('datasetDocuments.embedding.automatic') as string)+ // eslint-disable-next-line array-callback-return+ : sourceData?.rules?.pre_processing_rules?.map((rule) => {+ if (rule.enabled)+ return getRuleName(rule.id)+ }).filter(Boolean).join(';')break}return value- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [sourceData])+ }, [sourceData, docName])- return <div className='py-3'>- <div className='flex flex-col gap-y-1'>- {Object.keys(segmentationRuleMap).map((field) => {- return <FieldInfo- key={field}- label={segmentationRuleMap[field as keyof typeof segmentationRuleMap]}- displayedValue={String(getValue(field))}- />- })}- </div>- <Divider type='horizontal' className='bg-divider-subtle' />- <FieldInfo- label={t('datasetCreation.stepTwo.indexMode')}- displayedValue={t(`datasetCreation.stepTwo.${indexingType === IndexingType.ECONOMICAL ? 'economical' : 'qualified'}`) as string}- valueIcon={- <Image- className='size-4'- src={- indexingType === IndexingType.ECONOMICAL- ? indexMethodIcon.economical- : indexMethodIcon.high_quality- }- alt=''- />- }- />- <FieldInfo- label={t('datasetSettings.form.retrievalSetting.title')}- displayedValue={t(`dataset.retrieval.${indexingType === IndexingType.ECONOMICAL ? 'invertedIndex' : retrievalMethod}.title`) as string}- valueIcon={- <Image- className='size-4'- src={- retrievalMethod === RETRIEVE_METHOD.fullText- ? retrievalIcon.fullText- : retrievalMethod === RETRIEVE_METHOD.hybrid- ? retrievalIcon.hybrid- : retrievalIcon.vector- }- alt=''- />- }- />+ return <div className='flex flex-col pt-8 pb-10 first:mt-0'>+ {Object.keys(segmentationRuleMap).map((field) => {+ return <FieldInfo+ key={field}+ label={segmentationRuleMap[field as keyof typeof segmentationRuleMap]}+ displayedValue={String(getValue(field))}+ />+ })}</div>-})--RuleDetail.displayName = 'RuleDetail'+}-const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({- datasetId: dstId,- documentId: docId,- detailUpdate,- indexingType,- retrievalMethod,-}) => {+const EmbeddingDetail: FC<Props> = ({ detail, stopPosition = 'top', datasetId: dstId, documentId: docId, detailUpdate }) => {+ const onTop = stopPosition === 'top'const { t } = useTranslation()const { notify } = useContext(ToastContext)- const datasetId = useDocumentContext(s => s.datasetId)- const documentId = useDocumentContext(s => s.documentId)+ const { datasetId = '', documentId = '' } = useContext(DocumentContext)const localDatasetId = dstId ?? datasetIdconst localDocumentId = docId ?? documentId@@ -197,7 +146,6 @@ const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({await sleep(2500)await startQueryStatus()}- // eslint-disable-next-line react-hooks/exhaustive-deps}, [stopQueryStatus])useEffect(() => {@@ -208,13 +156,21 @@ const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({}}, [startQueryStatus, stopQueryStatus])- const { data: ruleDetail } = useSWR({+ const { data: ruleDetail, error: ruleError } = useSWR({action: 'fetchProcessRule',params: { documentId: localDocumentId },}, apiParams => fetchProcessRule(omit(apiParams, 'action')), {revalidateOnFocus: false,})+ const [showModal, setShowModal] = useState(false)+ const modalShowHandle = () => setShowModal(true)+ const modalCloseHandle = () => setShowModal(false)+ const router = useRouter()+ const navToDocument = () => {+ router.push(`/datasets/${localDatasetId}/documents/${localDocumentId}`)+ }+const isEmbedding = useMemo(() => ['indexing', 'splitting', 'parsing', 'cleaning'].includes(indexingStatusDetail?.indexing_status || ''), [indexingStatusDetail])const isEmbeddingCompleted = useMemo(() => ['completed'].includes(indexingStatusDetail?.indexing_status || ''), [indexingStatusDetail])const isEmbeddingPaused = useMemo(() => ['paused'].includes(indexingStatusDetail?.indexing_status || ''), [indexingStatusDetail])@@ -233,12 +189,6 @@ const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId: localDatasetId, documentId: localDocumentId }) as Promise<CommonResponse>)if (!e) {notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- // if the embedding is resumed from paused, we need to start the query status- if (isEmbeddingPaused) {- isStopQuery.current = false- startQueryStatus()- detailUpdate()- }setIndexingStatusDetail(null)}else {@@ -246,66 +196,78 @@ const EmbeddingDetail: FC<IEmbeddingDetailProps> = ({}}+ // if (!ruleDetail && !error)+ // return <Loading type='app' />+return (<>- <div className='py-12 px-16 flex flex-col gap-y-2'>- <div className='flex items-center gap-x-1 h-6'>- {isEmbedding && <RiLoader2Line className='h-4 w-4 text-text-secondary animate-spin' />}- <span className='grow text-text-secondary system-md-semibold-uppercase'>- {isEmbedding && t('datasetDocuments.embedding.processing')}- {isEmbeddingCompleted && t('datasetDocuments.embedding.completed')}- {isEmbeddingPaused && t('datasetDocuments.embedding.paused')}- {isEmbeddingError && t('datasetDocuments.embedding.error')}- </span>+ <div className={s.embeddingStatus}>+ {isEmbedding && t('datasetDocuments.embedding.processing')}+ {isEmbeddingCompleted && t('datasetDocuments.embedding.completed')}+ {isEmbeddingPaused && t('datasetDocuments.embedding.paused')}+ {isEmbeddingError && t('datasetDocuments.embedding.error')}+ {onTop && isEmbedding && (+ <Button onClick={handleSwitch} className={s.opBtn}>+ <StopIcon className={s.opIcon} />+ {t('datasetDocuments.embedding.stop')}+ </Button>+ )}+ {onTop && isEmbeddingPaused && (+ <Button onClick={handleSwitch} className={s.opBtn}>+ <ResumeIcon className={s.opIcon} />+ {t('datasetDocuments.embedding.resume')}+ </Button>+ )}+ </div>+ {/* progress bar */}+ <div className={s.progressContainer}>+ {new Array(10).fill('').map((_, idx) => <div+ key={idx}+ className={cn(s.progressBgItem, isEmbedding ? 'bg-primary-50' : 'bg-gray-100')}+ />)}+ <div+ className={cn(+ 'rounded-l-md',+ s.progressBar,+ (isEmbedding || isEmbeddingCompleted) && s.barProcessing,+ (isEmbeddingPaused || isEmbeddingError) && s.barPaused,+ indexingStatusDetail?.indexing_status === 'completed' && 'rounded-r-md',+ )}+ style={{ width: `${percent}%` }}+ />+ </div>+ <div className={s.progressData}>+ <div>{t('datasetDocuments.embedding.segments')} {indexingStatusDetail?.completed_segments}/{indexingStatusDetail?.total_segments} · {percent}%</div>+ </div>+ <RuleDetail sourceData={ruleDetail} docName={detail?.name} />+ {!onTop && (+ <div className='flex items-center gap-2 mt-10'>{isEmbedding && (- <button- type='button'- className={`px-1.5 py-1 border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg- shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] flex items-center gap-x-1 rounded-md`}- onClick={handleSwitch}- >- <RiPauseCircleLine className='w-3.5 h-3.5 text-components-button-secondary-text' />- <span className='pr-[3px] text-components-button-secondary-text system-xs-medium'>- {t('datasetDocuments.embedding.pause')}- </span>- </button>+ <Button onClick={modalShowHandle} className='w-fit'>+ {t('datasetCreation.stepThree.stop')}+ </Button>)}{isEmbeddingPaused && (- <button- type='button'- className={`px-1.5 py-1 border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg- shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] flex items-center gap-x-1 rounded-md`}- onClick={handleSwitch}- >- <RiPlayCircleLine className='w-3.5 h-3.5 text-components-button-secondary-text' />- <span className='pr-[3px] text-components-button-secondary-text system-xs-medium'>- {t('datasetDocuments.embedding.resume')}- </span>- </button>+ <Button onClick={handleSwitch} className='w-fit'>+ {t('datasetCreation.stepThree.resume')}+ </Button>)}+ <Button className='w-fit' variant='primary' onClick={navToDocument}>+ <span>{t('datasetCreation.stepThree.navTo')}</span>+ <ArrowRightIcon className='h-4 w-4 ml-2 stroke-current stroke-1' />+ </Button></div>- {/* progress bar */}- <div className={cn(- 'flex items-center w-full h-2 rounded-md border border-components-progress-bar-border overflow-hidden',- isEmbedding ? 'bg-components-progress-bar-bg bg-opacity-50' : 'bg-components-progress-bar-bg',- )}>- <div- className={cn(- 'h-full',- (isEmbedding || isEmbeddingCompleted) && 'bg-components-progress-bar-progress-solid',- (isEmbeddingPaused || isEmbeddingError) && 'bg-components-progress-bar-progress-highlight',- )}- style={{ width: `${percent}%` }}- />- </div>- <div className={'w-full flex items-center'}>- <span className='text-text-secondary system-xs-medium'>- {`${t('datasetDocuments.embedding.segments')} ${indexingStatusDetail?.completed_segments || '--'}/${indexingStatusDetail?.total_segments || '--'} · ${percent}%`}- </span>+ )}+ {onTop && <>+ <Divider />+ <div className={s.previewTip}>{t('datasetDocuments.embedding.previewTip')}</div>+ <div className={style.cardWrapper}>+ {[1, 2, 3].map((v, index) => (+ <SegmentCard key={index} loading={true} detail={{ position: v } as any} />+ ))}</div>- <RuleDetail sourceData={ruleDetail} indexingType={indexingType} retrievalMethod={retrievalMethod} />- </div>- <EmbeddingSkeleton />+ </>}+ <StopEmbeddingModal show={showModal} onConfirm={handleSwitch} onHide={modalCloseHandle} /></>)}diff --git a/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx b/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsxdeleted file mode 100644index ebf5dc19d59..00000000000--- a/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx+++ /dev/null@@ -1,66 +0,0 @@-import React from 'react'-import {- SkeletonContainer,- SkeletonPoint,- SkeletonRectangle,- SkeletonRow,-} from '@/app/components/base/skeleton'-import Divider from '@/app/components/base/divider'--const CardSkelton = React.memo(() => {- return (- <SkeletonContainer className='p-1 pb-2 gap-y-0'>- <SkeletonContainer className='px-2 pt-1.5 gap-y-0.5'>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-[72px] bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonPoint className='opacity-20' />- <SkeletonRectangle className='w-24 bg-text-quaternary' />- <SkeletonRow className='grow justify-end gap-1'>- <SkeletonRectangle className='w-12 bg-text-quaternary' />- <SkeletonRectangle className='w-2 bg-text-quaternary mx-1' />- </SkeletonRow>- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-full bg-text-quaternary' />- </SkeletonRow>- <SkeletonRow className='py-0.5'>- <SkeletonRectangle className='w-2/3 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- <SkeletonContainer className='px-2 py-1.5'>- <SkeletonRow>- <SkeletonRectangle className='w-14 bg-text-quaternary' />- <SkeletonRectangle className='w-[88px] bg-text-quaternary' />- <SkeletonRectangle className='w-14 bg-text-quaternary' />- </SkeletonRow>- </SkeletonContainer>- </SkeletonContainer>- )-})--CardSkelton.displayName = 'CardSkelton'--const EmbeddingSkeleton = () => {- return (- <div className='relative flex flex-col grow overflow-y-hidden z-10'>- <div className='absolute top-0 left-0 w-full h-full bg-dataset-chunk-list-mask-bg z-20' />- {[...Array(5)].map((_, index) => {- return (- <div key={index} className='w-full px-11'>- <CardSkelton />- {index !== 9 && <div className='w-full px-3'>- <Divider type='horizontal' className='bg-divider-subtle my-1' />- </div>}- </div>- )- })}- </div>- )-}--export default React.memo(EmbeddingSkeleton)diff --git a/web/app/components/datasets/documents/detail/index.tsx b/web/app/components/datasets/documents/detail/index.tsxindex 8e7f9931237..4f1e850fc8f 100644--- a/web/app/components/datasets/documents/detail/index.tsx+++ b/web/app/components/datasets/documents/detail/index.tsx@@ -1,12 +1,14 @@'use client'import type { FC } from 'react'-import React, { useMemo, useState } from 'react'-import { createContext, useContext, useContextSelector } from 'use-context-selector'+import React, { useState } from 'react'+import useSWR from 'swr'+import { ArrowLeftIcon } from '@heroicons/react/24/solid'+import { createContext, useContext } from 'use-context-selector'import { useTranslation } from 'react-i18next'import { useRouter } from 'next/navigation'-import { RiArrowLeftLine, RiLayoutRight2Line } from '@remixicon/react'+import { omit } from 'lodash-es'import { OperationAction, StatusItem } from '../list'-import DocumentPicker from '../../common/document-picker'+import s from '../style.module.css'import Completed from './completed'import Embedding from './embedding'import Metadata from './metadata'@@ -16,58 +18,30 @@ import style from './style.module.css'import cn from '@/utils/classnames'import Divider from '@/app/components/base/divider'import Loading from '@/app/components/base/loading'+import type { MetadataType } from '@/service/datasets'+import { checkSegmentBatchImportProgress, fetchDocumentDetail, segmentBatchImport } from '@/service/datasets'import { ToastContext } from '@/app/components/base/toast'-import type { ChunkingMode, ParentMode, ProcessMode } from '@/models/datasets'+import type { DocForm } from '@/models/datasets'import { useDatasetDetailContext } from '@/context/dataset-detail'import FloatRightContainer from '@/app/components/base/float-right-container'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'-import { LayoutRight2LineMod } from '@/app/components/base/icons/src/public/knowledge'-import { useCheckSegmentBatchImportProgress, useSegmentBatchImport } from '@/service/knowledge/use-segment'-import { useDocumentDetail, useDocumentMetadata } from '@/service/knowledge/use-document'-type DocumentContextValue = {- datasetId?: string- documentId?: string- docForm: string- mode?: ProcessMode- parentMode?: ParentMode-}--export const DocumentContext = createContext<DocumentContextValue>({ docForm: '' })--export const useDocumentContext = (selector: (value: DocumentContextValue) => any) => {- return useContextSelector(DocumentContext, selector)-}+export const DocumentContext = createContext<{ datasetId?: string; documentId?: string; docForm: string }>({ docForm: '' })type DocumentTitleProps = {- datasetId: stringextension?: stringname?: string- processMode?: ProcessMode- parent_mode?: ParentModeiconCls?: stringtextCls?: stringwrapperCls?: string}-export const DocumentTitle: FC<DocumentTitleProps> = ({ datasetId, extension, name, processMode, parent_mode, wrapperCls }) => {- const router = useRouter()- return (- <div className={cn('flex items-center justify-start flex-1', wrapperCls)}>- <DocumentPicker- datasetId={datasetId}- value={{- name,- extension,- processMode,- parentMode: parent_mode,- }}- onChange={(doc) => {- router.push(`/datasets/${datasetId}/documents/${doc.id}`)- }}- />- </div>- )+export const DocumentTitle: FC<DocumentTitleProps> = ({ extension, name, iconCls, textCls, wrapperCls }) => {+ const localExtension = extension?.toLowerCase() || name?.split('.')?.pop()?.toLowerCase()+ return <div className={cn('flex items-center justify-start flex-1', wrapperCls)}>+ <div className={cn(s[`${localExtension || 'txt'}Icon`], style.titleIcon, iconCls)}></div>+ <span className={cn('font-semibold text-lg text-gray-900 ml-1', textCls)}> {name || '--'}</span>+ </div>}type Props = {@@ -93,52 +67,49 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {const showBatchModal = () => setBatchModalVisible(true)const hideBatchModal = () => setBatchModalVisible(false)const resetProcessStatus = () => setImportStatus('')-- const { mutateAsync: checkSegmentBatchImportProgress } = useCheckSegmentBatchImportProgress()const checkProcess = async (jobID: string) => {- await checkSegmentBatchImportProgress({ jobID }, {- onSuccess: (res) => {- setImportStatus(res.job_status)- if (res.job_status === ProcessStatus.WAITING || res.job_status === ProcessStatus.PROCESSING)- setTimeout(() => checkProcess(res.job_id), 2500)- if (res.job_status === ProcessStatus.ERROR)- notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}` })- },- onError: (e) => {- notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}${'message' in e ? `: ${e.message}` : ''}` })- },- })+ try {+ const res = await checkSegmentBatchImportProgress({ jobID })+ setImportStatus(res.job_status)+ if (res.job_status === ProcessStatus.WAITING || res.job_status === ProcessStatus.PROCESSING)+ setTimeout(() => checkProcess(res.job_id), 2500)+ if (res.job_status === ProcessStatus.ERROR)+ notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}` })+ }+ catch (e: any) {+ notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}${'message' in e ? `: ${e.message}` : ''}` })+ }}-- const { mutateAsync: segmentBatchImport } = useSegmentBatchImport()const runBatch = async (csv: File) => {const formData = new FormData()formData.append('file', csv)- await segmentBatchImport({- url: `/datasets/${datasetId}/documents/${documentId}/segments/batch_import`,- body: formData,- }, {- onSuccess: (res) => {- setImportStatus(res.job_status)- checkProcess(res.job_id)- },- onError: (e) => {- notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}${'message' in e ? `: ${e.message}` : ''}` })- },- })+ try {+ const res = await segmentBatchImport({+ url: `/datasets/${datasetId}/documents/${documentId}/segments/batch_import`,+ body: formData,+ })+ setImportStatus(res.job_status)+ checkProcess(res.job_id)+ }+ catch (e: any) {+ notify({ type: 'error', message: `${t('datasetDocuments.list.batchModal.runError')}${'message' in e ? `: ${e.message}` : ''}` })+ }}- const { data: documentDetail, error, refetch: detailMutate } = useDocumentDetail({+ const { data: documentDetail, error, mutate: detailMutate } = useSWR({+ action: 'fetchDocumentDetail',datasetId,documentId,- params: { metadata: 'without' },- })+ params: { metadata: 'without' as MetadataType },+ }, apiParams => fetchDocumentDetail(omit(apiParams, 'action')))- const { data: documentMetadata, error: metadataErr, refetch: metadataMutate } = useDocumentMetadata({+ const { data: documentMetadata, error: metadataErr, mutate: metadataMutate } = useSWR({+ action: 'fetchDocumentDetail',datasetId,documentId,- params: { metadata: 'only' },- })+ params: { metadata: 'only' as MetadataType },+ }, apiParams => fetchDocumentDetail(omit(apiParams, 'action')),+ )const backToPrev = () => {router.push(`/datasets/${datasetId}/documents`)@@ -156,65 +127,25 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {detailMutate()}- const mode = useMemo(() => {- return documentDetail?.document_process_rule?.mode- }, [documentDetail?.document_process_rule])-- const parentMode = useMemo(() => {- return documentDetail?.document_process_rule?.rules?.parent_mode- }, [documentDetail?.document_process_rule])-- const isFullDocMode = useMemo(() => {- return mode === 'hierarchical' && parentMode === 'full-doc'- }, [mode, parentMode])-return (- <DocumentContext.Provider value={{- datasetId,- documentId,- docForm: documentDetail?.doc_form || '',- mode,- parentMode,- }}>- <div className='flex flex-col h-full bg-background-default'>- <div className='flex items-center justify-between flex-wrap min-h-16 pl-3 pr-4 py-2.5 border-b border-b-divider-subtle'>- <div onClick={backToPrev} className={'shrink-0 rounded-full w-8 h-8 flex justify-center items-center cursor-pointer hover:bg-components-button-tertiary-bg'}>- <RiArrowLeftLine className='text-components-button-ghost-text hover:text-text-tertiary w-4 h-4' />+ <DocumentContext.Provider value={{ datasetId, documentId, docForm: documentDetail?.doc_form || '' }}>+ <div className='flex flex-col h-full'>+ <div className='flex min-h-16 border-b-gray-100 border-b items-center p-4 justify-between flex-wrap gap-y-2'>+ <div onClick={backToPrev} className={'shrink-0 rounded-full w-8 h-8 flex justify-center items-center border-gray-100 cursor-pointer border hover:border-gray-300 shadow-[0px_12px_16px_-4px_rgba(16,24,40,0.08),0px_4px_6px_-2px_rgba(16,24,40,0.03)]'}>+ <ArrowLeftIcon className='text-primary-600 fill-current stroke-current h-4 w-4' /></div>- <DocumentTitle- datasetId={datasetId}- extension={documentDetail?.data_source_info?.upload_file?.extension}- name={documentDetail?.name}- wrapperCls='mr-2'- parent_mode={parentMode}- processMode={mode}- />- <div className='flex items-center flex-wrap'>- {embeddingAvailable && documentDetail && !documentDetail.archived && !isFullDocMode && (- <>- <SegmentAdd- importStatus={importStatus}- clearProcessStatus={resetProcessStatus}- showNewSegmentModal={showNewSegmentModal}- showBatchModal={showBatchModal}- embedding={embedding}- />- <Divider type='vertical' className='!bg-divider-regular !h-[14px] !mx-3' />- </>+ <Divider className='!h-4' type='vertical' />+ <DocumentTitle extension={documentDetail?.data_source_info?.upload_file?.extension} name={documentDetail?.name} />+ <div className='flex items-center flex-wrap gap-y-2'>+ <StatusItem status={documentDetail?.display_status || 'available'} scene='detail' errorMessage={documentDetail?.error || ''} />+ {embeddingAvailable && documentDetail && !documentDetail.archived && (+ <SegmentAdd+ importStatus={importStatus}+ clearProcessStatus={resetProcessStatus}+ showNewSegmentModal={showNewSegmentModal}+ showBatchModal={showBatchModal}+ />)}- <StatusItem- status={documentDetail?.display_status || 'available'}- scene='detail'- errorMessage={documentDetail?.error || ''}- textCls='font-semibold text-xs uppercase'- detail={{- enabled: documentDetail?.enabled || false,- archived: documentDetail?.archived || false,- id: documentId,- }}- datasetId={datasetId}- onUpdate={handleOperate}- /><OperationActionscene='detail'embeddingAvailable={embeddingAvailable}@@ -228,32 +159,20 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {}}datasetId={datasetId}onUpdate={handleOperate}- className='!w-[200px]'+ className='!w-[216px]'/><button- className={style.layoutRightIcon}+ className={cn(style.layoutRightIcon, showMetadata ? style.iconShow : style.iconClose)}onClick={() => setShowMetadata(!showMetadata)}- >- {- showMetadata- ? <LayoutRight2LineMod className='w-4 h-4 text-components-button-secondary-text' />- : <RiLayoutRight2Line className='w-4 h-4 text-components-button-secondary-text' />- }- </button>+ /></div></div><div className='flex flex-row flex-1' style={{ height: 'calc(100% - 4rem)' }}>{isDetailLoading? <Loading type='app' />- : <div className={cn('h-full w-full flex flex-col',- embedding ? '' : isFullDocMode ? 'relative pt-4 pr-11 pl-11' : 'relative pt-3 pr-11 pl-5',- )}>+ : <div className={`h-full w-full flex flex-col ${embedding ? 'px-6 py-3 sm:py-12 sm:px-16' : 'pb-[30px] pt-3 px-6'}`}>{embedding- ? <Embedding- detailUpdate={detailMutate}- indexingType={dataset?.indexing_technique}- retrievalMethod={dataset?.retrieval_model_dict?.search_method}- />+ ? <Embedding detail={documentDetail} detailUpdate={detailMutate} />: <CompletedembeddingAvailable={embeddingAvailable}showNewSegmentModal={newSegmentModalVisible}@@ -276,7 +195,7 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {isShow={batchModalVisible}onCancel={hideBatchModal}onConfirm={runBatch}- docForm={documentDetail?.doc_form as ChunkingMode}+ docForm={documentDetail?.doc_form as DocForm}/></div></DocumentContext.Provider>diff --git a/web/app/components/datasets/documents/detail/metadata/index.tsx b/web/app/components/datasets/documents/detail/metadata/index.tsxindex 4a5560203e2..9990ff7404f 100644--- a/web/app/components/datasets/documents/detail/metadata/index.tsx+++ b/web/app/components/datasets/documents/detail/metadata/index.tsx@@ -1,11 +1,11 @@'use client'-import type { FC, ReactNode } from 'react'+import type { FC } from 'react'import React, { useEffect, useState } from 'react'import { PencilIcon } from '@heroicons/react/24/outline'import { useTranslation } from 'react-i18next'import { useContext } from 'use-context-selector'import { get } from 'lodash-es'-import { useDocumentContext } from '../index'+import { DocumentContext } from '../index'import s from './style.module.css'import cn from '@/utils/classnames'import Input from '@/app/components/base/input'@@ -32,7 +32,6 @@ const map2Options = (map: { [key: string]: string }) => {type IFieldInfoProps = {label: stringvalue?: string- valueIcon?: ReactNodedisplayedValue?: stringdefaultValue?: stringshowEdit?: boolean@@ -44,7 +43,6 @@ type IFieldInfoProps = {export const FieldInfo: FC<IFieldInfoProps> = ({label,value = '',- valueIcon,displayedValue = '',defaultValue,showEdit = false,@@ -58,10 +56,9 @@ export const FieldInfo: FC<IFieldInfoProps> = ({const readAlignTop = !showEdit && textNeedWrapreturn (- <div className={cn('flex items-center gap-1 py-0.5 min-h-5 text-xs', editAlignTop && '!items-start', readAlignTop && '!items-start pt-1')}>- <div className={cn('w-[200px] text-text-tertiary overflow-hidden text-ellipsis whitespace-nowrap shrink-0', editAlignTop && 'pt-1')}>{label}</div>- <div className="grow flex items-center gap-1 text-text-secondary">- {valueIcon}+ <div className={cn(s.fieldInfo, editAlignTop && '!items-start', readAlignTop && '!items-start pt-1')}>+ <div className={cn(s.label, editAlignTop && 'pt-1')}>{label}</div>+ <div className={s.value}>{!showEdit? displayedValue: inputType === 'select'@@ -150,8 +147,7 @@ const Metadata: FC<IMetadataProps> = ({ docDetail, loading, onUpdate }) => {const [saveLoading, setSaveLoading] = useState(false)const { notify } = useContext(ToastContext)- const datasetId = useDocumentContext(s => s.datasetId)- const documentId = useDocumentContext(s => s.documentId)+ const { datasetId = '', documentId = '' } = useContext(DocumentContext)useEffect(() => {if (docDetail?.doc_type) {@@ -352,7 +348,7 @@ const Metadata: FC<IMetadataProps> = ({ docDetail, loading, onUpdate }) => {·<divonClick={() => { setShowDocTypes(true) }}- className='cursor-pointer hover:text-text-accent'+ className='cursor-pointer hover:text-[#155EEF]'>{t('common.operation.change')}</div>diff --git a/web/app/components/datasets/documents/detail/metadata/style.module.css b/web/app/components/datasets/documents/detail/metadata/style.module.cssindex 37796d38dc1..60420c196e9 100644--- a/web/app/components/datasets/documents/detail/metadata/style.module.css+++ b/web/app/components/datasets/documents/detail/metadata/style.module.css@@ -53,7 +53,18 @@.desc {@apply text-gray-500 text-xs;}-+.fieldInfo {+ /* height: 1.75rem; */+ min-height: 1.75rem;+ @apply flex flex-row items-center gap-4;+}+.fieldInfo > .label {+ @apply w-2/5 max-w-[128px] text-gray-500 text-xs font-medium overflow-hidden text-ellipsis whitespace-nowrap;+}+.fieldInfo > .value {+ overflow-wrap: anywhere;+ @apply w-3/5 text-gray-700 font-normal text-xs;+}.changeTip {@apply text-[#D92D20] text-xs text-center;}diff --git a/web/app/components/datasets/documents/detail/new-segment-modal.tsx b/web/app/components/datasets/documents/detail/new-segment-modal.tsxnew file mode 100644index 00000000000..dae9cf19fbc--- /dev/null+++ b/web/app/components/datasets/documents/detail/new-segment-modal.tsx@@ -0,0 +1,156 @@+import { memo, useState } from 'react'+import type { FC } from 'react'+import { useTranslation } from 'react-i18next'+import { useContext } from 'use-context-selector'+import { useParams } from 'next/navigation'+import { RiCloseLine } from '@remixicon/react'+import Modal from '@/app/components/base/modal'+import Button from '@/app/components/base/button'+import AutoHeightTextarea from '@/app/components/base/auto-height-textarea/common'+import { Hash02 } from '@/app/components/base/icons/src/vender/line/general'+import { ToastContext } from '@/app/components/base/toast'+import type { SegmentUpdater } from '@/models/datasets'+import { addSegment } from '@/service/datasets'+import TagInput from '@/app/components/base/tag-input'++type NewSegmentModalProps = {+ isShow: boolean+ onCancel: () => void+ docForm: string+ onSave: () => void+}++const NewSegmentModal: FC<NewSegmentModalProps> = ({+ isShow,+ onCancel,+ docForm,+ onSave,+}) => {+ const { t } = useTranslation()+ const { notify } = useContext(ToastContext)+ const [question, setQuestion] = useState('')+ const [answer, setAnswer] = useState('')+ const { datasetId, documentId } = useParams()+ const [keywords, setKeywords] = useState<string[]>([])+ const [loading, setLoading] = useState(false)++ const handleCancel = () => {+ setQuestion('')+ setAnswer('')+ onCancel()+ setKeywords([])+ }++ const handleSave = async () => {+ const params: SegmentUpdater = { content: '' }+ if (docForm === 'qa_model') {+ if (!question.trim())+ return notify({ type: 'error', message: t('datasetDocuments.segment.questionEmpty') })+ if (!answer.trim())+ return notify({ type: 'error', message: t('datasetDocuments.segment.answerEmpty') })++ params.content = question+ params.answer = answer+ }+ else {+ if (!question.trim())+ return notify({ type: 'error', message: t('datasetDocuments.segment.contentEmpty') })++ params.content = question+ }++ if (keywords?.length)+ params.keywords = keywords++ setLoading(true)+ try {+ await addSegment({ datasetId, documentId, body: params })+ notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })+ handleCancel()+ onSave()+ }+ finally {+ setLoading(false)+ }+ }++ const renderContent = () => {+ if (docForm === 'qa_model') {+ return (+ <>+ <div className='mb-1 text-xs font-medium text-gray-500'>QUESTION</div>+ <AutoHeightTextarea+ outerClassName='mb-4'+ className='leading-6 text-md text-gray-800'+ value={question}+ placeholder={t('datasetDocuments.segment.questionPlaceholder') || ''}+ onChange={e => setQuestion(e.target.value)}+ autoFocus+ />+ <div className='mb-1 text-xs font-medium text-gray-500'>ANSWER</div>+ <AutoHeightTextarea+ outerClassName='mb-4'+ className='leading-6 text-md text-gray-800'+ value={answer}+ placeholder={t('datasetDocuments.segment.answerPlaceholder') || ''}+ onChange={e => setAnswer(e.target.value)}+ />+ </>+ )+ }++ return (+ <AutoHeightTextarea+ className='leading-6 text-md text-gray-800'+ value={question}+ placeholder={t('datasetDocuments.segment.contentPlaceholder') || ''}+ onChange={e => setQuestion(e.target.value)}+ autoFocus+ />+ )+ }++ return (+ <Modal isShow={isShow} onClose={() => { }} className='pt-8 px-8 pb-6 !max-w-[640px] !rounded-xl'>+ <div className={'flex flex-col relative'}>+ <div className='absolute right-0 -top-0.5 flex items-center h-6'>+ <div className='flex justify-center items-center w-6 h-6 cursor-pointer' onClick={handleCancel}>+ <RiCloseLine className='w-4 h-4 text-gray-500' />+ </div>+ </div>+ <div className='mb-[14px]'>+ <span className='inline-flex items-center px-1.5 h-5 border border-gray-200 rounded-md'>+ <Hash02 className='mr-0.5 w-3 h-3 text-gray-400' />+ <span className='text-[11px] font-medium text-gray-500 italic'>+ {+ docForm === 'qa_model'+ ? t('datasetDocuments.segment.newQaSegment')+ : t('datasetDocuments.segment.newTextSegment')+ }+ </span>+ </span>+ </div>+ <div className='mb-4 py-1.5 h-[420px] overflow-auto'>{renderContent()}</div>+ <div className='text-xs font-medium text-gray-500'>{t('datasetDocuments.segment.keywords')}</div>+ <div className='mb-8'>+ <TagInput items={keywords} onChange={newKeywords => setKeywords(newKeywords)} />+ </div>+ <div className='flex justify-end'>+ <Button+ onClick={handleCancel}>+ {t('common.operation.cancel')}+ </Button>+ <Button+ variant='primary'+ onClick={handleSave}+ disabled={loading}+ >+ {t('common.operation.save')}+ </Button>+ </div>+ </div>+ </Modal>+ )+}++export default memo(NewSegmentModal)diff --git a/web/app/components/datasets/documents/detail/new-segment.tsx b/web/app/components/datasets/documents/detail/new-segment.tsxdeleted file mode 100644index e0eec87f0aa..00000000000--- a/web/app/components/datasets/documents/detail/new-segment.tsx+++ /dev/null@@ -1,208 +0,0 @@-import { memo, useMemo, useRef, useState } from 'react'-import type { FC } from 'react'-import { useTranslation } from 'react-i18next'-import { useContext } from 'use-context-selector'-import { useParams } from 'next/navigation'-import { RiCloseLine, RiExpandDiagonalLine } from '@remixicon/react'-import { useShallow } from 'zustand/react/shallow'-import { useSegmentListContext } from './completed'-import { SegmentIndexTag } from './completed/common/segment-index-tag'-import ActionButtons from './completed/common/action-buttons'-import Keywords from './completed/common/keywords'-import ChunkContent from './completed/common/chunk-content'-import AddAnother from './completed/common/add-another'-import Dot from './completed/common/dot'-import { useDocumentContext } from './index'-import { useStore as useAppStore } from '@/app/components/app/store'-import { ToastContext } from '@/app/components/base/toast'-import { ChunkingMode, type SegmentUpdater } from '@/models/datasets'-import classNames from '@/utils/classnames'-import { formatNumber } from '@/utils/format'-import Divider from '@/app/components/base/divider'-import { useAddSegment } from '@/service/knowledge/use-segment'--type NewSegmentModalProps = {- onCancel: () => void- docForm: ChunkingMode- onSave: () => void- viewNewlyAddedChunk: () => void-}--const NewSegmentModal: FC<NewSegmentModalProps> = ({- onCancel,- docForm,- onSave,- viewNewlyAddedChunk,-}) => {- const { t } = useTranslation()- const { notify } = useContext(ToastContext)- const [question, setQuestion] = useState('')- const [answer, setAnswer] = useState('')- const { datasetId, documentId } = useParams<{ datasetId: string; documentId: string }>()- const [keywords, setKeywords] = useState<string[]>([])- const [loading, setLoading] = useState(false)- const [addAnother, setAddAnother] = useState(true)- const fullScreen = useSegmentListContext(s => s.fullScreen)- const toggleFullScreen = useSegmentListContext(s => s.toggleFullScreen)- const mode = useDocumentContext(s => s.mode)- const { appSidebarExpand } = useAppStore(useShallow(state => ({- appSidebarExpand: state.appSidebarExpand,- })))- const refreshTimer = useRef<any>(null)-- const CustomButton = <>- <Divider type='vertical' className='h-3 mx-1 bg-divider-regular' />- <button- type='button'- className='text-text-accent system-xs-semibold'- onClick={() => {- clearTimeout(refreshTimer.current)- viewNewlyAddedChunk()- }}>- {t('common.operation.view')}- </button>- </>-- const isQAModel = useMemo(() => {- return docForm === ChunkingMode.qa- }, [docForm])-- const handleCancel = (actionType: 'esc' | 'add' = 'esc') => {- if (actionType === 'esc' || !addAnother)- onCancel()- setQuestion('')- setAnswer('')- setKeywords([])- }-- const { mutateAsync: addSegment } = useAddSegment()-- const handleSave = async () => {- const params: SegmentUpdater = { content: '' }- if (isQAModel) {- if (!question.trim()) {- return notify({- type: 'error',- message: t('datasetDocuments.segment.questionEmpty'),- })- }- if (!answer.trim()) {- return notify({- type: 'error',- message: t('datasetDocuments.segment.answerEmpty'),- })- }-- params.content = question- params.answer = answer- }- else {- if (!question.trim()) {- return notify({- type: 'error',- message: t('datasetDocuments.segment.contentEmpty'),- })- }-- params.content = question- }-- if (keywords?.length)- params.keywords = keywords-- setLoading(true)- await addSegment({ datasetId, documentId, body: params }, {- onSuccess() {- notify({- type: 'success',- message: t('datasetDocuments.segment.chunkAdded'),- className: `!w-[296px] !bottom-0 ${appSidebarExpand === 'expand' ? '!left-[216px]' : '!left-14'}- !top-auto !right-auto !mb-[52px] !ml-11`,- customComponent: CustomButton,- })- handleCancel('add')- refreshTimer.current = setTimeout(() => {- onSave()- }, 3000)- },- onSettled() {- setLoading(false)- },- })- }-- const wordCountText = useMemo(() => {- const count = isQAModel ? (question.length + answer.length) : question.length- return `${formatNumber(count)} ${t('datasetDocuments.segment.characters', { count })}`- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [question.length, answer.length, isQAModel])-- return (- <div className={'flex flex-col h-full'}>- <div className={classNames('flex items-center justify-between', fullScreen ? 'py-3 pr-4 pl-6 border border-divider-subtle' : 'pt-3 pr-3 pl-4')}>- <div className='flex flex-col'>- <div className='text-text-primary system-xl-semibold'>{- t('datasetDocuments.segment.addChunk')- }</div>- <div className='flex items-center gap-x-2'>- <SegmentIndexTag label={t('datasetDocuments.segment.newChunk')!} />- <Dot />- <span className='text-text-tertiary system-xs-medium'>{wordCountText}</span>- </div>- </div>- <div className='flex items-center'>- {fullScreen && (- <>- <AddAnother className='mr-3' isChecked={addAnother} onCheck={() => setAddAnother(!addAnother)} />- <ActionButtons- handleCancel={handleCancel.bind(null, 'esc')}- handleSave={handleSave}- loading={loading}- actionType='add'- />- <Divider type='vertical' className='h-3.5 bg-divider-regular ml-4 mr-2' />- </>- )}- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer mr-1' onClick={toggleFullScreen}>- <RiExpandDiagonalLine className='w-4 h-4 text-text-tertiary' />- </div>- <div className='w-8 h-8 flex justify-center items-center p-1.5 cursor-pointer' onClick={handleCancel.bind(null, 'esc')}>- <RiCloseLine className='w-4 h-4 text-text-tertiary' />- </div>- </div>- </div>- <div className={classNames('flex grow', fullScreen ? 'w-full flex-row justify-center px-6 pt-6 gap-x-8' : 'flex-col gap-y-1 py-3 px-4')}>- <div className={classNames('break-all overflow-hidden whitespace-pre-line', fullScreen ? 'w-1/2' : 'grow')}>- <ChunkContent- docForm={docForm}- question={question}- answer={answer}- onQuestionChange={question => setQuestion(question)}- onAnswerChange={answer => setAnswer(answer)}- isEditMode={true}- />- </div>- {mode === 'custom' && <Keywords- className={fullScreen ? 'w-1/5' : ''}- actionType='add'- keywords={keywords}- isEditMode={true}- onKeywordsChange={keywords => setKeywords(keywords)}- />}- </div>- {!fullScreen && (- <div className='flex items-center justify-between p-4 pt-3 border-t-[1px] border-t-divider-subtle'>- <AddAnother isChecked={addAnother} onCheck={() => setAddAnother(!addAnother)} />- <ActionButtons- handleCancel={handleCancel.bind(null, 'esc')}- handleSave={handleSave}- loading={loading}- actionType='add'- />- </div>- )}- </div>- )-}--export default memo(NewSegmentModal)diff --git a/web/app/components/datasets/documents/detail/segment-add/index.tsx b/web/app/components/datasets/documents/detail/segment-add/index.tsxindex 7123c99b347..e69f3e9ab03 100644--- a/web/app/components/datasets/documents/detail/segment-add/index.tsx+++ b/web/app/components/datasets/documents/detail/segment-add/index.tsx@@ -1,14 +1,13 @@'use client'import type { FC } from 'react'-import React, { useMemo } from 'react'+import React from 'react'import { useTranslation } from 'react-i18next'import {- RiAddLine,- RiArrowDownSLine,RiErrorWarningFill,RiLoader2Line,} from '@remixicon/react'import cn from '@/utils/classnames'+import { FilePlus02 } from '@/app/components/base/icons/src/vender/line/files'import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general'import Popover from '@/app/components/base/popover'@@ -17,7 +16,6 @@ export type ISegmentAddProps = {clearProcessStatus: () => voidshowNewSegmentModal: () => voidshowBatchModal: () => void- embedding: boolean}export enum ProcessStatus {@@ -32,49 +30,32 @@ const SegmentAdd: FC<ISegmentAddProps> = ({clearProcessStatus,showNewSegmentModal,showBatchModal,- embedding,}) => {const { t } = useTranslation()- const textColor = useMemo(() => {- return embedding- ? 'text-components-button-secondary-accent-text-disabled'- : 'text-components-button-secondary-accent-text'- }, [embedding])if (importStatus) {return (<>{(importStatus === ProcessStatus.WAITING || importStatus === ProcessStatus.PROCESSING) && (- <div className='relative overflow-hidden inline-flex items-center mr-2 px-2.5 py-2 text-components-button-secondary-accent-text- bg-components-progress-bar-border rounded-lg border-[0.5px] border-components-progress-bar-border- shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]'>- <div className={cn('absolute left-0 top-0 h-full bg-components-progress-bar-progress border-r-[1.5px] border-r-components-progress-bar-progress-highlight z-0', importStatus === ProcessStatus.WAITING ? 'w-3/12' : 'w-2/3')} />- <RiLoader2Line className='animate-spin mr-1 w-4 h-4' />- <span className='system-sm-medium z-10 pr-0.5'>{t('datasetDocuments.list.batchModal.processing')}</span>+ <div className='relative overflow-hidden inline-flex items-center mr-2 px-3 py-[6px] text-blue-700 bg-[#F5F8FF] rounded-lg border border-black/5'>+ {importStatus === ProcessStatus.WAITING && <div className='absolute left-0 top-0 w-3/12 h-full bg-[#D1E0FF] z-0' />}+ {importStatus === ProcessStatus.PROCESSING && <div className='absolute left-0 top-0 w-2/3 h-full bg-[#D1E0FF] z-0' />}+ <RiLoader2Line className='animate-spin mr-2 w-4 h-4' />+ <span className='font-medium text-[13px] leading-[18px] z-10'>{t('datasetDocuments.list.batchModal.processing')}</span></div>)}{importStatus === ProcessStatus.COMPLETED && (- <div className='relative inline-flex items-center mr-2 bg-components-panel-bg rounded-lg border-[0.5px] border-components-panel-border shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] overflow-hidden'>- <div className='inline-flex items-center px-2.5 py-2 text-text-success border-r border-r-divider-subtle'>- <CheckCircle className='mr-1 w-4 h-4' />- <span className='system-sm-medium pr-0.5'>{t('datasetDocuments.list.batchModal.completed')}</span>- </div>- <div className='m-1 inline-flex items-center'>- <span className='system-xs-medium text-components-button-ghost-text hover:bg-components-button-ghost-bg-hover px-1.5 py-1 rounded-md cursor-pointer' onClick={clearProcessStatus}>{t('datasetDocuments.list.batchModal.ok')}</span>- </div>- <div className='absolute top-0 left-0 w-full h-full bg-dataset-chunk-process-success-bg opacity-40 -z-10' />+ <div className='inline-flex items-center mr-2 px-3 py-[6px] text-gray-700 bg-[#F6FEF9] rounded-lg border border-black/5'>+ <CheckCircle className='mr-2 w-4 h-4 text-[#039855]' />+ <span className='font-medium text-[13px] leading-[18px]'>{t('datasetDocuments.list.batchModal.completed')}</span>+ <span className='pl-2 font-medium text-[13px] leading-[18px] text-[#155EEF] cursor-pointer' onClick={clearProcessStatus}>{t('datasetDocuments.list.batchModal.ok')}</span></div>)}{importStatus === ProcessStatus.ERROR && (- <div className='relative inline-flex items-center mr-2 bg-components-panel-bg rounded-lg border-[0.5px] border-components-panel-border shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] overflow-hidden'>- <div className='inline-flex items-center px-2.5 py-2 text-text-destructive border-r border-r-divider-subtle'>- <RiErrorWarningFill className='mr-1 w-4 h-4' />- <span className='system-sm-medium pr-0.5'>{t('datasetDocuments.list.batchModal.error')}</span>- </div>- <div className='m-1 inline-flex items-center'>- <span className='system-xs-medium text-components-button-ghost-text hover:bg-components-button-ghost-bg-hover px-1.5 py-1 rounded-md cursor-pointer' onClick={clearProcessStatus}>{t('datasetDocuments.list.batchModal.ok')}</span>- </div>- <div className='absolute top-0 left-0 w-full h-full bg-dataset-chunk-process-error-bg opacity-40 -z-10' />+ <div className='inline-flex items-center mr-2 px-3 py-[6px] text-red-600 bg-red-100 rounded-lg border border-black/5'>+ <RiErrorWarningFill className='mr-2 w-4 h-4 text-[#D92D20]' />+ <span className='font-medium text-[13px] leading-[18px]'>{t('datasetDocuments.list.batchModal.error')}</span>+ <span className='pl-2 font-medium text-[13px] leading-[18px] text-[#155EEF] cursor-pointer' onClick={clearProcessStatus}>{t('datasetDocuments.list.batchModal.ok')}</span></div>)}</>@@ -82,53 +63,24 @@ const SegmentAdd: FC<ISegmentAddProps> = ({}return (- <div className={cn(- 'flex items-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] relative z-20',- embedding && 'border-components-button-secondary-border-disabled bg-components-button-secondary-bg-disabled',- )}>- <button- type='button'- className={`inline-flex items-center px-2.5 py-2 rounded-l-lg border-r-[1px] border-r-divider-subtle- hover:bg-state-base-hover disabled:cursor-not-allowed disabled:hover:bg-transparent`}- onClick={showNewSegmentModal}- disabled={embedding}- >- <RiAddLine className={cn('w-4 h-4', textColor)} />- <span className={cn('text-[13px] leading-[16px] font-medium capitalize px-0.5 ml-0.5', textColor)}>- {t('datasetDocuments.list.action.addButton')}- </span>- </button>- <Popover- position='br'- manualClose- trigger='click'- htmlContent={- <div className='w-full p-1'>- <button- type='button'- className='w-full py-1.5 px-2 flex items-center hover:bg-state-base-hover rounded-lg text-text-secondary system-md-regular'- onClick={showBatchModal}- >- {t('datasetDocuments.list.action.batchAdd')}- </button>- </div>- }- btnElement={- <div className='flex justify-center items-center' >- <RiArrowDownSLine className={cn('w-4 h-4', textColor)}/>- </div>- }- btnClassName={open => cn(- `!p-2 !border-0 !rounded-l-none !rounded-r-lg !hover:bg-state-base-hover backdrop-blur-[5px]- disabled:cursor-not-allowed disabled:bg-transparent disabled:hover:bg-transparent`,- open ? '!bg-state-base-hover' : '',- )}- popupClassName='!min-w-[128px] !bg-components-panel-bg-blur !rounded-xl border-[0.5px] !ring-0- border-components-panel-border !shadow-xl !shadow-shadow-shadow-5 backdrop-blur-[5px]'- className='min-w-[128px] h-fit'- disabled={embedding}- />- </div>+ <Popover+ manualClose+ trigger='click'+ htmlContent={+ <div className='w-full py-1'>+ <div className='py-2 px-3 mx-1 flex items-center gap-2 hover:bg-gray-100 rounded-lg cursor-pointer text-gray-700 text-sm' onClick={showNewSegmentModal}>{t('datasetDocuments.list.action.add')}</div>+ <div className='py-2 px-3 mx-1 flex items-center gap-2 hover:bg-gray-100 rounded-lg cursor-pointer text-gray-700 text-sm' onClick={showBatchModal}>{t('datasetDocuments.list.action.batchAdd')}</div>+ </div>+ }+ btnElement={+ <div className='inline-flex items-center'>+ <FilePlus02 className='w-4 h-4 text-gray-700' />+ <span className='pl-1'>{t('datasetDocuments.list.action.addButton')}</span>+ </div>+ }+ btnClassName={open => cn('mr-2 !py-[6px] !text-[13px] !leading-[18px] hover:bg-gray-50 border border-gray-200 hover:border-gray-300 hover:shadow-[0_1px_2px_rgba(16,24,40,0.05)]', open ? '!bg-gray-100 !shadow-none' : '!bg-transparent')}+ className='!w-[132px] h-fit !z-20 !translate-x-0 !left-0'+ />)}export default React.memo(SegmentAdd)diff --git a/web/app/components/datasets/documents/detail/settings/index.tsx b/web/app/components/datasets/documents/detail/settings/index.tsxindex 05c52d4de89..b2646654584 100644--- a/web/app/components/datasets/documents/detail/settings/index.tsx+++ b/web/app/components/datasets/documents/detail/settings/index.tsx@@ -1,11 +1,13 @@'use client'-import React, { useMemo } from 'react'+import React, { useEffect, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { useBoolean } from 'ahooks'import { useContext } from 'use-context-selector'import { useRouter } from 'next/navigation'import DatasetDetailContext from '@/context/dataset-detail'-import type { CrawlOptions, CustomFile } from '@/models/datasets'+import type { CrawlOptions, CustomFile, FullDocumentDetail } from '@/models/datasets'+import type { MetadataType } from '@/service/datasets'+import { fetchDocumentDetail } from '@/service/datasets'import Loading from '@/app/components/base/loading'import StepTwo from '@/app/components/datasets/create/step-two'@@ -14,7 +16,6 @@ import AppUnavailable from '@/app/components/base/app-unavailable'import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import type { NotionPage } from '@/models/common'-import { useDocumentDetail, useInvalidDocumentDetailKey } from '@/service/knowledge/use-document'type DocumentSettingsProps = {datasetId: string@@ -25,23 +26,15 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => {const { t } = useTranslation()const router = useRouter()const [isShowSetAPIKey, { setTrue: showSetAPIKey, setFalse: hideSetAPIkey }] = useBoolean()+ const [hasError, setHasError] = useState(false)const { indexingTechnique, dataset } = useContext(DatasetDetailContext)const { data: embeddingsDefaultModel } = useDefaultModel(ModelTypeEnum.textEmbedding)- const invalidDocumentDetail = useInvalidDocumentDetailKey()- const saveHandler = () => {- invalidDocumentDetail()- router.push(`/datasets/${datasetId}/documents/${documentId}`)- }+ const saveHandler = () => router.push(`/datasets/${datasetId}/documents/${documentId}`)const cancelHandler = () => router.back()- const { data: documentDetail, error } = useDocumentDetail({- datasetId,- documentId,- params: { metadata: 'without' },- })-+ const [documentDetail, setDocumentDetail] = useState<FullDocumentDetail | null>(null)const currentPage = useMemo(() => {return {workspace_id: documentDetail?.data_source_info.notion_workspace_id,@@ -51,8 +44,23 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => {type: documentDetail?.data_source_type,}}, [documentDetail])+ useEffect(() => {+ (async () => {+ try {+ const detail = await fetchDocumentDetail({+ datasetId,+ documentId,+ params: { metadata: 'without' as MetadataType },+ })+ setDocumentDetail(detail)+ }+ catch (e) {+ setHasError(true)+ }+ })()+ }, [datasetId, documentId])- if (error)+ if (hasError)return <AppUnavailable code={500} unknownReason={t('datasetCreation.error.unavailable') as string} />return (@@ -77,7 +85,7 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => {websiteCrawlProvider={documentDetail.data_source_info?.provider}websiteCrawlJobId={documentDetail.data_source_info?.job_id}crawlOptions={documentDetail.data_source_info as unknown as CrawlOptions}- indexingType={indexingTechnique}+ indexingType={indexingTechnique || ''}isSettingdocumentDetail={documentDetail}files={[documentDetail.data_source_info.upload_file as CustomFile]}diff --git a/web/app/components/datasets/documents/detail/style.module.css b/web/app/components/datasets/documents/detail/style.module.cssindex 8a59ef6f066..69295ab31c3 100644--- a/web/app/components/datasets/documents/detail/style.module.css+++ b/web/app/components/datasets/documents/detail/style.module.css@@ -5,7 +5,11 @@@apply h-6 w-6 !important;}.layoutRightIcon {- @apply p-2 ml-2 border-[0.5px] border-components-button-secondary-border hover:border-components-button-secondary-border-hover- rounded-lg bg-components-button-secondary-bg hover:bg-components-button-secondary-bg-hover cursor-pointer- shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px];+ @apply w-8 h-8 ml-2 box-border border border-gray-200 rounded-lg hover:bg-gray-50 cursor-pointer hover:shadow-[0_1px_2px_rgba(16,24,40,0.05)];+}+.iconShow {+ background: center center url(../assets/layoutRightShow.svg) no-repeat;+}+.iconClose {+ background: center center url(../assets/layoutRightClose.svg) no-repeat;}diff --git a/web/app/components/datasets/documents/index.tsx b/web/app/components/datasets/documents/index.tsxindex 7365ff98507..7a61d4d580c 100644--- a/web/app/components/datasets/documents/index.tsx+++ b/web/app/components/datasets/documents/index.tsx@@ -1,19 +1,18 @@'use client'import type { FC } from 'react'-import React, { useCallback, useEffect, useMemo, useState } from 'react'+import React, { useMemo, useState } from 'react'import useSWR from 'swr'import { useTranslation } from 'react-i18next'import { useRouter } from 'next/navigation'import { useDebounce, useDebounceFn } from 'ahooks'import { groupBy, omit } from 'lodash-es'import { PlusIcon } from '@heroicons/react/24/solid'-import { RiExternalLinkLine } from '@remixicon/react'-import AutoDisabledDocument from '../common/document-status-with-action/auto-disabled-document'import List from './list'import s from './style.module.css'import Loading from '@/app/components/base/loading'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'+import Pagination from '@/app/components/base/pagination'import { get } from '@/service/base'import { createDocument, fetchDocuments } from '@/service/datasets'import { useDatasetDetailContext } from '@/context/dataset-detail'@@ -21,9 +20,10 @@ import { NotionPageSelectorModal } from '@/app/components/base/notion-page-selecimport type { NotionPage } from '@/models/common'import type { CreateDocumentReq } from '@/models/datasets'import { DataSourceType } from '@/models/datasets'-import IndexFailed from '@/app/components/datasets/common/document-status-with-action/index-failed'-import { useProviderContext } from '@/context/provider-context'-import cn from '@/utils/classnames'+import RetryButton from '@/app/components/base/retry-button'+// Custom page count is not currently supported.+const limit = 15+const FolderPlusIcon = ({ className }: React.SVGProps<SVGElement>) => {return <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}><path d="M10.8332 5.83333L9.90355 3.9741C9.63601 3.439 9.50222 3.17144 9.30265 2.97597C9.12615 2.80311 8.91344 2.67164 8.6799 2.59109C8.41581 2.5 8.11668 2.5 7.51841 2.5H4.33317C3.39975 2.5 2.93304 2.5 2.57652 2.68166C2.26292 2.84144 2.00795 3.09641 1.84816 3.41002C1.6665 3.76654 1.6665 4.23325 1.6665 5.16667V5.83333M1.6665 5.83333H14.3332C15.7333 5.83333 16.4334 5.83333 16.9681 6.10582C17.4386 6.3455 17.821 6.72795 18.0607 7.19836C18.3332 7.73314 18.3332 8.4332 18.3332 9.83333V13.5C18.3332 14.9001 18.3332 15.6002 18.0607 16.135C17.821 16.6054 17.4386 16.9878 16.9681 17.2275C16.4334 17.5 15.7333 17.5 14.3332 17.5H5.6665C4.26637 17.5 3.56631 17.5 3.03153 17.2275C2.56112 16.9878 2.17867 16.6054 1.93899 16.135C1.6665 15.6002 1.6665 14.9001 1.6665 13.5V5.83333ZM9.99984 14.1667V9.16667M7.49984 11.6667H12.4998" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />@@ -74,16 +74,12 @@ type IDocumentsProps = {}export const fetcher = (url: string) => get(url, {}, {})-const DEFAULT_LIMIT = 15const Documents: FC<IDocumentsProps> = ({ datasetId }) => {const { t } = useTranslation()- const { plan } = useProviderContext()- const isFreePlan = plan.type === 'sandbox'const [inputValue, setInputValue] = useState<string>('') // the input valueconst [searchValue, setSearchValue] = useState<string>('')const [currPage, setCurrPage] = React.useState<number>(0)- const [limit, setLimit] = useState<number>(DEFAULT_LIMIT)const router = useRouter()const { dataset } = useDatasetDetailContext()const [notionPageSelectorModalVisible, setNotionPageSelectorModalVisible] = useState(false)@@ -97,9 +93,9 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {const query = useMemo(() => {return { page: currPage + 1, limit, keyword: debouncedSearchValue, fetch: isDataSourceNotion ? true : '' }- }, [currPage, debouncedSearchValue, isDataSourceNotion, limit])+ }, [currPage, debouncedSearchValue, isDataSourceNotion])- const { data: documentsRes, error, mutate, isLoading: isListLoading } = useSWR(+ const { data: documentsRes, error, mutate } = useSWR({action: 'fetchDocuments',datasetId,@@ -109,17 +105,6 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {{ refreshInterval: (isDataSourceNotion && timerCanRun) ? 2500 : 0 },)- const [isMuting, setIsMuting] = useState(false)- useEffect(() => {- if (!isListLoading && isMuting)- setIsMuting(false)- }, [isListLoading, isMuting])-- const handleUpdate = useCallback(() => {- setIsMuting(true)- mutate()- }, [mutate])-const documentsWithProgress = useMemo(() => {let completedNum = 0let percent = 0@@ -161,7 +146,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {router.push(`/datasets/${datasetId}/documents/create`)}- const isLoading = isListLoading // !documentsRes && !error+ const isLoading = !documentsRes && !errorconst handleSaveNotionPageSelected = async (selectedPages: NotionPage[]) => {const workspacesMap = groupBy(selectedPages, 'workspace_id')@@ -210,7 +195,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {}const documentsList = isDataSourceNotion ? documentsWithProgress?.data : documentsRes?.data- const [selectedIds, setSelectedIds] = useState<string[]>([])+const { run: handleSearch } = useDebounceFn(() => {setSearchValue(inputValue)}, { wait: 500 })@@ -223,17 +208,8 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {return (<div className='flex flex-col h-full overflow-y-auto'><div className='flex flex-col justify-center gap-1 px-6 pt-4'>- <h1 className='text-base font-semibold text-text-primary'>{t('datasetDocuments.list.title')}</h1>- <div className='flex items-center text-sm font-normal text-text-tertiary space-x-0.5'>- <span>{t('datasetDocuments.list.desc')}</span>- <a- className='flex items-center text-text-accent'- target='_blank'- href='https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application'>- <span>{t('datasetDocuments.list.learnMore')}</span>- <RiExternalLinkLine className='w-3 h-3' />- </a>- </div>+ <h1 className={s.title}>{t('datasetDocuments.list.title')}</h1>+ <p className={s.desc}>{t('datasetDocuments.list.desc')}</p></div><div className='flex flex-col px-6 py-4 flex-1'><div className='flex items-center justify-between flex-wrap'>@@ -246,38 +222,27 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {onClear={() => handleInputChange('')}/><div className='flex gap-2 justify-center items-center !h-8'>- {!isFreePlan && <AutoDisabledDocument datasetId={datasetId} />}- <IndexFailed datasetId={datasetId} />+ <RetryButton datasetId={datasetId} />{embeddingAvailable && (<Button variant='primary' onClick={routeToDocCreate} className='shrink-0'>- <PlusIcon className={cn('h-4 w-4 mr-2 stroke-current')} />+ <PlusIcon className='h-4 w-4 mr-2 stroke-current' />{isDataSourceNotion && t('datasetDocuments.list.addPages')}{isDataSourceWeb && t('datasetDocuments.list.addUrl')}- {(!dataset?.data_source_type || isDataSourceFile) && t('datasetDocuments.list.addFile')}+ {isDataSourceFile && t('datasetDocuments.list.addFile')}</Button>)}</div></div>- {(isLoading && !isMuting)+ {isLoading? <Loading type='app' />: total > 0- ? <List- embeddingAvailable={embeddingAvailable}- documents={documentsList || []}- datasetId={datasetId}- onUpdate={handleUpdate}- selectedIds={selectedIds}- onSelectedIdChange={setSelectedIds}- pagination={{- total,- limit,- onLimitChange: setLimit,- current: currPage,- onChange: setCurrPage,- }}- />+ ? <List embeddingAvailable={embeddingAvailable} documents={documentsList || []} datasetId={datasetId} onUpdate={mutate} />: <EmptyElement canAdd={embeddingAvailable} onClick={routeToDocCreate} type={isDataSourceNotion ? 'sync' : 'upload'} />}+ {/* Show Pagination only if the total is more than the limit */}+ {(total && total > limit)+ ? <Pagination current={currPage} onChange={setCurrPage} total={total} limit={limit} />+ : null}<NotionPageSelectorModalisShow={notionPageSelectorModalVisible}onClose={() => setNotionPageSelectorModalVisible(false)}diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsxindex 26c26414df6..0e0eebb034d 100644--- a/web/app/components/datasets/documents/list.tsx+++ b/web/app/components/datasets/documents/list.tsx@@ -1,15 +1,11 @@+/* eslint-disable no-mixed-operators */'use client'-import type { FC } from 'react'-import React, { useCallback, useEffect, useMemo, useState } from 'react'+import type { FC, SVGProps } from 'react'+import React, { useCallback, useEffect, useState } from 'react'import { useBoolean, useDebounceFn } from 'ahooks'-import { ArrowDownIcon } from '@heroicons/react/24/outline'-import { pick, uniq } from 'lodash-es'+import { ArrowDownIcon, TrashIcon } from '@heroicons/react/24/outline'+import { pick } from 'lodash-es'import {- RiArchive2Line,- RiDeleteBinLine,- RiEditLine,- RiEqualizer2Line,- RiLoopLeftLine,RiMoreFill,} from '@remixicon/react'import { useContext } from 'use-context-selector'@@ -18,33 +14,49 @@ import { useTranslation } from 'react-i18next'import dayjs from 'dayjs'import { Edit03 } from '../../base/icons/src/vender/solid/general'import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'-import ChunkingModeLabel from '../common/chunking-mode-label'-import FileTypeIcon from '../../base/file-uploader/file-type-icon'import s from './style.module.css'import RenameModal from './rename-modal'-import BatchAction from './detail/completed/common/batch-action'import cn from '@/utils/classnames'import Switch from '@/app/components/base/switch'import Divider from '@/app/components/base/divider'import Popover from '@/app/components/base/popover'import Confirm from '@/app/components/base/confirm'import Tooltip from '@/app/components/base/tooltip'-import Toast, { ToastContext } from '@/app/components/base/toast'-import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator'+import { ToastContext } from '@/app/components/base/toast'+import type { IndicatorProps } from '@/app/components/header/indicator'import Indicator from '@/app/components/header/indicator'import { asyncRunSafe } from '@/utils'import { formatNumber } from '@/utils/format'+import { archiveDocument, deleteDocument, disableDocument, enableDocument, syncDocument, syncWebsite, unArchiveDocument } from '@/service/datasets'import NotionIcon from '@/app/components/base/notion-icon'import ProgressBar from '@/app/components/base/progress-bar'-import { ChunkingMode, DataSourceType, DocumentActionType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'+import { DataSourceType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'import type { CommonResponse } from '@/models/common'import useTimestamp from '@/hooks/use-timestamp'-import { useDatasetDetailContextWithSelector as useDatasetDetailContext } from '@/context/dataset-detail'-import type { Props as PaginationProps } from '@/app/components/base/pagination'-import Pagination from '@/app/components/base/pagination'-import Checkbox from '@/app/components/base/checkbox'-import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentEnable, useDocumentUnArchive, useSyncDocument, useSyncWebsite } from '@/service/knowledge/use-document'-import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'++export const SettingsIcon = ({ className }: SVGProps<SVGElement>) => {+ return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>+ <path d="M2 5.33325L10 5.33325M10 5.33325C10 6.43782 10.8954 7.33325 12 7.33325C13.1046 7.33325 14 6.43782 14 5.33325C14 4.22868 13.1046 3.33325 12 3.33325C10.8954 3.33325 10 4.22868 10 5.33325ZM6 10.6666L14 10.6666M6 10.6666C6 11.7712 5.10457 12.6666 4 12.6666C2.89543 12.6666 2 11.7712 2 10.6666C2 9.56202 2.89543 8.66659 4 8.66659C5.10457 8.66659 6 9.56202 6 10.6666Z" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </svg>+}++export const SyncIcon = () => {+ return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">+ <path d="M5.69773 13.1783C7.29715 13.8879 9.20212 13.8494 10.8334 12.9075C13.5438 11.3427 14.4724 7.87704 12.9076 5.16672L12.7409 4.87804M3.09233 10.8335C1.52752 8.12314 2.45615 4.65746 5.16647 3.09265C6.7978 2.15081 8.70277 2.11227 10.3022 2.82185M1.66226 10.8892L3.48363 11.3773L3.97166 9.5559M12.0284 6.44393L12.5164 4.62256L14.3378 5.1106" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />+ </svg>+}++export const FilePlusIcon = ({ className }: SVGProps<SVGElement>) => {+ return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>+ <path d="M13.3332 6.99992V4.53325C13.3332 3.41315 13.3332 2.85309 13.1152 2.42527C12.9234 2.04895 12.6175 1.74299 12.2412 1.55124C11.8133 1.33325 11.2533 1.33325 10.1332 1.33325H5.8665C4.7464 1.33325 4.18635 1.33325 3.75852 1.55124C3.3822 1.74299 3.07624 2.04895 2.88449 2.42527C2.6665 2.85309 2.6665 3.41315 2.6665 4.53325V11.4666C2.6665 12.5867 2.6665 13.1467 2.88449 13.5746C3.07624 13.9509 3.3822 14.2569 3.75852 14.4486C4.18635 14.6666 4.7464 14.6666 5.8665 14.6666H7.99984M9.33317 7.33325H5.33317M6.6665 9.99992H5.33317M10.6665 4.66659H5.33317M11.9998 13.9999V9.99992M9.99984 11.9999H13.9998" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </svg>+}++export const ArchiveIcon = ({ className }: SVGProps<SVGElement>) => {+ return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>+ <path d="M2.66683 5.33106C2.55749 5.32824 2.47809 5.32191 2.40671 5.30771C1.87779 5.2025 1.46432 4.78904 1.35912 4.26012C1.3335 4.13132 1.3335 3.97644 1.3335 3.66667C1.3335 3.3569 1.3335 3.20201 1.35912 3.07321C1.46432 2.54429 1.87779 2.13083 2.40671 2.02562C2.53551 2 2.69039 2 3.00016 2H13.0002C13.3099 2 13.4648 2 13.5936 2.02562C14.1225 2.13083 14.536 2.54429 14.6412 3.07321C14.6668 3.20201 14.6668 3.3569 14.6668 3.66667C14.6668 3.97644 14.6668 4.13132 14.6412 4.26012C14.536 4.78904 14.1225 5.2025 13.5936 5.30771C13.5222 5.32191 13.4428 5.32824 13.3335 5.33106M6.66683 8.66667H9.3335M2.66683 5.33333H13.3335V10.8C13.3335 11.9201 13.3335 12.4802 13.1155 12.908C12.9238 13.2843 12.6178 13.5903 12.2415 13.782C11.8137 14 11.2536 14 10.1335 14H5.86683C4.74672 14 4.18667 14 3.75885 13.782C3.38252 13.5903 3.07656 13.2843 2.88482 12.908C2.66683 12.4802 2.66683 11.9201 2.66683 10.8V5.33333Z" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </svg>+}export const useIndexStatus = () => {const { t } = useTranslation()@@ -60,15 +72,6 @@ export const useIndexStatus = () => {}}-const STATUS_TEXT_COLOR_MAP: ColorMap = {- green: 'text-util-colors-green-green-600',- orange: 'text-util-colors-warning-warning-600',- red: 'text-util-colors-red-red-600',- blue: 'text-util-colors-blue-light-blue-light-600',- yellow: 'text-util-colors-warning-warning-600',- gray: 'text-text-tertiary',-}-// status item for listexport const StatusItem: FC<{status: DocumentDisplayStatus@@ -76,82 +79,16 @@ export const StatusItem: FC<{scene?: 'list' | 'detail'textCls?: stringerrorMessage?: string- detail?: {- enabled: boolean- archived: boolean- id: string- }- datasetId?: string- onUpdate?: (operationName?: string) => void--}> = ({ status, reverse = false, scene = 'list', textCls = '', errorMessage, datasetId = '', detail, onUpdate }) => {+}> = ({ status, reverse = false, scene = 'list', textCls = '', errorMessage }) => {const DOC_INDEX_STATUS_MAP = useIndexStatus()const localStatus = status.toLowerCase() as keyof typeof DOC_INDEX_STATUS_MAP- const { enabled = false, archived = false, id = '' } = detail || {}- const { notify } = useContext(ToastContext)- const { t } = useTranslation()- const { mutateAsync: enableDocument } = useDocumentEnable()- const { mutateAsync: disableDocument } = useDocumentDisable()- const { mutateAsync: deleteDocument } = useDocumentDelete()-- const onOperate = async (operationName: OperationName) => {- let opApi = deleteDocument- switch (operationName) {- case 'enable':- opApi = enableDocument- break- case 'disable':- opApi = disableDocument- break- }- const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)- if (!e) {- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- onUpdate?.(operationName)- }- else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }- }-- const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {- if (operationName === 'enable' && enabled)- return- if (operationName === 'disable' && !enabled)- return- onOperate(operationName)- }, { wait: 500 })-- const embedding = useMemo(() => {- return ['queuing', 'indexing', 'paused'].includes(localStatus)- }, [localStatus])-return <div className={cn('flex items-center',reverse ? 'flex-row-reverse' : '',scene === 'detail' ? s.statusItemDetail : '')}><Indicator color={DOC_INDEX_STATUS_MAP[localStatus]?.color as IndicatorProps['color']} className={reverse ? 'ml-2' : 'mr-2'} />- <span className={cn(`${STATUS_TEXT_COLOR_MAP[DOC_INDEX_STATUS_MAP[localStatus].color as keyof typeof STATUS_TEXT_COLOR_MAP]} text-sm`, textCls)}>- {DOC_INDEX_STATUS_MAP[localStatus]?.text}- </span>- {- scene === 'detail' && (- <div className='flex justify-between items-center ml-1.5'>- <Tooltip- popupContent={t('datasetDocuments.list.action.enableWarning')}- popupClassName='text-text-secondary system-xs-medium'- needsDelay- disabled={!archived}- >- <Switch- defaultValue={archived ? false : enabled}- onChange={v => !archived && handleSwitch(v ? 'enable' : 'disable')}- disabled={embedding || archived}- size='md'- />- </Tooltip>- </div>- )- }+ <span className={cn('text-gray-700 text-sm', textCls)}>{DOC_INDEX_STATUS_MAP[localStatus]?.text}</span>{errorMessage && (<Tooltip@@ -189,13 +126,7 @@ export const OperationAction: FC<{const { notify } = useContext(ToastContext)const { t } = useTranslation()const router = useRouter()- const { mutateAsync: archiveDocument } = useDocumentArchive()- const { mutateAsync: unArchiveDocument } = useDocumentUnArchive()- const { mutateAsync: enableDocument } = useDocumentEnable()- const { mutateAsync: disableDocument } = useDocumentDisable()- const { mutateAsync: deleteDocument } = useDocumentDelete()- const { mutateAsync: syncDocument } = useSyncDocument()- const { mutateAsync: syncWebsite } = useSyncWebsite()+const isListScene = scene === 'list'const onOperate = async (operationName: OperationName) => {@@ -216,8 +147,10 @@ export const OperationAction: FC<{case 'sync':if (data_source_type === 'notion_import')opApi = syncDocument+elseopApi = syncWebsite+breakdefault:opApi = deleteDocument@@ -225,13 +158,13 @@ export const OperationAction: FC<{break}const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)- if (!e) {+ if (!e)notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- onUpdate(operationName)- }- else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }+ else+ notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })if (operationName === 'delete')setDeleting(false)+ onUpdate(operationName)}const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {@@ -283,71 +216,85 @@ export const OperationAction: FC<{</>)}{embeddingAvailable && (- <>- <Tooltip- popupContent={t('datasetDocuments.list.action.settings')}- popupClassName='text-text-secondary system-xs-medium'- >- <button- className={cn('rounded-lg mr-2 cursor-pointer',- !isListScene- ? 'p-2 bg-components-button-secondary-bg hover:bg-components-button-secondary-bg-hover border-[0.5px] border-components-button-secondary-border hover:border-components-button-secondary-border-hover shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]'- : 'p-0.5 hover:bg-state-base-hover')}- onClick={() => router.push(`/datasets/${datasetId}/documents/${detail.id}/settings`)}>- <RiEqualizer2Line className='w-4 h-4 text-components-button-secondary-text' />- </button>- </Tooltip>- <Popover- htmlContent={- <div className='w-full py-1'>- {!archived && (- <>- <div className={s.actionItem} onClick={() => {- handleShowRenameModal({- id: detail.id,- name: detail.name,- })- }}>- <RiEditLine className='w-4 h-4 text-text-tertiary' />- <span className={s.actionName}>{t('datasetDocuments.list.table.rename')}</span>+ <Popover+ htmlContent={+ <div className='w-full py-1'>+ {!isListScene && <>+ <div className='flex justify-between items-center mx-4 pt-2'>+ <span className={cn(s.actionName, 'font-medium')}>+ {!archived && enabled ? t('datasetDocuments.list.index.enable') : t('datasetDocuments.list.index.disable')}+ </span>+ <Tooltip+ popupContent={t('datasetDocuments.list.action.enableWarning')}+ popupClassName='!font-semibold'+ needsDelay+ disabled={!archived}+ >+ <div>+ <Switch+ defaultValue={archived ? false : enabled}+ onChange={v => !archived && handleSwitch(v ? 'enable' : 'disable')}+ disabled={archived}+ size='md'+ /></div>- {['notion_import', DataSourceType.WEB].includes(data_source_type) && (- <div className={s.actionItem} onClick={() => onOperate('sync')}>- <RiLoopLeftLine className='w-4 h-4 text-text-tertiary' />- <span className={s.actionName}>{t('datasetDocuments.list.action.sync')}</span>- </div>- )}- <Divider className='my-1' />- </>- )}- {!archived && <div className={s.actionItem} onClick={() => onOperate('archive')}>- <RiArchive2Line className='w-4 h-4 text-text-tertiary' />- <span className={s.actionName}>{t('datasetDocuments.list.action.archive')}</span>- </div>}- {archived && (- <div className={s.actionItem} onClick={() => onOperate('un_archive')}>- <RiArchive2Line className='w-4 h-4 text-text-tertiary' />- <span className={s.actionName}>{t('datasetDocuments.list.action.unarchive')}</span>+ </Tooltip>+ </div>+ <div className='mx-4 pb-1 pt-0.5 text-xs text-gray-500'>+ {!archived && enabled ? t('datasetDocuments.list.index.enableTip') : t('datasetDocuments.list.index.disableTip')}+ </div>+ <Divider />+ </>}+ {!archived && (+ <>+ <div className={s.actionItem} onClick={() => {+ handleShowRenameModal({+ id: detail.id,+ name: detail.name,+ })+ }}>+ <Edit03 className='w-4 h-4 text-gray-500' />+ <span className={s.actionName}>{t('datasetDocuments.list.table.rename')}</span>+ </div>+ <div className={s.actionItem} onClick={() => router.push(`/datasets/${datasetId}/documents/${detail.id}/settings`)}>+ <SettingsIcon />+ <span className={s.actionName}>{t('datasetDocuments.list.action.settings')}</span></div>- )}- <div className={cn(s.actionItem, s.deleteActionItem, 'group')} onClick={() => setShowModal(true)}>- <RiDeleteBinLine className={'w-4 h-4 text-text-tertiary group-hover:text-text-destructive'} />- <span className={cn(s.actionName, 'group-hover:text-text-destructive')}>{t('datasetDocuments.list.action.delete')}</span>+ {['notion_import', DataSourceType.WEB].includes(data_source_type) && (+ <div className={s.actionItem} onClick={() => onOperate('sync')}>+ <SyncIcon />+ <span className={s.actionName}>{t('datasetDocuments.list.action.sync')}</span>+ </div>+ )}+ <Divider className='my-1' />+ </>+ )}+ {!archived && <div className={s.actionItem} onClick={() => onOperate('archive')}>+ <ArchiveIcon />+ <span className={s.actionName}>{t('datasetDocuments.list.action.archive')}</span>+ </div>}+ {archived && (+ <div className={s.actionItem} onClick={() => onOperate('un_archive')}>+ <ArchiveIcon />+ <span className={s.actionName}>{t('datasetDocuments.list.action.unarchive')}</span></div>+ )}+ <div className={cn(s.actionItem, s.deleteActionItem, 'group')} onClick={() => setShowModal(true)}>+ <TrashIcon className={'w-4 h-4 stroke-current text-gray-500 stroke-2 group-hover:text-red-500'} />+ <span className={cn(s.actionName, 'group-hover:text-red-500')}>{t('datasetDocuments.list.action.delete')}</span></div>- }- trigger='click'- position='br'- btnElement={- <div className={cn(s.commonIcon)}>- <RiMoreFill className='w-4 h-4 text-text-components-button-secondary-text' />- </div>- }- btnClassName={open => cn(isListScene ? s.actionIconWrapperList : s.actionIconWrapperDetail, open ? '!hover:bg-state-base-hover !shadow-none' : '!bg-transparent')}- popupClassName='!w-full'- className={`flex justify-end !w-[200px] h-fit !z-20 ${className}`}- />- </>+ </div>+ }+ trigger='click'+ position='br'+ btnElement={+ <div className={cn(s.commonIcon)}>+ <RiMoreFill className='w-4 h-4 text-gray-700' />+ </div>+ }+ btnClassName={open => cn(isListScene ? s.actionIconWrapperList : s.actionIconWrapperDetail, open ? '!bg-gray-100 !shadow-none' : '!bg-transparent')}+ className={`flex justify-end !w-[200px] h-fit !z-20 ${className}`}+ />)}{showModal&& <Confirm@@ -376,7 +323,7 @@ export const OperationAction: FC<{export const renderTdValue = (value: string | number | null, isEmptyStyle = false) => {return (- <div className={cn(isEmptyStyle ? 'text-text-tertiary' : 'text-text-secondary', s.tdValue)}>+ <div className={cn(isEmptyStyle ? 'text-gray-400' : 'text-gray-700', s.tdValue)}>{value ?? '-'}</div>)@@ -396,34 +343,19 @@ type LocalDoc = SimpleDocumentDetail & { percent?: number }type IDocumentListProps = {embeddingAvailable: booleandocuments: LocalDoc[]- selectedIds: string[]- onSelectedIdChange: (selectedIds: string[]) => voiddatasetId: string- pagination: PaginationPropsonUpdate: () => void}/*** Document list component including basic information*/-const DocumentList: FC<IDocumentListProps> = ({- embeddingAvailable,- documents = [],- selectedIds,- onSelectedIdChange,- datasetId,- pagination,- onUpdate,-}) => {+const DocumentList: FC<IDocumentListProps> = ({ embeddingAvailable, documents = [], datasetId, onUpdate }) => {const { t } = useTranslation()const { formatTime } = useTimestamp()const router = useRouter()- const [datasetConfig] = useDatasetDetailContext(s => [s.dataset])- const chunkingMode = datasetConfig?.doc_form- const isGeneralMode = chunkingMode !== ChunkingMode.parentChild- const isQAMode = chunkingMode === ChunkingMode.qaconst [localDocs, setLocalDocs] = useState<LocalDoc[]>(documents)- const [enableSort, setEnableSort] = useState(true)+ const [enableSort, setEnableSort] = useState(false)useEffect(() => {setLocalDocs(documents)@@ -431,7 +363,7 @@ const DocumentList: FC<IDocumentListProps> = ({const onClickSort = () => {setEnableSort(!enableSort)- if (enableSort) {+ if (!enableSort) {const sortedDocs = [...localDocs].sort((a, b) => dayjs(a.created_at).isBefore(dayjs(b.created_at)) ? -1 : 1)setLocalDocs(sortedDocs)}@@ -453,119 +385,46 @@ const DocumentList: FC<IDocumentListProps> = ({onUpdate()}, [onUpdate])- const isAllSelected = useMemo(() => {- return localDocs.length > 0 && localDocs.every(doc => selectedIds.includes(doc.id))- }, [localDocs, selectedIds])-- const isSomeSelected = useMemo(() => {- return localDocs.some(doc => selectedIds.includes(doc.id))- }, [localDocs, selectedIds])-- const onSelectedAll = useCallback(() => {- if (isAllSelected)- onSelectedIdChange([])- else- onSelectedIdChange(uniq([...selectedIds, ...localDocs.map(doc => doc.id)]))- }, [isAllSelected, localDocs, onSelectedIdChange, selectedIds])- const { mutateAsync: archiveDocument } = useDocumentArchive()- const { mutateAsync: enableDocument } = useDocumentEnable()- const { mutateAsync: disableDocument } = useDocumentDisable()- const { mutateAsync: deleteDocument } = useDocumentDelete()-- const handleAction = (actionName: DocumentActionType) => {- return async () => {- let opApi = deleteDocument- switch (actionName) {- case DocumentActionType.archive:- opApi = archiveDocument- break- case DocumentActionType.enable:- opApi = enableDocument- break- case DocumentActionType.disable:- opApi = disableDocument- break- default:- opApi = deleteDocument- break- }- const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentIds: selectedIds }) as Promise<CommonResponse>)-- if (!e) {- Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })- onUpdate()- }- else { Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }- }- }-return (- <div className='relative w-full h-full overflow-x-auto'>+ <div className='w-full h-full overflow-x-auto'><table className={`min-w-[700px] max-w-full w-full border-collapse border-0 text-sm mt-3 ${s.documentTable}`}>- <thead className="h-8 leading-8 border-b border-divider-subtle text-text-tertiary font-medium text-xs uppercase">+ <thead className="h-8 leading-8 border-b border-gray-200 text-gray-500 font-medium text-xs uppercase"><tr>- <td className='w-12'>- <div className='flex items-center' onClick={e => e.stopPropagation()}>- <Checkbox- className='shrink-0 mr-2'- checked={isAllSelected}- mixed={!isAllSelected && isSomeSelected}- onCheck={onSelectedAll}- />- #- </div>- </td>+ <td className='w-12'>#</td><td><div className='flex'>{t('datasetDocuments.list.table.header.fileName')}</div></td>- <td className='w-[130px]'>{t('datasetDocuments.list.table.header.chunkingMode')}</td><td className='w-24'>{t('datasetDocuments.list.table.header.words')}</td><td className='w-44'>{t('datasetDocuments.list.table.header.hitCount')}</td><td className='w-44'>- <div className='flex items-center' onClick={onClickSort}>+ <div className='flex justify-between items-center'>{t('datasetDocuments.list.table.header.uploadTime')}- <ArrowDownIcon className={cn('ml-0.5 h-3 w-3 stroke-current stroke-2 cursor-pointer', enableSort ? 'text-text-tertiary' : 'text-text-disabled')} />+ <ArrowDownIcon className={cn('h-3 w-3 stroke-current stroke-2 cursor-pointer', enableSort ? 'text-gray-500' : 'text-gray-300')} onClick={onClickSort} /></div></td><td className='w-40'>{t('datasetDocuments.list.table.header.status')}</td><td className='w-20'>{t('datasetDocuments.list.table.header.action')}</td></tr></thead>- <tbody className="text-text-secondary">- {localDocs.map((doc, index) => {+ <tbody className="text-gray-700">+ {localDocs.map((doc) => {const isFile = doc.data_source_type === DataSourceType.FILEconst fileType = isFile ? doc.data_source_detail_dict?.upload_file?.extension : ''return <trkey={doc.id}- className={'border-b border-divider-subtle h-8 hover:bg-background-default-hover cursor-pointer'}+ className={'border-b border-gray-200 h-8 hover:bg-gray-50 cursor-pointer'}onClick={() => {router.push(`/datasets/${datasetId}/documents/${doc.id}`)}}>- <td className='text-left align-middle text-text-tertiary text-xs'>- <div className='flex items-center' onClick={e => e.stopPropagation()}>- <Checkbox- className='shrink-0 mr-2'- checked={selectedIds.includes(doc.id)}- onCheck={() => {- onSelectedIdChange(- selectedIds.includes(doc.id)- ? selectedIds.filter(id => id !== doc.id)- : [...selectedIds, doc.id],- )- }}- />- {/* {doc.position} */}- {index + 1}- </div>- </td>+ <td className='text-left align-middle text-gray-500 text-xs'>{doc.position}</td><td>- <div className={'group flex items-center justify-between mr-6 hover:mr-0'}>- <span className={cn(s.tdValue, 'flex items-center')}>+ <div className='group flex items-center justify-between'>+ <span className={s.tdValue}>{doc?.data_source_type === DataSourceType.NOTION && <NotionIcon className='inline-flex -mt-[3px] mr-1.5 align-middle' type='page' src={doc.data_source_info.notion_page_icon} />}- {doc?.data_source_type === DataSourceType.FILE && <FileTypeIcon type={extensionToFileType(doc?.data_source_info?.upload_file?.extension ?? fileType)} className='mr-1.5' />}+ {doc?.data_source_type === DataSourceType.FILE && <div className={cn(s[`${doc?.data_source_info?.upload_file?.extension ?? fileType}Icon`], s.commonIcon, 'mr-1.5')}></div>}{doc?.data_source_type === DataSourceType.WEB && <Globe01 className='inline-flex -mt-[3px] mr-1.5 align-middle' />}{@@ -577,27 +436,22 @@ const DocumentList: FC<IDocumentListProps> = ({popupContent={t('datasetDocuments.list.table.rename')}><div- className='p-1 rounded-md cursor-pointer hover:bg-state-base-hover'+ className='p-1 rounded-md cursor-pointer hover:bg-black/5'onClick={(e) => {e.stopPropagation()handleShowRenameModal(doc)}}>- <Edit03 className='w-4 h-4 text-text-tertiary' />+ <Edit03 className='w-4 h-4 text-gray-500' /></div></Tooltip></div></div>- </td>- <td>- <ChunkingModeLabel- isGeneralMode={isGeneralMode}- isQAMode={isQAMode}- />+</td><td>{renderCount(doc.word_count)}</td><td>{renderCount(doc.hit_count)}</td>- <td className='text-text-secondary text-[13px]'>+ <td className='text-gray-500 text-[13px]'>{formatTime(doc.created_at, t('datasetHitTesting.dateTimeFormat') as string)}</td><td>@@ -619,26 +473,6 @@ const DocumentList: FC<IDocumentListProps> = ({})}</tbody></table>- {(selectedIds.length > 0) && (- <BatchAction- className='absolute left-0 bottom-16 z-20'- selectedIds={selectedIds}- onArchive={handleAction(DocumentActionType.archive)}- onBatchEnable={handleAction(DocumentActionType.enable)}- onBatchDisable={handleAction(DocumentActionType.disable)}- onBatchDelete={handleAction(DocumentActionType.delete)}- onCancel={() => {- onSelectedIdChange([])- }}- />- )}- {/* Show Pagination only if the total is more than the limit */}- {pagination.total && pagination.total > (pagination.limit || 10) && (- <Pagination- {...pagination}- className='absolute bottom-0 left-0 w-full px-0 pb-0'- />- )}{isShowRenameModal && currDocument && (<RenameModaldiff --git a/web/app/components/datasets/documents/style.module.css b/web/app/components/datasets/documents/style.module.cssindex e10402e9394..58b573bb503 100644--- a/web/app/components/datasets/documents/style.module.css+++ b/web/app/components/datasets/documents/style.module.css@@ -8,22 +8,26 @@box-sizing: border-box;max-width: 200px;}+.title {+ @apply text-xl font-medium text-gray-900;+}+.desc {+ @apply text-sm font-normal text-gray-500;+}.actionIconWrapperList {@apply h-6 w-6 rounded-md border-none p-1 hover:bg-gray-100 !important;}.actionIconWrapperDetail {- @apply p-2 bg-components-button-secondary-bg hover:bg-components-button-secondary-bg-hover- border-[0.5px] border-components-button-secondary-border hover:border-components-button-secondary-border-hover- shadow-xs shadow-shadow-shadow-3 !important;+ @apply h-8 w-8 p-2 hover:bg-gray-50 border border-gray-200 hover:border-gray-300 hover:shadow-[0_1px_2px_rgba(16,24,40,0.05)] !important;}.actionItem {@apply h-9 py-2 px-3 mx-1 flex items-center gap-2 hover:bg-gray-100 rounded-lg cursor-pointer;}.deleteActionItem {- @apply hover:bg-state-destructive-hover !important;+ @apply hover:bg-red-50 !important;}.actionName {- @apply text-text-secondary text-sm;+ @apply text-gray-700 text-sm;}.addFileBtn {@apply mt-4 w-fit !text-[13px] text-primary-600 font-medium bg-white border-[0.5px];@@ -90,8 +94,7 @@background-image: url(~@/assets/docx.svg);}.statusItemDetail {- @apply border-[0.5px] border-components-button-secondary-border inline-flex items-center- rounded-lg pl-2.5 pr-2 py-2 mr-2 shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px];+ @apply h-8 font-medium border border-gray-200 inline-flex items-center rounded-lg pl-3 pr-4 mr-2;}.tdValue {@apply text-sm overflow-hidden text-ellipsis whitespace-nowrap;diff --git a/web/app/components/datasets/formatted-text/flavours/edit-slice.tsx b/web/app/components/datasets/formatted-text/flavours/edit-slice.tsxdeleted file mode 100644index ca29c032e04..00000000000--- a/web/app/components/datasets/formatted-text/flavours/edit-slice.tsx+++ /dev/null@@ -1,115 +0,0 @@-import { useState } from 'react'-import type { FC, ReactNode } from 'react'-import { FloatingFocusManager, type OffsetOptions, autoUpdate, flip, offset, shift, useDismiss, useFloating, useHover, useInteractions, useRole } from '@floating-ui/react'-import { RiDeleteBinLine } from '@remixicon/react'-// @ts-expect-error no types available-import lineClamp from 'line-clamp'-import type { SliceProps } from './type'-import { SliceContainer, SliceContent, SliceDivider, SliceLabel } from './shared'-import classNames from '@/utils/classnames'-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'--type EditSliceProps = SliceProps<{- label: ReactNode- onDelete: () => void- labelClassName?: string- labelInnerClassName?: string- contentClassName?: string- showDivider?: boolean- offsetOptions?: OffsetOptions-}>--export const EditSlice: FC<EditSliceProps> = (props) => {- const {- label,- className,- text,- onDelete,- labelClassName,- labelInnerClassName,- contentClassName,- showDivider = true,- offsetOptions,- ...rest- } = props- const [delBtnShow, setDelBtnShow] = useState(false)- const [isDelBtnHover, setDelBtnHover] = useState(false)-- const { refs, floatingStyles, context } = useFloating({- open: delBtnShow,- onOpenChange: setDelBtnShow,- placement: 'right-start',- whileElementsMounted: autoUpdate,- middleware: [- flip(),- shift(),- offset(offsetOptions),- ],- })- const hover = useHover(context, {})- const dismiss = useDismiss(context)- const role = useRole(context)- const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss, role])-- const isDestructive = delBtnShow && isDelBtnHover-- return (- <>- <SliceContainer {...rest}- className={classNames('block mr-0', className)}- ref={(ref) => {- refs.setReference(ref)- if (ref)- lineClamp(ref, 4)- }}- {...getReferenceProps()}- >- <SliceLabel- className={classNames(- isDestructive && '!bg-state-destructive-solid !text-text-primary-on-surface',- labelClassName,- )}- labelInnerClassName={labelInnerClassName}- >- {label}- </SliceLabel>- <SliceContent- className={classNames(- isDestructive && '!bg-state-destructive-hover-alt',- contentClassName,- )}- >- {text}- </SliceContent>- {showDivider && <SliceDivider- className={classNames(- isDestructive && '!bg-state-destructive-hover-alt',- )}- />}- {delBtnShow && <FloatingFocusManager- context={context}- >- <span- ref={refs.setFloating}- style={floatingStyles}- {...getFloatingProps()}- className='p-1 rounded-lg bg-components-actionbar-bg shadow inline-flex items-center justify-center'- onMouseEnter={() => setDelBtnHover(true)}- onMouseLeave={() => setDelBtnHover(false)}- >- <ActionButton- onClick={(e) => {- e.stopPropagation()- onDelete()- setDelBtnShow(false)- }}- state={ActionButtonState.Destructive}- >- <RiDeleteBinLine className='w-4 h-4' />- </ActionButton>- </span>- </FloatingFocusManager>}- </SliceContainer>- </>- )-}diff --git a/web/app/components/datasets/formatted-text/flavours/preview-slice.tsx b/web/app/components/datasets/formatted-text/flavours/preview-slice.tsxdeleted file mode 100644index 662362cbf58..00000000000--- a/web/app/components/datasets/formatted-text/flavours/preview-slice.tsx+++ /dev/null@@ -1,56 +0,0 @@-import { useState } from 'react'-import type { FC, ReactNode } from 'react'-import { autoUpdate, flip, inline, shift, useDismiss, useFloating, useHover, useInteractions, useRole } from '@floating-ui/react'-import type { SliceProps } from './type'-import { SliceContainer, SliceContent, SliceDivider, SliceLabel } from './shared'--type PreviewSliceProps = SliceProps<{- label: ReactNode- tooltip: ReactNode- labelInnerClassName?: string- dividerClassName?: string-}>--export const PreviewSlice: FC<PreviewSliceProps> = (props) => {- const { label, className, text, tooltip, labelInnerClassName, dividerClassName, ...rest } = props- const [tooltipOpen, setTooltipOpen] = useState(false)- const { refs, floatingStyles, context } = useFloating({- open: tooltipOpen,- onOpenChange: setTooltipOpen,- whileElementsMounted: autoUpdate,- placement: 'top',- middleware: [- inline(),- flip(),- shift(),- ],- })- const hover = useHover(context, {- delay: { open: 500 },- move: true,- })- const dismiss = useDismiss(context)- const role = useRole(context, { role: 'tooltip' })- const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss, role])- return (- <>- <SliceContainer {...rest}- className={className}- ref={refs.setReference}- {...getReferenceProps()}- >- <SliceLabel labelInnerClassName={labelInnerClassName}>{label}</SliceLabel>- <SliceContent>{text}</SliceContent>- <SliceDivider className={dividerClassName} />- </SliceContainer>- {tooltipOpen && <span- ref={refs.setFloating}- style={floatingStyles}- {...getFloatingProps()}- className='p-2 rounded-md bg-components-tooltip-bg shadow shadow-shadow-shadow-5 backdrop-blur-[5px] text-text-secondary leading-4 border-[0.5px] border-components-panel-border text-xs'- >- {tooltip}- </span>}- </>- )-}diff --git a/web/app/components/datasets/formatted-text/flavours/shared.tsx b/web/app/components/datasets/formatted-text/flavours/shared.tsxdeleted file mode 100644index 577e3cedf47..00000000000--- a/web/app/components/datasets/formatted-text/flavours/shared.tsx+++ /dev/null@@ -1,60 +0,0 @@-import { type ComponentProps, type FC, forwardRef } from 'react'-import classNames from '@/utils/classnames'--const baseStyle = 'py-[3px]'--export type SliceContainerProps = ComponentProps<'span'>--export const SliceContainer: FC<SliceContainerProps> = forwardRef((props, ref) => {- const { className, ...rest } = props- return <span {...rest} ref={ref} className={classNames(- 'group align-bottom mr-1 select-none text-sm',- className,- )} />-})-SliceContainer.displayName = 'SliceContainer'--export type SliceLabelProps = ComponentProps<'span'> & { labelInnerClassName?: string }--export const SliceLabel: FC<SliceLabelProps> = forwardRef((props, ref) => {- const { className, children, labelInnerClassName, ...rest } = props- return <span {...rest} ref={ref} className={classNames(- baseStyle,- 'px-1 bg-state-base-hover-alt group-hover:bg-state-accent-solid group-hover:text-text-primary-on-surface uppercase text-text-tertiary',- className,- )}>- <span className={classNames('text-nowrap', labelInnerClassName)}>- {children}- </span>- </span>-})-SliceLabel.displayName = 'SliceLabel'--export type SliceContentProps = ComponentProps<'span'>--export const SliceContent: FC<SliceContentProps> = forwardRef((props, ref) => {- const { className, children, ...rest } = props- return <span {...rest} ref={ref} className={classNames(- baseStyle,- 'px-1 bg-state-base-hover group-hover:bg-state-accent-hover-alt group-hover:text-text-primary leading-7 whitespace-pre-line break-all',- className,- )}>- {children}- </span>-})-SliceContent.displayName = 'SliceContent'--export type SliceDividerProps = ComponentProps<'span'>--export const SliceDivider: FC<SliceDividerProps> = forwardRef((props, ref) => {- const { className, ...rest } = props- return <span {...rest} ref={ref} className={classNames(- baseStyle,- 'bg-state-base-active group-hover:bg-state-accent-solid text-sm px-[1px]',- className,- )}>- {/* use a zero-width space to make the hover area bigger */}- ​- </span>-})-SliceDivider.displayName = 'SliceDivider'diff --git a/web/app/components/datasets/formatted-text/flavours/type.ts b/web/app/components/datasets/formatted-text/flavours/type.tsdeleted file mode 100644index 8d2fb431f95..00000000000--- a/web/app/components/datasets/formatted-text/flavours/type.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { ComponentProps } from 'react'--export type SliceProps<T = {}> = T & {- text: string-} & ComponentProps<'span'>diff --git a/web/app/components/datasets/formatted-text/formatted.tsx b/web/app/components/datasets/formatted-text/formatted.tsxdeleted file mode 100644index 14d339e688c..00000000000--- a/web/app/components/datasets/formatted-text/formatted.tsx+++ /dev/null@@ -1,12 +0,0 @@-import type { ComponentProps, FC } from 'react'-import classNames from '@/utils/classnames'--export type FormattedTextProps = ComponentProps<'p'>--export const FormattedText: FC<FormattedTextProps> = (props) => {- const { className, ...rest } = props- return <p- {...rest}- className={classNames('leading-7', className)}- >{props.children}</p>-}diff --git a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx b/web/app/components/datasets/hit-testing/components/child-chunks-item.tsxdeleted file mode 100644index 043aa3cea7c..00000000000--- a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx+++ /dev/null@@ -1,30 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import { SliceContent } from '../../formatted-text/flavours/shared'-import Score from './score'-import type { HitTestingChildChunk } from '@/models/datasets'--type Props = {- payload: HitTestingChildChunk- isShowAll: boolean-}--const ChildChunks: FC<Props> = ({- payload,- isShowAll,-}) => {- const { id, score, content, position } = payload- return (- <div- className={!isShowAll ? 'line-clamp-2' : ''}- >- <div className='inline-flex items-center relative top-[-2px]'>- <div className='flex items-center h-[20.5px] bg-state-accent-solid system-2xs-semibold-uppercase text-text-primary-on-surface px-1'>C-{position}</div>- <Score value={score} besideChunkName />- </div>- <SliceContent className='py-0.5 bg-state-accent-hover group-hover:bg-state-accent-hover text-sm text-text-secondary font-normal'>{content}</SliceContent>- </div>- )-}-export default React.memo(ChildChunks)diff --git a/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx b/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsxdeleted file mode 100644index 8d49cef3d0e..00000000000--- a/web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx+++ /dev/null@@ -1,89 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import { useTranslation } from 'react-i18next'-import { SegmentIndexTag } from '../../documents/detail/completed/common/segment-index-tag'-import Dot from '../../documents/detail/completed/common/dot'-import Score from './score'-import ChildChunksItem from './child-chunks-item'-import Modal from '@/app/components/base/modal'-import type { HitTesting } from '@/models/datasets'-import FileIcon from '@/app/components/base/file-uploader/file-type-icon'-import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'-import cn from '@/utils/classnames'-import Tag from '@/app/components/datasets/documents/detail/completed/common/tag'--const i18nPrefix = 'datasetHitTesting'--type Props = {- payload: HitTesting- onHide: () => void-}--const ChunkDetailModal: FC<Props> = ({- payload,- onHide,-}) => {- const { t } = useTranslation()- const { segment, score, child_chunks } = payload- const { position, content, keywords, document } = segment- const isParentChildRetrieval = !!(child_chunks && child_chunks.length > 0)- const extension = document.name.split('.').slice(-1)[0] as FileAppearanceTypeEnum- const heighClassName = isParentChildRetrieval ? 'h-[min(627px,_80vh)] overflow-y-auto' : 'h-[min(539px,_80vh)] overflow-y-auto'- return (- <Modal- title={t(`${i18nPrefix}.chunkDetail`)}- isShow- closable- onClose={onHide}- className={cn(isParentChildRetrieval ? '!min-w-[1200px]' : '!min-w-[800px]')}- >- <div className='mt-4 flex'>- <div className={cn('flex-1', isParentChildRetrieval && 'pr-6')}>- {/* Meta info */}- <div className='flex justify-between items-center'>- <div className='grow flex items-center space-x-2'>- <SegmentIndexTag- labelPrefix={`${isParentChildRetrieval ? 'Parent-' : ''}Chunk`}- positionId={position}- className={cn('w-fit group-hover:opacity-100')}- />- <Dot />- <div className='grow flex items-center space-x-1'>- <FileIcon type={extension} size='sm' />- <span className='grow w-0 truncate text-text-secondary text-[13px] font-normal'>{document.name}</span>- </div>- </div>- <Score value={score} />- </div>- <div className={cn('mt-2 body-md-regular text-text-secondary', heighClassName)}>- {content}- </div>- {!isParentChildRetrieval && keywords && keywords.length > 0 && (- <div className='mt-6'>- <div className='font-medium text-xs text-text-tertiary uppercase'>{t(`${i18nPrefix}.keyword`)}</div>- <div className='mt-1 flex flex-wrap'>- {keywords.map(keyword => (- <Tag key={keyword} text={keyword} className='mr-2' />- ))}- </div>- </div>- )}- </div>-- {isParentChildRetrieval && (- <div className='flex-1 pl-6 pb-6'>- <div className='system-xs-semibold-uppercase text-text-secondary'>{t(`${i18nPrefix}.hitChunks`, { num: child_chunks.length })}</div>- <div className={cn('mt-1 space-y-2', heighClassName)}>- {child_chunks.map(item => (- <ChildChunksItem key={item.id} payload={item} isShowAll />- ))}- </div>- </div>- )}- </div>- </Modal>- )-}--export default React.memo(ChunkDetailModal)diff --git a/web/app/components/datasets/hit-testing/components/result-item.tsx b/web/app/components/datasets/hit-testing/components/result-item.tsxdeleted file mode 100644index 36ee541161c..00000000000--- a/web/app/components/datasets/hit-testing/components/result-item.tsx+++ /dev/null@@ -1,121 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import { useTranslation } from 'react-i18next'-import { RiArrowDownSLine, RiArrowRightSLine, RiArrowRightUpLine } from '@remixicon/react'-import { useBoolean } from 'ahooks'-import { SegmentIndexTag } from '../../documents/detail/completed/common/segment-index-tag'-import Dot from '../../documents/detail/completed/common/dot'-import Score from './score'-import ChildChunkItem from './child-chunks-item'-import ChunkDetailModal from './chunk-detail-modal'-import type { HitTesting } from '@/models/datasets'-import cn from '@/utils/classnames'-import FileIcon from '@/app/components/base/file-uploader/file-type-icon'-import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'-import Tag from '@/app/components/datasets/documents/detail/completed/common/tag'-import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'--const i18nPrefix = 'datasetHitTesting'-type Props = {- isExternal: boolean- payload: HitTesting-}--const ResultItem: FC<Props> = ({- isExternal,- payload,-}) => {- const { t } = useTranslation()- const { segment, content: externalContent, score, child_chunks } = payload- const data = isExternal ? externalContent : segment- const { position, word_count, content, keywords, document } = data- const isParentChildRetrieval = !!(child_chunks && child_chunks.length > 0)- const extension = document.name.split('.').slice(-1)[0] as FileAppearanceTypeEnum- const fileType = extensionToFileType(extension)- const [isFold, {- toggle: toggleFold,- }] = useBoolean(false)- const Icon = isFold ? RiArrowRightSLine : RiArrowDownSLine-- const [isShowDetailModal, {- setTrue: showDetailModal,- setFalse: hideDetailModal,- }] = useBoolean(false)-- const handleClickCard = () => {- if (!isParentChildRetrieval)- showDetailModal()- }-- return (- <div className={cn('pt-3 bg-chat-bubble-bg rounded-xl hover:shadow-lg', !isParentChildRetrieval && 'cursor-pointer')} onClick={handleClickCard}>- {/* Meta info */}- <div className='flex justify-between items-center px-3'>- <div className='flex items-center space-x-2'>- <SegmentIndexTag- labelPrefix={`${isParentChildRetrieval ? 'Parent-' : ''}Chunk`}- positionId={position}- className={cn('w-fit group-hover:opacity-100')}- />- <Dot />- <div className='system-xs-medium text-text-tertiary'>{word_count} {t('datasetDocuments.segment.characters', { count: word_count })}</div>- </div>- <Score value={score} />- </div>-- {/* Main */}- <div className='mt-1 px-3'>- <div className='line-clamp-2 body-md-regular'>{content}</div>- {isParentChildRetrieval && (- <div className='mt-1'>- <div className={cn('inline-flex items-center h-6 space-x-0.5 text-text-secondary select-none rounded-lg cursor-pointer', isFold && 'pl-1 bg-[linear-gradient(90deg,_rgba(200,_206,_218,_0.20)_0%,_rgba(200,_206,_218,_0.04)_100%)]')} onClick={toggleFold}>- <Icon className={cn('w-4 h-4', isFold && 'opacity-50')} />- <div className='text-xs font-semibold uppercase'>{t(`${i18nPrefix}.hitChunks`, { num: child_chunks.length })}</div>- </div>- {!isFold && (- <div className='space-y-2'>- {child_chunks.map(item => (- <div key={item.id} className='ml-[7px] pl-[7px] border-l-[2px] border-text-accent-secondary'>- <ChildChunkItem payload={item} isShowAll={false} />- </div>- ))}- </div>- )}- </div>- )}- {!isParentChildRetrieval && keywords && keywords.length > 0 && (- <div className='mt-2 flex flex-wrap'>- {keywords.map(keyword => (- <Tag key={keyword} text={keyword} className='mr-2' />- ))}- </div>- )}- </div>- {/* Foot */}- <div className='mt-3 flex justify-between items-center h-10 pl-3 pr-2 border-t border-divider-subtle'>- <div className='grow flex items-center space-x-1'>- <FileIcon type={fileType} size='sm' />- <span className='grow w-0 truncate text-text-secondary text-[13px] font-normal'>{document.name}</span>- </div>- <div- className='flex items-center space-x-1 cursor-pointer text-text-tertiary'- onClick={showDetailModal}- >- <div className='text-xs uppercase'>{t(`${i18nPrefix}.open`)}</div>- <RiArrowRightUpLine className='size-3.5' />- </div>- </div>-- {- isShowDetailModal && (- <ChunkDetailModal- payload={payload}- onHide={hideDetailModal}- />- )- }- </div >- )-}-export default React.memo(ResultItem)diff --git a/web/app/components/datasets/hit-testing/components/score.tsx b/web/app/components/datasets/hit-testing/components/score.tsxdeleted file mode 100644index 115141eaaa0..00000000000--- a/web/app/components/datasets/hit-testing/components/score.tsx+++ /dev/null@@ -1,25 +0,0 @@-'use client'-import type { FC } from 'react'-import React from 'react'-import cn from '@/utils/classnames'--type Props = {- value: number- besideChunkName?: boolean-}--const Score: FC<Props> = ({- value,- besideChunkName,-}) => {- return (- <div className={cn('relative items-center px-[5px] border border-components-progress-bar-border overflow-hidden', besideChunkName ? 'border-l-0 h-[20.5px]' : 'h-[20px] rounded-md')}>- <div className={cn('absolute top-0 left-0 h-full bg-util-colors-blue-brand-blue-brand-100 border-r-[1.5px] border-components-progress-brand-progress', value === 1 && 'border-r-0')} style={{ width: `${value * 100}%` }} />- <div className={cn('relative flex items-center h-full space-x-0.5 text-util-colors-blue-brand-blue-brand-700')}>- <div className='system-2xs-medium-uppercase'>score</div>- <div className='system-xs-semibold'>{value.toFixed(2)}</div>- </div>- </div>- )-}-export default React.memo(Score)diff --git a/web/app/components/datasets/hit-testing/hit-detail.tsx b/web/app/components/datasets/hit-testing/hit-detail.tsxnew file mode 100644index 00000000000..066e2238c8a--- /dev/null+++ b/web/app/components/datasets/hit-testing/hit-detail.tsx@@ -0,0 +1,68 @@+import type { FC } from 'react'+import React from 'react'+import { useTranslation } from 'react-i18next'+import { SegmentIndexTag } from '../documents/detail/completed'+import s from '../documents/detail/completed/style.module.css'+import cn from '@/utils/classnames'+import type { SegmentDetailModel } from '@/models/datasets'+import Divider from '@/app/components/base/divider'++type IHitDetailProps = {+ segInfo?: Partial<SegmentDetailModel> & { id: string }+}++const HitDetail: FC<IHitDetailProps> = ({ segInfo }) => {+ const { t } = useTranslation()++ const renderContent = () => {+ if (segInfo?.answer) {+ return (+ <>+ <div className='mt-2 mb-1 text-xs font-medium text-gray-500'>QUESTION</div>+ <div className='mb-4 text-md text-gray-800'>{segInfo.content}</div>+ <div className='mb-1 text-xs font-medium text-gray-500'>ANSWER</div>+ <div className='text-md text-gray-800'>{segInfo.answer}</div>+ </>+ )+ }++ return <div className='mb-4 text-md text-gray-800 h-full'>{segInfo?.content}</div>+ }++ return (+ segInfo?.id === 'external'+ ? <div className='w-full overflow-x-auto px-2'>+ <div className={s.segModalContent}>{renderContent()}</div>+ </div>+ : <div className='overflow-x-auto'>+ <div className="flex items-center">+ <SegmentIndexTag+ positionId={segInfo?.position || ''}+ className="w-fit mr-6"+ />+ <div className={cn(s.commonIcon, s.typeSquareIcon)} />+ <span className={cn('mr-6', s.numberInfo)}>+ {segInfo?.word_count} {t('datasetDocuments.segment.characters')}+ </span>+ <div className={cn(s.commonIcon, s.targetIcon)} />+ <span className={s.numberInfo}>+ {segInfo?.hit_count} {t('datasetDocuments.segment.hitCount')}+ </span>+ </div>+ <Divider />+ <div className={s.segModalContent}>{renderContent()}</div>+ <div className={s.keywordTitle}>+ {t('datasetDocuments.segment.keywords')}+ </div>+ <div className={s.keywordWrapper}>+ {!segInfo?.keywords?.length+ ? '-'+ : segInfo?.keywords?.map((word, index) => {+ return <div key={index} className={s.keyword}>{word}</div>+ })}+ </div>+ </div>+ )+}++export default HitDetaildiff --git a/web/app/components/datasets/hit-testing/index.tsx b/web/app/components/datasets/hit-testing/index.tsxindex 30be6fb7e71..ce47f2bfa6c 100644--- a/web/app/components/datasets/hit-testing/index.tsx+++ b/web/app/components/datasets/hit-testing/index.tsx@@ -6,15 +6,16 @@ import useSWR from 'swr'import { omit } from 'lodash-es'import { useBoolean } from 'ahooks'import { useContext } from 'use-context-selector'-import { RiApps2Line, RiFocus2Line } from '@remixicon/react'import SegmentCard from '../documents/detail/completed/SegmentCard'+import docStyle from '../documents/detail/completed/style.module.css'import Textarea from './textarea'import s from './style.module.css'+import HitDetail from './hit-detail'import ModifyRetrievalModal from './modify-retrieval-modal'-import ResultItem from './components/result-item'import cn from '@/utils/classnames'-import type { ExternalKnowledgeBaseHitTestingResponse, HitTestingResponse } from '@/models/datasets'+import type { ExternalKnowledgeBaseHitTestingResponse, ExternalKnowledgeBaseHitTesting as ExternalKnowledgeBaseHitTestingType, HitTestingResponse, HitTesting as HitTestingType } from '@/models/datasets'import Loading from '@/app/components/base/loading'+import Modal from '@/app/components/base/modal'import Drawer from '@/app/components/base/drawer'import Pagination from '@/app/components/base/pagination'import FloatRightContainer from '@/app/components/base/float-right-container'@@ -23,7 +24,6 @@ import DatasetDetailContext from '@/context/dataset-detail'import type { RetrievalConfig } from '@/types/app'import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'import useTimestamp from '@/hooks/use-timestamp'-import docStyle from '@/app/components/datasets/documents/detail/completed/style.module.css'const limit = 10@@ -51,6 +51,8 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {const [hitResult, setHitResult] = useState<HitTestingResponse | undefined>() // 初始化记录为空数组const [externalHitResult, setExternalHitResult] = useState<ExternalKnowledgeBaseHitTestingResponse | undefined>()const [submitLoading, setSubmitLoading] = useState(false)+ const [currParagraph, setCurrParagraph] = useState<{ paraInfo?: HitTestingType; showModal: boolean }>({ showModal: false })+ const [externalCurrParagraph, setExternalCurrParagraph] = useState<{ paraInfo?: ExternalKnowledgeBaseHitTestingType; showModal: boolean }>({ showModal: false })const [text, setText] = useState('')const [currPage, setCurrPage] = React.useState<number>(0)@@ -62,33 +64,51 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {const total = recordsRes?.total || 0+ const onClickCard = (detail: HitTestingType) => {+ setCurrParagraph({ paraInfo: detail, showModal: true })+ }++ const onClickExternalCard = (detail: ExternalKnowledgeBaseHitTestingType) => {+ setExternalCurrParagraph({ paraInfo: detail, showModal: true })+ }const { dataset: currentDataset } = useContext(DatasetDetailContext)const isExternal = currentDataset?.provider === 'external'const [retrievalConfig, setRetrievalConfig] = useState(currentDataset?.retrieval_model_dict as RetrievalConfig)const [isShowModifyRetrievalModal, setIsShowModifyRetrievalModal] = useState(false)const [isShowRightPanel, { setTrue: showRightPanel, setFalse: hideRightPanel, set: setShowRightPanel }] = useBoolean(!isMobile)- const renderHitResults = (results: any[]) => (- <div className='h-full flex flex-col py-3 px-4 rounded-t-2xl bg-background-body'>- <div className='shrink-0 pl-2 text-text-primary font-semibold leading-6 mb-2'>- {t('datasetHitTesting.hit.title', { num: results.length })}- </div>- <div className='grow overflow-y-auto space-y-2'>- {results.map((record, idx) => (- <ResultItem- key={idx}- payload={record}- isExternal={isExternal}- />- ))}++ const renderHitResults = (results: any[], onClickCard: (record: any) => void) => (+ <>+ <div className='text-gray-600 font-semibold mb-4'>{t('datasetHitTesting.hit.title')}</div>+ <div className='overflow-auto flex-1'>+ <div className={s.cardWrapper}>+ {results.map((record, idx) => (+ <SegmentCard+ key={idx}+ loading={false}+ refSource= {{+ title: record.title,+ uri: record.metadata ? record.metadata['x-amz-bedrock-kb-source-uri'] : '',+ }}+ isExternal={isExternal}+ detail={record.segment}+ contentExternal={record.content}+ score={record.score}+ scene='hitTesting'+ className='h-[216px] mb-4'+ onClick={() => onClickCard(record)}+ />+ ))}+ </div></div>- </div>+ </>)const renderEmptyState = () => (- <div className='h-full flex flex-col justify-center items-center py-3 px-4 rounded-t-2xl bg-background-body'>- <div className={cn(docStyle.commonIcon, docStyle.targetIcon, '!bg-text-quaternary !h-14 !w-14')} />- <div className='text-text-quaternary text-[13px] mt-3'>+ <div className='h-full flex flex-col justify-center items-center'>+ <div className={cn(docStyle.commonIcon, docStyle.targetIcon, '!bg-gray-200 !h-14 !w-14')} />+ <div className='text-gray-300 text-[13px] mt-3'>{t('datasetHitTesting.hit.emptyTip')}</div></div>@@ -100,10 +120,10 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {return (<div className={s.container}>- <div className='px-6 py-3 flex flex-col'>- <div className='flex flex-col justify-center mb-4'>- <h1 className='text-base font-semibold text-text-primary'>{t('datasetHitTesting.title')}</h1>- <p className='mt-0.5 text-[13px] leading-4 font-normal text-text-tertiary'>{t('datasetHitTesting.desc')}</p>+ <div className={s.leftDiv}>+ <div className={s.titleWrapper}>+ <h1 className={s.title}>{t('datasetHitTesting.title')}</h1>+ <p className={s.desc}>{t('datasetHitTesting.desc')}</p></div><TextareadatasetId={datasetId}@@ -120,7 +140,7 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {retrievalConfig={retrievalConfig}isEconomy={currentDataset?.indexing_technique === 'economy'}/>- <div className='text-base font-semibold text-text-primary mt-6 mb-3'>{t('datasetHitTesting.records')}</div>+ <div className={cn(s.title, 'mt-8 mb-2')}>{t('datasetHitTesting.recents')}</div>{(!recordsRes && !error)? (<div className='flex-1'><Loading type='app' /></div>@@ -129,30 +149,29 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {? (<><div className='grow overflow-y-auto'>- <table className={'w-full border-collapse border-0 text-[13px] leading-4 text-text-secondary '}>- <thead className="sticky top-0 h-7 leading-7 text-xs text-text-tertiary font-medium uppercase">+ <table className={`w-full border-collapse border-0 mt-3 ${s.table}`}>+ <thead className="sticky top-0 h-8 bg-white leading-8 border-b border-gray-200 text-gray-500 font-bold"><tr>- <td className='pl-3 w-[128px] rounded-l-lg bg-background-section-burn'>{t('datasetHitTesting.table.header.source')}</td>- <td className='bg-background-section-burn'>{t('datasetHitTesting.table.header.text')}</td>- <td className='pl-2 w-48 rounded-r-lg bg-background-section-burn'>{t('datasetHitTesting.table.header.time')}</td>+ <td className='w-28'>{t('datasetHitTesting.table.header.source')}</td>+ <td>{t('datasetHitTesting.table.header.text')}</td>+ <td className='w-48'>{t('datasetHitTesting.table.header.time')}</td></tr></thead>- <tbody>+ <tbody className="text-gray-500">{recordsRes?.data?.map((record) => {- const SourceIcon = record.source === 'app' ? RiApps2Line : RiFocus2Linereturn <trkey={record.id}- className='group border-b border-divider-subtle h-10 hover:bg-background-default-hover cursor-pointer'+ className='group border-b border-gray-200 h-8 hover:bg-gray-50 cursor-pointer'onClick={() => setText(record.content)}>- <td className='pl-3 w-[128px]'>+ <td className='w-24'><div className='flex items-center'>- <SourceIcon className='mr-1 size-4 text-text-tertiary' />- <span className='capitalize'>{record.source.replace('_', ' ').replace('hit testing', 'retrieval test')}</span>+ <div className={cn(s[`${record.source}_icon`], s.commonIcon, 'mr-1')} />+ <span className='capitalize'>{record.source.replace('_', ' ')}</span></div></td>- <td className='max-w-xs py-2'>{record.content}</td>- <td className='pl-2 w-36'>+ <td className='max-w-xs group-hover:text-primary-600'>{record.content}</td>+ <td className='w-36'>{formatTime(record.created_at, t('datasetHitTesting.dateTimeFormat') as string)}</td></tr>@@ -170,28 +189,57 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {)}</div><FloatRightContainer panelClassname='!justify-start !overflow-y-auto' showClose isMobile={isMobile} isOpen={isShowRightPanel} onClose={hideRightPanel} footer={null}>- <div className='flex flex-col pt-3'>- {/* {renderHitResults(generalResultData)} */}+ <div className={cn(s.rightDiv, 'p-0 sm:px-8 sm:pt-[42px] sm:pb-[26px]')}>{submitLoading- ? <SegmentCard- loading={true}- scene='hitTesting'- className='h-[216px]'- />+ ? <div className={s.cardWrapper}>+ <SegmentCard+ loading={true}+ scene='hitTesting'+ className='h-[216px]'+ />+ <SegmentCard+ loading={true}+ scene='hitTesting'+ className='h-[216px]'+ />+ </div>: ((() => {if (!hitResult?.records.length && !externalHitResult?.records.length)return renderEmptyState()if (hitResult?.records.length)- return renderHitResults(hitResult.records)+ return renderHitResults(hitResult.records, onClickCard)- return renderHitResults(externalHitResult?.records || [])+ return renderHitResults(externalHitResult?.records || [], onClickExternalCard)})())}</div></FloatRightContainer>+ <Modal+ className={isExternal ? 'py-10 px-8' : 'w-full'}+ closable+ onClose={() => {+ setCurrParagraph({ showModal: false })+ setExternalCurrParagraph({ showModal: false })+ }}+ isShow={currParagraph.showModal || externalCurrParagraph.showModal}+ >+ {currParagraph.showModal && (+ <HitDetail+ segInfo={currParagraph.paraInfo?.segment}+ />+ )}+ {externalCurrParagraph.showModal && (+ <HitDetail+ segInfo={{+ id: 'external',+ content: externalCurrParagraph.paraInfo?.content,+ }}+ />+ )}+ </Modal><Drawer isOpen={isShowModifyRetrievalModal} onClose={() => setIsShowModifyRetrievalModal(false)} footer={null} mask={isMobile} panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[640px] rounded-xl'><ModifyRetrievalModalindexMethod={currentDataset?.indexing_technique || ''}diff --git a/web/app/components/datasets/hit-testing/modify-retrieval-modal.tsx b/web/app/components/datasets/hit-testing/modify-retrieval-modal.tsxindex 2790ea4d8b9..1fc5b68d671 100644--- a/web/app/components/datasets/hit-testing/modify-retrieval-modal.tsx+++ b/web/app/components/datasets/hit-testing/modify-retrieval-modal.tsx@@ -11,7 +11,6 @@ import EconomicalRetrievalMethodConfig from '@/app/components/datasets/common/ecimport Button from '@/app/components/base/button'import { ensureRerankModelSelected, isReRankModelSelected } from '@/app/components/datasets/common/check-rerank-model'import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'-import { RerankingModeEnum } from '@/models/datasets'type Props = {indexMethod: string@@ -58,10 +57,7 @@ const ModifyRetrievalModal: FC<Props> = ({}onSave(ensureRerankModelSelected({rerankDefaultModel: rerankDefaultModel!,- retrievalConfig: {- ...retrievalConfig,- reranking_enable: retrievalConfig.reranking_mode === RerankingModeEnum.RerankingModel,- },+ retrievalConfig,indexMethod,}))}@@ -81,7 +77,7 @@ const ModifyRetrievalModal: FC<Props> = ({<div className='text-base font-semibold text-gray-900'><div>{t('datasetSettings.form.retrievalSetting.title')}</div><div className='leading-[18px] text-xs font-normal text-gray-500'>- <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-text-accent'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>+ <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-[#155eef]'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>{t('datasetSettings.form.retrievalSetting.description')}</div></div>diff --git a/web/app/components/datasets/hit-testing/style.module.css b/web/app/components/datasets/hit-testing/style.module.cssindex cf8536f998d..1e90902a707 100644--- a/web/app/components/datasets/hit-testing/style.module.css+++ b/web/app/components/datasets/hit-testing/style.module.css@@ -1,43 +1,61 @@.container {@apply flex h-full w-full relative overflow-y-auto;}--.container>div {+.container > div {@apply flex-1 h-full;}-+.leftDiv {+ @apply border-r border-gray-100 px-6 py-3 flex flex-col;+}+.rightDiv {+ @apply flex flex-col;+}+.titleWrapper {+ @apply flex flex-col justify-center gap-1 mb-5;+}+.title {+ @apply text-xl font-medium text-gray-900;+}+.desc {+ @apply text-sm font-normal text-gray-500;+}+.table {+ @apply text-[13px] text-gray-500;+}+.table td {+ @apply whitespace-nowrap overflow-hidden text-ellipsis;+}.commonIcon {@apply w-3.5 h-3.5 inline-block align-middle;background-repeat: no-repeat;background-position: center center;background-size: contain;}-.app_icon {background-image: url(./assets/grid.svg);}-.hit_testing_icon {background-image: url(../documents/assets/target.svg);}-.plugin_icon {background-image: url(./assets/plugin.svg);}+.wrapper {+ @apply relative border border-primary-600 rounded-xl;+}+.cardWrapper {display: grid;grid-template-columns: repeat(auto-fill, minmax(284px, auto));grid-gap: 16px;grid-auto-rows: 216px;}-.clockWrapper {border: 0.5px solid #eaecf5;@apply rounded-lg w-11 h-11 flex justify-center items-center;}-.clockIcon {mask-image: url(./assets/clock.svg);@apply bg-gray-500;-}\ No newline at end of file+}diff --git a/web/app/components/datasets/hit-testing/textarea.tsx b/web/app/components/datasets/hit-testing/textarea.tsxindex fcd72a2f1ba..9589a2e8358 100644--- a/web/app/components/datasets/hit-testing/textarea.tsx+++ b/web/app/components/datasets/hit-testing/textarea.tsx@@ -3,9 +3,10 @@ import { useTranslation } from 'react-i18next'import {RiEqualizer2Line,} from '@remixicon/react'-import Image from 'next/image'import Button from '../../base/button'+import Tag from '../../base/tag'import { getIcon } from '../common/retrieval-method-info'+import s from './style.module.css'import ModifyExternalRetrievalModal from './modify-external-retrieval-modal'import Tooltip from '@/app/components/base/tooltip'import cn from '@/utils/classnames'@@ -13,7 +14,6 @@ import type { ExternalKnowledgeBaseHitTestingResponse, HitTestingResponse } fromimport { externalKnowledgeBaseHitTesting, hitTesting } from '@/service/datasets'import { asyncRunSafe } from '@/utils'import { RETRIEVE_METHOD, type RetrievalConfig } from '@/types/app'-import promptS from '@/app/components/app/configuration/config-prompt/style.module.css'type TextAreaWithButtonIProps = {datasetId: string@@ -103,13 +103,13 @@ const TextAreaWithButton = ({}const retrievalMethod = isEconomy ? RETRIEVE_METHOD.invertedIndex : retrievalConfig.search_method- const icon = <Image className='size-3.5 text-util-colors-purple-purple-600' src={getIcon(retrievalMethod)} alt='' />+ const Icon = getIcon(retrievalMethod)return (<>- <div className={cn('relative rounded-xl', promptS.gradientBorder)}>- <div className='relative pt-1.5 rounded-tl-xl rounded-tr-xl bg-background-section-burn'>- <div className="pl-4 pr-1.5 pb-1 flex justify-between h-8 items-center">- <span className="text-text-secondary font-semibold text-[13px] leading-4 uppercase">+ <div className={s.wrapper}>+ <div className='relative pt-2 rounded-tl-xl rounded-tr-xl bg-[#EEF4FF]'>+ <div className="px-4 pb-2 flex justify-between h-8 items-center">+ <span className="text-gray-800 font-semibold text-sm">{t('datasetHitTesting.input.title')}</span>{isExternal@@ -123,14 +123,17 @@ const TextAreaWithButton = ({<span className='text-components-button-secondary-text system-xs-medium'>{t('datasetHitTesting.settingTitle')}</span></div></Button>- : <div- onClick={onClickRetrievalMethod}- className='flex px-1.5 h-7 items-center bg-components-button-secondary-bg hover:bg-components-button-secondary-bg-hover rounded-lg border-[0.5px] border-components-button-secondary-bg shadow-xs backdrop-blur-[5px] cursor-pointer space-x-0.5'+ : <Tooltip+ popupContent={t('dataset.retrieval.changeRetrievalMethod')}>- {icon}- <div className='text-text-secondary text-xs font-medium uppercase'>{t(`dataset.retrieval.${retrievalMethod}.title`)}</div>- <RiEqualizer2Line className='size-4 text-components-menu-item-text'></RiEqualizer2Line>- </div>+ <div+ onClick={onClickRetrievalMethod}+ className='flex px-2 h-7 items-center space-x-1 bg-white hover:bg-[#ECE9FE] rounded-md shadow-sm cursor-pointer text-[#6927DA]'+ >+ <Icon className='w-3.5 h-3.5'></Icon>+ <div className='text-xs font-medium'>{t(`dataset.retrieval.${retrievalMethod}.title`)}</div>+ </div>+ </Tooltip>}</div>{@@ -144,11 +147,11 @@ const TextAreaWithButton = ({/>)}- <div className='h-2 rounded-tl-xl rounded-tr-xl bg-background-default'></div>+ <div className='h-2 rounded-tl-xl rounded-tr-xl bg-white'></div></div>- <div className='px-4 pb-11 bg-background-default rounded-b-xl'>+ <div className='px-4 pb-11'><textarea- className='h-[220px] border-none resize-none font-normal caret-primary-600 text-text-secondary text-sm w-full focus-visible:outline-none placeholder:text-gray-300 placeholder:text-sm placeholder:font-normal'+ className='h-[220px] border-none resize-none font-normal caret-primary-600 text-gray-700 text-sm w-full focus-visible:outline-none placeholder:text-gray-300 placeholder:text-sm placeholder:font-normal'value={text}onChange={handleTextChange}placeholder={t('datasetHitTesting.input.placeholder') as string}@@ -159,23 +162,24 @@ const TextAreaWithButton = ({<TooltippopupContent={t('datasetHitTesting.input.countWarning')}>- <div- className={cn('flex items-center h-5 px-1 rounded-md bg-background-section-burn text-red-600 text-xs font-medium', !text?.length && 'opacity-50')}- >- {text?.length}- <span className="text-red-300 mx-0.5">/</span>- 200+ <div>+ <Tag color="red" className="!text-red-600">+ {text?.length}+ <span className="text-red-300 mx-0.5">/</span>+ 200+ </Tag></div></Tooltip>): (- <div- className={cn('flex items-center h-5 px-1 rounded-md bg-background-section-burn text-text-tertiary text-xs font-medium', !text?.length && 'opacity-50')}+ <Tag+ color="gray"+ className={cn('!text-gray-500', text?.length ? '' : 'opacity-50')}>{text?.length}- <span className="text-divider-deep mx-0.5">/</span>+ <span className="text-gray-300 mx-0.5">/</span>200- </div>+ </Tag>)}<div>@@ -184,7 +188,6 @@ const TextAreaWithButton = ({variant="primary"loading={loading}disabled={(!text?.length || text?.length > 200)}- className='w-[88px]'>{t('datasetHitTesting.input.testing')}</Button>diff --git a/web/app/components/datasets/hit-testing/utils/extension-to-file-type.ts b/web/app/components/datasets/hit-testing/utils/extension-to-file-type.tsdeleted file mode 100644index 68db7421995..00000000000--- a/web/app/components/datasets/hit-testing/utils/extension-to-file-type.ts+++ /dev/null@@ -1,31 +0,0 @@-import { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'--export const extensionToFileType = (extension: string): FileAppearanceTypeEnum => {- switch (extension) {- case 'pdf':- return FileAppearanceTypeEnum.pdf- case 'doc':- case 'docx':- return FileAppearanceTypeEnum.word- case 'txt':- case 'epub':- return FileAppearanceTypeEnum.document- case 'md':- case 'mdx':- case 'markdown':- return FileAppearanceTypeEnum.markdown- case 'csv':- case 'xls':- case 'xlsx':- return FileAppearanceTypeEnum.excel- case 'html':- case 'htm':- case 'xml':- return FileAppearanceTypeEnum.document- case 'ppt':- case 'pptx':- return FileAppearanceTypeEnum.ppt- default:- return FileAppearanceTypeEnum.custom- }-}diff --git a/web/app/components/datasets/loading.tsx b/web/app/components/datasets/loading.tsxdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/web/app/components/datasets/preview/container.tsx b/web/app/components/datasets/preview/container.tsxdeleted file mode 100644index e59fc8dbac5..00000000000--- a/web/app/components/datasets/preview/container.tsx+++ /dev/null@@ -1,29 +0,0 @@-import type { ComponentProps, FC, ReactNode } from 'react'-import { forwardRef } from 'react'-import classNames from '@/utils/classnames'--export type PreviewContainerProps = ComponentProps<'div'> & {- header: ReactNode- mainClassName?: string-}--export const PreviewContainer: FC<PreviewContainerProps> = forwardRef((props, ref) => {- const { children, className, header, mainClassName, ...rest } = props- return <div className={className}>- <div- {...rest}- ref={ref}- className={classNames(- 'flex flex-col w-full h-full overflow-y-auto rounded-l-xl border-t-[0.5px] border-l-[0.5px] border-components-panel-border bg-background-default-lighter shadow shadow-shadow-shadow-5',- )}- >- <header className='pl-5 pt-4 pr-4 pb-3 border-b border-divider-subtle'>- {header}- </header>- <main className={classNames('py-5 px-6 w-full h-full', mainClassName)}>- {children}- </main>- </div>- </div>-})-PreviewContainer.displayName = 'PreviewContainer'diff --git a/web/app/components/datasets/preview/header.tsx b/web/app/components/datasets/preview/header.tsxdeleted file mode 100644index ccb7cf8e2f8..00000000000--- a/web/app/components/datasets/preview/header.tsx+++ /dev/null@@ -1,23 +0,0 @@-import type { ComponentProps, FC } from 'react'-import classNames from '@/utils/classnames'--export type PreviewHeaderProps = Omit<ComponentProps<'div'>, 'title'> & {- title: string-}--export const PreviewHeader: FC<PreviewHeaderProps> = (props) => {- const { title, className, children, ...rest } = props- return <div- {...rest}- className={classNames(- className,- )}- >- <div- className='text-text-accent system-2xs-semibold-uppercase uppercase px-1 mb-1'- >- {title}- </div>- {children}- </div>-}diff --git a/web/app/components/datasets/preview/index.tsx b/web/app/components/datasets/preview/index.tsxdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsxindex 5f6fc00eb7e..b93ebd01155 100644--- a/web/app/components/datasets/settings/form/index.tsx+++ b/web/app/components/datasets/settings/form/index.tsx@@ -8,16 +8,16 @@ import { unstable_serialize } from 'swr/infinite'import PermissionSelector from '../permission-selector'import IndexMethodRadio from '../index-method-radio'import RetrievalSettings from '../../external-knowledge-base/create/RetrievalSettings'-import { IndexingType } from '../../create/step-two'import RetrievalMethodConfig from '@/app/components/datasets/common/retrieval-method-config'import EconomicalRetrievalMethodConfig from '@/app/components/datasets/common/economical-retrieval-method-config'import { ToastContext } from '@/app/components/base/toast'import Button from '@/app/components/base/button'import Input from '@/app/components/base/input'import Textarea from '@/app/components/base/textarea'+import Divider from '@/app/components/base/divider'import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development'import { updateDatasetSetting } from '@/service/datasets'-import { type DataSetListResponse, RerankingModeEnum } from '@/models/datasets'+import type { DataSetListResponse } from '@/models/datasets'import DatasetDetailContext from '@/context/dataset-detail'import { type RetrievalConfig } from '@/types/app'import { useAppContext } from '@/context/app-context'@@ -31,11 +31,12 @@ import type { DefaultModel } from '@/app/components/header/account-setting/modelimport { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { fetchMembers } from '@/service/common'import type { Member } from '@/models/common'-import AlertTriangle from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback/AlertTriangle'-const rowClass = 'flex'+const rowClass = `+ flex justify-between py-4 flex-wrap gap-y-2+`const labelClass = `- flex items-center shrink-0 w-[180px] h-9+ flex items-center w-[168px] h-9`const getKey = (pageIndex: number, previousPageData: DataSetListResponse) => {@@ -121,10 +122,7 @@ const Form = () => {}const postRetrievalConfig = ensureRerankModelSelected({rerankDefaultModel: rerankDefaultModel!,- retrievalConfig: {- ...retrievalConfig,- reranking_enable: retrievalConfig.reranking_mode === RerankingModeEnum.RerankingModel,- },+ retrievalConfig,indexMethod,})if (postRetrievalConfig.weights) {@@ -181,12 +179,12 @@ const Form = () => {}return (- <div className='w-full sm:w-[880px] px-14 py-8 flex flex-col gap-y-4'>+ <div className='w-full sm:w-[800px] p-4 sm:px-16 sm:py-6'><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.name')}</div></div>- <div className='grow'>+ <div className='w-full max-w-[480px]'><Inputdisabled={!currentDataset?.embedding_available}className='h-9'@@ -199,10 +197,10 @@ const Form = () => {<div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.desc')}</div></div>- <div className='grow'>+ <div className='w-full max-w-[480px]'><Textareadisabled={!currentDataset?.embedding_available}- className='h-[120px] resize-none'+ className='mb-2 h-[120px] resize-none'placeholder={t('datasetSettings.form.descPlaceholder') || ''}value={description}onChange={e => setDescription(e.target.value)}@@ -213,7 +211,7 @@ const Form = () => {<div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.permissions')}</div></div>- <div className='grow'>+ <div className='w-full sm:w-[480px]'><PermissionSelectordisabled={!currentDataset?.embedding_available || isCurrentWorkspaceDatasetOperator}permission={permission}@@ -226,53 +224,42 @@ const Form = () => {</div>{currentDataset && currentDataset.indexing_technique && (<>- <div className='w-full h-0 border-b border-divider-subtle my-1' />+ <div className='w-full h-0 border-b-[0.5px] border-b-gray-200 my-2' /><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.indexMethod')}</div></div>- <div className='grow'>+ <div className='w-full sm:w-[480px]'><IndexMethodRadiodisable={!currentDataset?.embedding_available}value={indexMethod}onChange={v => setIndexMethod(v)}- docForm={currentDataset.doc_form}- currentValue={currentDataset.indexing_technique}/>- {currentDataset.indexing_technique === IndexingType.ECONOMICAL && indexMethod === IndexingType.QUALIFIED && <div className='mt-2 h-10 p-2 flex items-center gap-x-0.5 rounded-xl border-[0.5px] border-components-panel-border overflow-hidden bg-components-panel-bg-blur backdrop-blur-[5px] shadow-xs'>- <div className='absolute top-0 left-0 right-0 bottom-0 bg-[linear-gradient(92deg,rgba(247,144,9,0.25)_0%,rgba(255,255,255,0.00)_100%)] opacity-40'></div>- <div className='p-1'>- <AlertTriangle className='size-4 text-text-warning-secondary' />- </div>- <span className='system-xs-medium'>{t('datasetSettings.form.upgradeHighQualityTip')}</span>- </div>}</div></div></>)}{indexMethod === 'high_quality' && (- <>- <div className={rowClass}>- <div className={labelClass}>- <div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.embeddingModel')}</div>- </div>- <div className='grow'>- <ModelSelector- triggerClassName=''- defaultModel={embeddingModel}- modelList={embeddingModelList}- onSelect={(model: DefaultModel) => {- setEmbeddingModel(model)- }}- />- </div>+ <div className={rowClass}>+ <div className={labelClass}>+ <div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.embeddingModel')}</div></div>- </>+ <div className='w-[480px]'>+ <ModelSelector+ triggerClassName=''+ defaultModel={embeddingModel}+ modelList={embeddingModelList}+ onSelect={(model: DefaultModel) => {+ setEmbeddingModel(model)+ }}+ />+ </div>+ </div>)}{/* Retrieval Method Config */}{currentDataset?.provider === 'external'? <>- <div className='w-full h-0 border-b border-divider-subtle my-1' />+ <div className={rowClass}><Divider /></div><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.retrievalSetting.title')}</div>@@ -285,12 +272,12 @@ const Form = () => {isInRetrievalSetting={true}/></div>- <div className='w-full h-0 border-b border-divider-subtle my-1' />+ <div className={rowClass}><Divider /></div><div className={rowClass}><div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.externalKnowledgeAPI')}</div></div>- <div className='w-full'>+ <div className='w-full max-w-[480px]'><div className='flex h-full px-3 py-2 items-center gap-1 rounded-lg bg-components-input-bg-normal'><ApiConnectionMod className='w-4 h-4 text-text-secondary' /><div className='overflow-hidden text-text-secondary text-ellipsis system-sm-medium'>@@ -305,47 +292,44 @@ const Form = () => {<div className={labelClass}><div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.externalKnowledgeID')}</div></div>- <div className='w-full'>+ <div className='w-full max-w-[480px]'><div className='flex h-full px-3 py-2 items-center gap-1 rounded-lg bg-components-input-bg-normal'><div className='text-text-tertiary system-xs-regular'>{currentDataset?.external_knowledge_info.external_knowledge_id}</div></div></div></div>+ <div className={rowClass}><Divider /></div></>- : <>- <div className='w-full h-0 border-b border-divider-subtle my-1' />- <div className={rowClass}>- <div className={labelClass}>- <div>- <div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.retrievalSetting.title')}</div>- <div className='body-xs-regular text-text-tertiary'>- <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-text-accent'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>- {t('datasetSettings.form.retrievalSetting.description')}- </div>+ : <div className={rowClass}>+ <div className={labelClass}>+ <div>+ <div className='text-text-secondary system-sm-semibold'>{t('datasetSettings.form.retrievalSetting.title')}</div>+ <div className='leading-[18px] text-xs font-normal text-gray-500'>+ <a target='_blank' rel='noopener noreferrer' href='https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-4-retrieval-settings' className='text-[#155eef]'>{t('datasetSettings.form.retrievalSetting.learnMore')}</a>+ {t('datasetSettings.form.retrievalSetting.description')}</div></div>- <div className='grow'>- {indexMethod === 'high_quality'- ? (- <RetrievalMethodConfig- value={retrievalConfig}- onChange={setRetrievalConfig}- />- )- : (- <EconomicalRetrievalMethodConfig- value={retrievalConfig}- onChange={setRetrievalConfig}- />- )}- </div></div>- </>+ <div className='w-[480px]'>+ {indexMethod === 'high_quality'+ ? (+ <RetrievalMethodConfig+ value={retrievalConfig}+ onChange={setRetrievalConfig}+ />+ )+ : (+ <EconomicalRetrievalMethodConfig+ value={retrievalConfig}+ onChange={setRetrievalConfig}+ />+ )}+ </div>+ </div>}- <div className='w-full h-0 border-b border-divider-subtle my-1' /><div className={rowClass}><div className={labelClass} />- <div className='grow'>+ <div className='w-[480px]'><ButtonclassName='min-w-24'variant='primary'diff --git a/web/app/components/datasets/settings/index-method-radio/index.module.css b/web/app/components/datasets/settings/index-method-radio/index.module.cssnew file mode 100644index 00000000000..30f55b96450--- /dev/null+++ b/web/app/components/datasets/settings/index-method-radio/index.module.css@@ -0,0 +1,54 @@+.icon {+ margin-right: 12px;+ width: 24px;+ height: 24px;+ background: center center no-repeat;+ background-size: contain;+}++.high-quality-icon {+ background-image: url(./assets/high-quality.svg);+}+.economy-icon {+ background-image: url(./assets/economy.svg);+}++.wrapper .item:hover {+ background-color: #ffffff;+ border-color: #B2CCFF;+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);+}++.wrapper .item-active {+ background-color: #ffffff;+ border-width: 1.5px;+ border-color: #528BFF;+ box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);+}++.wrapper .item-active .radio {+ border-width: 5px;+ border-color: #155EEF;+}++.wrapper .item-active:hover {+ border-width: 1.5px;+ border-color: #528BFF;+ box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);+}++.wrapper .item.disable {+ @apply opacity-60;+}+.wrapper .item-active.disable {+ @apply opacity-60;+}+.wrapper .item.disable:hover {+ @apply bg-gray-25 border border-gray-100 shadow-none cursor-default opacity-60;+}+.wrapper .item-active.disable:hover {+ @apply cursor-default opacity-60;+ border-width: 1.5px;+ border-color: #528BFF;+ box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);+}diff --git a/web/app/components/datasets/settings/index-method-radio/index.tsx b/web/app/components/datasets/settings/index-method-radio/index.tsxindex 05650e48765..2bf6f36ce13 100644--- a/web/app/components/datasets/settings/index-method-radio/index.tsx+++ b/web/app/components/datasets/settings/index-method-radio/index.tsx@@ -1,103 +1,70 @@'use client'import { useTranslation } from 'react-i18next'-import Image from 'next/image'-import { useRef } from 'react'-import { useHover } from 'ahooks'-import { IndexingType } from '../../create/step-two'-import { OptionCard } from '../../create/step-two/option-card'-import { indexMethodIcon } from '../../create/icons'+import s from './index.module.css'import classNames from '@/utils/classnames'import type { DataSet } from '@/models/datasets'-import { ChunkingMode } from '@/models/datasets'-import Badge from '@/app/components/base/badge'-import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'+const itemClass = `+ w-full sm:w-[234px] p-3 rounded-xl bg-gray-25 border border-gray-100 cursor-pointer+`+const radioClass = `+ w-4 h-4 border-[2px] border-gray-200 rounded-full+`type IIndexMethodRadioProps = {value?: DataSet['indexing_technique']onChange: (v?: DataSet['indexing_technique']) => voiddisable?: boolean- docForm?: ChunkingMode- currentValue?: DataSet['indexing_technique']+ itemClassName?: string}const IndexMethodRadio = ({value,onChange,disable,- docForm,- currentValue,+ itemClassName,}: IIndexMethodRadioProps) => {const { t } = useTranslation()- const economyDomRef = useRef<HTMLDivElement>(null)- const isHoveringEconomy = useHover(economyDomRef)- const isEconomyDisabled = currentValue === IndexingType.QUALIFIEDconst options = [{key: 'high_quality',- text: <div className='flex items-center'>- {t('datasetCreation.stepTwo.qualified')}- <Badge uppercase className='ml-auto border-text-accent-secondary text-text-accent-secondary'>- {t('datasetCreation.stepTwo.recommend')}- </Badge>- </div>,+ text: t('datasetSettings.form.indexMethodHighQuality'),desc: t('datasetSettings.form.indexMethodHighQualityTip'),+ icon: 'high-quality',},{key: 'economy',text: t('datasetSettings.form.indexMethodEconomy'),desc: t('datasetSettings.form.indexMethodEconomyTip'),+ icon: 'economy',},]return (- <div className={classNames('flex justify-between w-full gap-2')}>+ <div className={classNames(s.wrapper, 'flex justify-between w-full flex-wrap gap-y-2')}>{- options.map((option) => {- const isParentChild = docForm === ChunkingMode.parentChild- return (- <PortalToFollowElem- key={option.key}- open={- isHoveringEconomy && option.key === 'economy'- }- placement={'top'}- >- <PortalToFollowElemTrigger>- <OptionCard- disabled={- disable- || (isEconomyDisabled && option.key === IndexingType.ECONOMICAL)- }- isActive={option.key === value}- onSwitched={() => {- if (isParentChild && option.key === IndexingType.ECONOMICAL)- return- if (isEconomyDisabled && option.key === IndexingType.ECONOMICAL)- return- if (!disable)- onChange(option.key as DataSet['indexing_technique'])- } }- icon={- <Image- src={option.key === 'high_quality' ? indexMethodIcon.high_quality : indexMethodIcon.economical}- alt={option.desc}- />- }- title={option.text}- description={option.desc}- ref={option.key === 'economy' ? economyDomRef : undefined}- className={classNames((isEconomyDisabled && option.key === 'economy') && 'cursor-not-allowed')}- >- </OptionCard>- </PortalToFollowElemTrigger>- <PortalToFollowElemContent style={{ zIndex: 60 }}>- <div className='p-3 bg-components-tooltip-bg border-components-panel-border text-xs font-medium text-text-secondary rounded-lg shadow-lg'>- {t('datasetSettings.form.indexMethodChangeToEconomyDisabledTip')}- </div>- </PortalToFollowElemContent>- </PortalToFollowElem>- )- })+ options.map(option => (+ <div+ key={option.key}+ className={classNames(+ itemClass,+ itemClassName,+ s.item,+ option.key === value && s['item-active'],+ disable && s.disable,+ )}+ onClick={() => {+ if (!disable)+ onChange(option.key as DataSet['indexing_technique'])+ }}+ >+ <div className='flex items-center mb-1'>+ <div className={classNames(s.icon, s[`${option.icon}-icon`])} />+ <div className='grow text-sm text-gray-900'>{option.text}</div>+ <div className={classNames(radioClass, s.radio)} />+ </div>+ <div className='pl-9 text-xs text-gray-500 leading-[18px]'>{option.desc}</div>+ </div>+ ))}</div>)diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/model-trigger.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/model-trigger.tsxindex 556a2ef66f3..023c6a5cd2a 100644--- a/web/app/components/header/account-setting/model-provider-page/model-selector/model-trigger.tsx+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/model-trigger.tsx@@ -13,7 +13,6 @@ import ModelIcon from '../model-icon'import ModelName from '../model-name'import { AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'import Tooltip from '@/app/components/base/tooltip'-import classNames from '@/utils/classnames'type ModelTriggerProps = {open: boolean@@ -33,13 +32,13 @@ const ModelTrigger: FC<ModelTriggerProps> = ({return (<div- className={classNames(- 'group flex items-center px-2 h-8 rounded-lg bg-components-input-bg-normal',- !readonly && 'hover:bg-components-input-bg-hover cursor-pointer',- className,- open && '!bg-components-input-bg-hover',- model.status !== ModelStatusEnum.active && '!bg-[#FFFAEB]',- )}+ className={`+ group flex items-center px-2 h-8 rounded-lg bg-gray-100+ ${!readonly && 'hover:bg-gray-200 cursor-pointer'}+ ${className}+ ${open && '!bg-gray-200'}+ ${model.status !== ModelStatusEnum.active && '!bg-[#FFFAEB]'}+ `}><ModelIconclassName='shrink-0 mr-1.5'@@ -69,6 +68,7 @@ const ModelTrigger: FC<ModelTriggerProps> = ({}</div>)}+</div>)}diff --git a/web/app/components/header/indicator/index.tsx b/web/app/components/header/indicator/index.tsxindex 12629e9848f..afa7aa7b08a 100644--- a/web/app/components/header/indicator/index.tsx+++ b/web/app/components/header/indicator/index.tsx@@ -7,7 +7,7 @@ export type IndicatorProps = {className?: string}-export type ColorMap = {+type ColorMap = {green: stringorange: stringred: string@@ -21,7 +21,7 @@ const BACKGROUND_MAP: ColorMap = {orange: 'bg-components-badge-status-light-warning-bg',red: 'bg-components-badge-status-light-error-bg',blue: 'bg-components-badge-status-light-normal-bg',- yellow: 'bg-components-badge-status-light-warning-bg',+ yellow: 'bg-[#FDB022]',gray: 'bg-components-badge-status-light-disabled-bg',}const BORDER_MAP: ColorMap = {@@ -29,16 +29,16 @@ const BORDER_MAP: ColorMap = {orange: 'border-components-badge-status-light-warning-border-inner',red: 'border-components-badge-status-light-error-border-inner',blue: 'border-components-badge-status-light-normal-border-inner',- yellow: 'border-components-badge-status-light-warning-border-inner',+ yellow: 'border-[#F79009]',gray: 'border-components-badge-status-light-disabled-border-inner',}const SHADOW_MAP: ColorMap = {- green: 'shadow-status-indicator-green-shadow',- orange: 'shadow-status-indicator-warning-shadow',- red: 'shadow-status-indicator-red-shadow',- blue: 'shadow-status-indicator-blue-shadow',- yellow: 'shadow-status-indicator-warning-shadow',- gray: 'shadow-status-indicator-gray-shadow',+ green: 'shadow-[0_0_5px_-3px_rgba(14,159,110,0.1),0.5px_0.5px_3px_rgba(14,159,110,0.3),inset_1.5px_1.5px_0px_rgba(255,255,255,0.2)]',+ orange: 'shadow-[0_0_5px_-3px_rgba(255,90,31,0.2),0.5px_0.5px_3px_rgba(255, 90, 31, 0.3), inset_1.5px_1.5px_0_rgba(255, 255, 255, 0.2)]',+ red: 'shadow-[0_0_5px_-3px_rgba(249,112,102,0.1),0.5px_0.5px_3px_rgba(249, 112, 102, 0.2), inset_1.5px_1.5px_0_rgba(255, 255, 255, 0.4)]',+ blue: 'shadow-[0_0_5px_-3px_rgba(208, 213, 221, 0.1),0.5px_0.5px_3px_rgba(208, 213, 221, 0.3), inset_1.5px_1.5px_0_rgba(255, 255, 255, 0.2)]',+ yellow: 'shadow-[0_0_5px_-3px_rgba(253, 176, 34, 0.1),0.5px_0.5px_3px_rgba(253, 176, 34, 0.3), inset_1.5px_1.5px_0_rgba(255, 255, 255, 0.2)]',+ gray: 'shadow-[0_0_5px_-3px_rgba(208, 213, 221, 0.1),0.5px_0.5px_3px_rgba(208, 213, 221, 0.3), inset_1.5px_1.5px_0_rgba(255, 255, 255, 0.2)]',}export default function Indicator({diff --git a/web/context/dataset-detail.ts b/web/context/dataset-detail.tsindex 198de381a8b..de046ce7a06 100644--- a/web/context/dataset-detail.ts+++ b/web/context/dataset-detail.ts@@ -1,17 +1,8 @@-import { createContext, useContext, useContextSelector } from 'use-context-selector'+import { createContext, useContext } from 'use-context-selector'import type { DataSet } from '@/models/datasets'-import type { IndexingType } from '@/app/components/datasets/create/step-two'-type DatasetDetailContextValue = {- indexingTechnique?: IndexingType- dataset?: DataSet- mutateDatasetRes?: () => void-}-const DatasetDetailContext = createContext<DatasetDetailContextValue>({})+const DatasetDetailContext = createContext<{ indexingTechnique?: string; dataset?: DataSet; mutateDatasetRes?: () => void }>({})export const useDatasetDetailContext = () => useContext(DatasetDetailContext)-export const useDatasetDetailContextWithSelector = (selector: (value: DatasetDetailContextValue) => any) => {- return useContextSelector(DatasetDetailContext, selector)-}export default DatasetDetailContextdiff --git a/web/hooks/use-metadata.ts b/web/hooks/use-metadata.tsindex 5d1d86c20e7..6a4965f2bfc 100644--- a/web/hooks/use-metadata.ts+++ b/web/hooks/use-metadata.ts@@ -1,7 +1,7 @@'use client'import { useTranslation } from 'react-i18next'import { formatFileSize, formatNumber, formatTime } from '@/utils/format'-import { type DocType, ProcessMode } from '@/models/datasets'+import type { DocType } from '@/models/datasets'import useTimestamp from '@/hooks/use-timestamp'export type inputType = 'input' | 'select' | 'textarea'@@ -250,7 +250,7 @@ export const useMetadataMap = (): MetadataMap => {subFieldsMap: {'dataset_process_rule.mode': {label: t(`${fieldPrefix}.technicalParameters.segmentSpecification`),- render: value => value === ProcessMode.general ? (t('datasetDocuments.embedding.custom') as string) : (t('datasetDocuments.embedding.hierarchical') as string),+ render: value => value === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string),},'dataset_process_rule.rules.segmentation.max_tokens': {label: t(`${fieldPrefix}.technicalParameters.segmentLength`),diff --git a/web/i18n/en-US/common.ts b/web/i18n/en-US/common.tsindex 4a951582c4e..ea0e4a88aaf 100644--- a/web/i18n/en-US/common.ts+++ b/web/i18n/en-US/common.ts@@ -42,11 +42,6 @@ const translation = {zoomOut: 'Zoom Out',zoomIn: 'Zoom In',openInNewTab: 'Open in new tab',- saveAndRegenerate: 'Save & Regenerate Child Chunks',- close: 'Close',- view: 'View',- viewMore: 'VIEW MORE',- regenerate: 'Regenerate',},errorMsg: {fieldRequired: '{{field}} is required',@@ -480,10 +475,9 @@ const translation = {documents: 'Documents',hitTesting: 'Retrieval Testing',settings: 'Settings',- emptyTip: 'This Knowledge has not been integrated within any application. Please refer to the document for guidance.',+ emptyTip: 'The Knowledge has not been associated, please go to the application or plug-in to complete the association.',viewDoc: 'View documentation',relatedApp: 'linked apps',- noRelatedApp: 'No linked apps',},voiceInput: {speaking: 'Speak now...',diff --git a/web/i18n/en-US/dataset-creation.ts b/web/i18n/en-US/dataset-creation.tsindex 8490896e3b9..6caf0056f81 100644--- a/web/i18n/en-US/dataset-creation.ts+++ b/web/i18n/en-US/dataset-creation.ts@@ -4,9 +4,9 @@ const translation = {creation: 'Create Knowledge',update: 'Add data',},- one: 'Data Source',- two: 'Document Processing',- three: 'Execute & Finish',+ one: 'Choose data source',+ two: 'Text Preprocessing and Cleaning',+ three: 'Execute and finish',},error: {unavailable: 'This Knowledge is not available',@@ -47,7 +47,6 @@ const translation = {notionSyncTitle: 'Notion is not connected',notionSyncTip: 'To sync with Notion, connection to Notion must be established first.',connect: 'Go to connect',- cancel: 'Cancel',button: 'Next',emptyDatasetCreation: 'I want to create an empty Knowledge',modal: {@@ -95,49 +94,36 @@ const translation = {},},stepTwo: {- segmentation: 'Chunk Settings',+ segmentation: 'Chunk settings',auto: 'Automatic',autoDescription: 'Automatically set chunk and preprocessing rules. Unfamiliar users are recommended to select this.',custom: 'Custom',customDescription: 'Customize chunks rules, chunks length, and preprocessing rules, etc.',- general: 'General',- generalTip: 'General text chunking mode, the chunks retrieved and recalled are the same.',- parentChild: 'Parent-child',- parentChildTip: 'When using the parent-child mode, the child-chunk is used for retrieval and the parent-chunk is used for recall as context.',- parentChunkForContext: 'Parent-chunk for Context',- childChunkForRetrieval: 'Child-chunk for Retrieval',- paragraph: 'Paragraph',- paragraphTip: 'This mode splits the text in to paragraphs based on delimiters and the maximum chunk length, using the split text as the parent chunk for retrieval.',- fullDoc: 'Full Doc',- fullDocTip: 'The entire document is used as the parent chunk and retrieved directly. Please note that for performance reasons, text exceeding 10000 tokens will be automatically truncated.',separator: 'Delimiter',separatorTip: 'A delimiter is the character used to separate text. \\n\\n and \\n are commonly used delimiters for separating paragraphs and lines. Combined with commas (\\n\\n,\\n), paragraphs will be segmented by lines when exceeding the maximum chunk length. You can also use special delimiters defined by yourself (e.g. ***).',- separatorPlaceholder: '\\n\\n for paragraphs; \\n for lines',+ separatorPlaceholder: '\\n\\n for separating paragraphs; \\n for separating lines',maxLength: 'Maximum chunk length',maxLengthCheck: 'Maximum chunk length should be less than {{limit}}',overlap: 'Chunk overlap',overlapTip: 'Setting the chunk overlap can maintain the semantic relevance between them, enhancing the retrieve effect. It is recommended to set 10%-25% of the maximum chunk size.',overlapCheck: 'chunk overlap should not bigger than maximum chunk length',- rules: 'Text Pre-processing Rules',+ rules: 'Text preprocessing rules',removeExtraSpaces: 'Replace consecutive spaces, newlines and tabs',removeUrlEmails: 'Delete all URLs and email addresses',removeStopwords: 'Remove stopwords such as "a", "an", "the"',- preview: 'Preview',- previewChunk: 'Preview Chunk',+ preview: 'Confirm & Preview',reset: 'Reset',- indexMode: 'Index Method',+ indexMode: 'Index mode',qualified: 'High Quality',- highQualityTip: 'Once finishing embedding in High Quality mode, reverting to Economical mode is not available.',recommend: 'Recommend',- qualifiedTip: 'Calling the embedding model to process documents for more precise retrieval helps LLM generate high-quality answers.',+ qualifiedTip: 'Call default system embedding interface for processing to provide higher accuracy when users query.',warning: 'Please set up the model provider API key first.',click: 'Go to settings',economical: 'Economical',- economicalTip: 'Using 10 keywords per chunk for retrieval, no tokens are consumed at the expense of reduced retrieval accuracy.',+ economicalTip: 'Use offline vector engines, keyword indexes, etc. to reduce accuracy without spending tokens',QATitle: 'Segmenting in Question & Answer format',QATip: 'Enable this option will consume more tokens',QALanguage: 'Segment using',- useQALanguage: 'Chunk using Q&A format in',estimateCost: 'Estimation',estimateSegment: 'Estimated chunks',segmentCount: 'chunks',@@ -167,19 +153,10 @@ const translation = {indexSettingTip: 'To change the index method & embedding model, please go to the ',retrievalSettingTip: 'To change the retrieval setting, please go to the ',datasetSettingLink: 'Knowledge settings.',- previewChunkTip: 'Click the \'Preview Chunk\' button on the left to load the preview',- previewChunkCount: '{{count}} Estimated chunks',- switch: 'Switch',- qaSwitchHighQualityTipTitle: 'Q&A Format Requires High-quality Indexing Method',- qaSwitchHighQualityTipContent: 'Currently, only high-quality index method supports Q&A format chunking. Would you like to switch to high-quality mode?',- notAvailableForParentChild: 'Not available for Parent-child Index',- notAvailableForQA: 'Not available for Q&A Index',- parentChildDelimiterTip: 'A delimiter is the character used to separate text. \\n\\n is recommended for splitting the original document into large parent chunks. You can also use special delimiters defined by yourself.',- parentChildChunkDelimiterTip: 'A delimiter is the character used to separate text. \\n is recommended for splitting parent chunks into small child chunks. You can also use special delimiters defined by yourself.',},stepThree: {creationTitle: '🎉 Knowledge created',- creationContent: 'We automatically named the Knowledge, you can modify it at any time.',+ creationContent: 'We automatically named the Knowledge, you can modify it at any time',label: 'Knowledge name',additionTitle: '🎉 Document uploaded',additionP1: 'The document has been uploaded to the Knowledge',@@ -194,11 +171,6 @@ const translation = {modelButtonConfirm: 'Confirm',modelButtonCancel: 'Cancel',},- otherDataSource: {- title: 'Connect to other data sources?',- description: 'Currently, Dify\'s knowledge base only has limited data sources. Contributing a data source to the Dify knowledge base is a fantastic way to help enhance the platform\'s flexibility and power for all users. Our contribution guide makes it easy to get started. Please click on the link below to learn more.',- learnMore: 'Learn more',- },}export default translationdiff --git a/web/i18n/en-US/dataset-documents.ts b/web/i18n/en-US/dataset-documents.tsindex d315261c361..8988b9dc184 100644--- a/web/i18n/en-US/dataset-documents.ts+++ b/web/i18n/en-US/dataset-documents.ts@@ -2,14 +2,12 @@ const translation = {list: {title: 'Documents',desc: 'All files of the Knowledge are shown here, and the entire Knowledge can be linked to Dify citations or indexed via the Chat plugin.',- learnMore: 'Learn more',addFile: 'Add file',addPages: 'Add Pages',addUrl: 'Add URL',table: {header: {- fileName: 'NAME',- chunkingMode: 'CHUNKING MODE',+ fileName: 'FILE NAME',words: 'WORDS',hitCount: 'RETRIEVAL COUNT',uploadTime: 'UPLOAD TIME',@@ -21,7 +19,7 @@ const translation = {},action: {uploadFile: 'Upload new file',- settings: 'Chunking Settings',+ settings: 'Segment settings',addButton: 'Add chunk',add: 'Add a chunk',batchAdd: 'Batch add',@@ -318,76 +316,36 @@ const translation = {completed: 'Embedding completed',error: 'Embedding error',docName: 'Preprocessing document',- mode: 'Chunking Setting',- segmentLength: 'Maximum Chunk Length',- textCleaning: 'Text Preprocessing Rules',+ mode: 'Segmentation rule',+ segmentLength: 'Chunks length',+ textCleaning: 'Text pre-definition and cleaning',segments: 'Paragraphs',highQuality: 'High-quality mode',economy: 'Economy mode',estimate: 'Estimated consumption',stop: 'Stop processing',- pause: 'Pause',- resume: 'Resume',+ resume: 'Resume processing',automatic: 'Automatic',custom: 'Custom',- hierarchical: 'Parent-child',previewTip: 'Paragraph preview will be available after embedding is complete',- parentMaxTokens: 'Parent',- childMaxTokens: 'Child',},segment: {paragraphs: 'Paragraphs',- chunks_one: 'CHUNK',- chunks_other: 'CHUNKS',- parentChunks_one: 'PARENT CHUNK',- parentChunks_other: 'PARENT CHUNKS',- childChunks_one: 'CHILD CHUNK',- childChunks_other: 'CHILD CHUNKS',- searchResults_zero: 'RESULT',- searchResults_one: 'RESULT',- searchResults_other: 'RESULTS',- empty: 'No Chunk found',- clearFilter: 'Clear filter',- chunk: 'Chunk',- parentChunk: 'Parent-Chunk',- newChunk: 'New Chunk',- childChunk: 'Child-Chunk',- newChildChunk: 'New Child Chunk',- keywords: 'KEYWORDS',- addKeyWord: 'Add keyword',+ keywords: 'Key Words',+ addKeyWord: 'Add key word',keywordError: 'The maximum length of keyword is 20',- characters_one: 'character',- characters_other: 'characters',+ characters: 'characters',hitCount: 'Retrieval count',vectorHash: 'Vector hash: ',- questionPlaceholder: 'Add question here',+ questionPlaceholder: 'add question here',questionEmpty: 'Question can not be empty',- answerPlaceholder: 'Add answer here',+ answerPlaceholder: 'add answer here',answerEmpty: 'Answer can not be empty',- contentPlaceholder: 'Add content here',+ contentPlaceholder: 'add content here',contentEmpty: 'Content can not be empty',newTextSegment: 'New Text Segment',newQaSegment: 'New Q&A Segment',- addChunk: 'Add Chunk',- addChildChunk: 'Add Child Chunk',- addAnother: 'Add another',delete: 'Delete this chunk ?',- chunkAdded: '1 chunk added',- childChunkAdded: '1 child chunk added',- editChunk: 'Edit Chunk',- editParentChunk: 'Edit Parent Chunk',- editChildChunk: 'Edit Child Chunk',- chunkDetail: 'Chunk Detail',- regenerationConfirmTitle: 'Do you want to regenerate child chunks?',- regenerationConfirmMessage: 'Regenerating child chunks will overwrite the current child chunks, including edited chunks and newly added chunks. The regeneration cannot be undone.',- regeneratingTitle: 'Regenerating child chunks',- regeneratingMessage: 'This may take a moment, please wait...',- regenerationSuccessTitle: 'Regeneration completed',- regenerationSuccessMessage: 'You can close this window.',- edited: 'EDITED',- editedAt: 'Edited at',- expandChunks: 'Expand chunks',- collapseChunks: 'Collapse chunks',},}diff --git a/web/i18n/en-US/dataset-hit-testing.ts b/web/i18n/en-US/dataset-hit-testing.tsindex 1e68306a9dd..6dbfa47fee7 100644--- a/web/i18n/en-US/dataset-hit-testing.ts+++ b/web/i18n/en-US/dataset-hit-testing.ts@@ -1,9 +1,9 @@const translation = {- title: 'Retrieval Test',+ title: 'Retrieval Testing',settingTitle: 'Retrieval Setting',- desc: 'Test the hitting effect of the Knowledge based on the given query text.',+ desc: 'Test the hitting effect of the Knowledge based on the given query text',dateTimeFormat: 'MM/DD/YYYY hh:mm A',- records: 'Records',+ recents: 'Recents',table: {header: {source: 'Source',@@ -16,19 +16,15 @@ const translation = {placeholder: 'Please enter a text, a short declarative sentence is recommended.',countWarning: 'Up to 200 characters.',indexWarning: 'High quality Knowledge only.',- testing: 'Test',+ testing: 'Testing',},hit: {- title: '{{num}} Retrieved Chunks',+ title: 'RETRIEVAL PARAGRAPHS',emptyTip: 'Retrieval Testing results will show here',},noRecentTip: 'No recent query results here',viewChart: 'View VECTOR CHART',viewDetail: 'View Detail',- chunkDetail: 'Chunk Detail',- hitChunks: 'Hit {{num}} child chunks',- open: 'Open',- keyword: 'Keywords',}export default translationdiff --git a/web/i18n/en-US/dataset-settings.ts b/web/i18n/en-US/dataset-settings.tsindex d25779ec83d..aa435c8e0e8 100644--- a/web/i18n/en-US/dataset-settings.ts+++ b/web/i18n/en-US/dataset-settings.ts@@ -7,8 +7,7 @@ const translation = {nameError: 'Name cannot be empty',desc: 'Knowledge Description',descInfo: 'Please write a clear textual description to outline the content of the Knowledge. This description will be used as a basis for matching when selecting from multiple Knowledge for inference.',- descPlaceholder: 'Describe what is in this data set. A detailed description allows AI to access the content of the data set in a timely manner. If empty, LangGenius will use the default hit strategy.',- helpText: 'Learn how to write a good dataset description.',+ descPlaceholder: 'Describe what\'s in this Knowledge (optional)',descWrite: 'Learn how to write a good Knowledge description.',permissions: 'Permissions',permissionsOnlyMe: 'Only me',@@ -17,10 +16,9 @@ const translation = {me: '(You)',indexMethod: 'Index Method',indexMethodHighQuality: 'High Quality',- indexMethodHighQualityTip: 'Calling the embedding model to process documents for more precise retrieval helps LLM generate high-quality answers.',- upgradeHighQualityTip: 'Once upgrading to High Quality mode, reverting to Economical mode is not available',+ indexMethodHighQualityTip: 'Call Embedding model for processing to provide higher accuracy when users query.',indexMethodEconomy: 'Economical',- indexMethodEconomyTip: 'Using 10 keywords per chunk for retrieval, no tokens are consumed at the expense of reduced retrieval accuracy.',+ indexMethodEconomyTip: 'Use offline vector engines, keyword indexes, etc. to reduce accuracy without spending tokens',embeddingModel: 'Embedding Model',embeddingModelTip: 'Change the embedded model, please go to ',embeddingModelTipLink: 'Settings',@@ -34,7 +32,6 @@ const translation = {externalKnowledgeID: 'External Knowledge ID',retrievalSettings: 'Retrieval Settings',save: 'Save',- indexMethodChangeToEconomyDisabledTip: 'Not available for downgrading from HQ to ECO',},}diff --git a/web/i18n/en-US/dataset.ts b/web/i18n/en-US/dataset.tsindex 6a6df700d7b..e89ea47c262 100644--- a/web/i18n/en-US/dataset.ts+++ b/web/i18n/en-US/dataset.ts@@ -1,13 +1,5 @@const translation = {knowledge: 'Knowledge',- chunkingMode: {- general: 'General',- parentChild: 'Parent-child',- },- parentMode: {- paragraph: 'Paragraph',- fullDoc: 'Full-doc',- },externalTag: 'External',externalAPI: 'External API',externalAPIPanelTitle: 'External Knowledge API',@@ -20,7 +12,6 @@ const translation = {learnHowToWriteGoodKnowledgeDescription: 'Learn how to write a good knowledge description',externalAPIPanelDescription: 'The external knowledge API is used to connect to a knowledge base outside of Dify and retrieve knowledge from that knowledge base.',externalAPIPanelDocumentation: 'Learn how to create an External Knowledge API',- localDocs: 'Local Docs',documentCount: ' docs',wordCount: ' k words',appCount: ' linked apps',@@ -124,10 +115,8 @@ const translation = {change: 'Change',changeRetrievalMethod: 'Change retrieval method',},- docsFailedNotice: 'documents indexed failed',+ docsFailedNotice: 'documents failed to be indexed',retry: 'Retry',- documentsDisabled: '{{num}} documents disabled - inactive for over 30 days',- enable: 'Enable',indexingTechnique: {high_quality: 'HQ',economy: 'ECO',@@ -157,15 +146,6 @@ const translation = {nTo1RetrievalLegacy: 'N-to-1 retrieval will be officially deprecated from September. It is recommended to use the latest Multi-path retrieval to obtain better results. ',nTo1RetrievalLegacyLink: 'Learn more',nTo1RetrievalLegacyLinkText: ' N-to-1 retrieval will be officially deprecated in September.',- batchAction: {- selected: 'Selected',- enable: 'Enable',- disable: 'Disable',- archive: 'Archive',- delete: 'Delete',- cancel: 'Cancel',- },- preprocessDocument: '{{num}} Preprocess Documents',}export default translationdiff --git a/web/i18n/zh-Hans/common.ts b/web/i18n/zh-Hans/common.tsindex 7f1dc1f899b..96e08a93375 100644--- a/web/i18n/zh-Hans/common.ts+++ b/web/i18n/zh-Hans/common.ts@@ -42,11 +42,6 @@ const translation = {zoomOut: '缩小',zoomIn: '放大',openInNewTab: '在新标签页打开',- saveAndRegenerate: '保存并重新生成子分段',- close: '关闭',- view: '查看',- viewMore: '查看更多',- regenerate: '重新生成',},errorMsg: {fieldRequired: '{{field}} 为必填项',@@ -480,10 +475,9 @@ const translation = {documents: '文档',hitTesting: '召回测试',settings: '设置',- emptyTip: '此知识尚未集成到任何应用程序中。请参阅文档以获取指导。',+ emptyTip: ' 知识库尚未关联,请前往应用程序或插件完成关联。',viewDoc: '查看文档',relatedApp: '个关联应用',- noRelatedApp: '无关联应用',},voiceInput: {speaking: '现在讲...',diff --git a/web/i18n/zh-Hans/dataset-creation.ts b/web/i18n/zh-Hans/dataset-creation.tsindex a3dff76050f..e6c3aa00ba9 100644--- a/web/i18n/zh-Hans/dataset-creation.ts+++ b/web/i18n/zh-Hans/dataset-creation.ts@@ -47,7 +47,6 @@ const translation = {notionSyncTitle: 'Notion 未绑定',notionSyncTip: '同步 Notion 内容前,须先绑定 Notion 空间',connect: '去绑定',- cancel: '取消',button: '下一步',emptyDatasetCreation: '创建一个空知识库',modal: {@@ -100,16 +99,6 @@ const translation = {autoDescription: '自动设置分段规则与预处理规则,如果不了解这些参数建议选择此项',custom: '自定义',customDescription: '自定义分段规则、分段长度以及预处理规则等参数',- general: '通用',- generalTip: '通用文本分块模式,检索和回忆的块是相同的',- parentChild: '父子分段',- parentChildTip: '使用父子模式时,子块用于检索,父块用作上下文',- parentChunkForContext: '父块用作上下文',- childChunkForRetrieval: '子块用于检索',- paragraph: '段落',- paragraphTip: '此模式根据分隔符和最大块长度将文本拆分为段落,使用拆分文本作为检索的父块',- fullDoc: '全文',- fullDocTip: '整个文档用作父块并直接检索。请注意,出于性能原因,超过10000个标记的文本将被自动截断。',separator: '分段标识符',separatorTip: '分隔符是用于分隔文本的字符。\\n\\n 和 \\n 是常用于分隔段落和行的分隔符。用逗号连接分隔符(\\n\\n,\\n),当段落超过最大块长度时,会按行进行分割。你也可以使用自定义的特殊分隔符(例如 ***)。',separatorPlaceholder: '\\n\\n 用于分段;\\n 用于分行',@@ -122,22 +111,19 @@ const translation = {removeExtraSpaces: '替换掉连续的空格、换行符和制表符',removeUrlEmails: '删除所有 URL 和电子邮件地址',removeStopwords: '去除停用词,例如 “a”,“an”,“the” 等',- preview: '预览',- previewChunk: '预览块',+ preview: '确认并预览',reset: '重置',indexMode: '索引方式',qualified: '高质量',- highQualityTip: '使用高质量模式进行嵌入后,无法切换回经济模式。',recommend: '推荐',- qualifiedTip: '调用嵌入模型处理文档以实现更精确的检索,可以帮助LLM生成高质量的答案。',+ qualifiedTip: '调用系统默认的嵌入接口进行处理,以在用户查询时提供更高的准确度',warning: '请先完成模型供应商的 API KEY 设置。.',click: '前往设置',economical: '经济',- economicalTip: '每个数据块使用10个关键词进行检索,不会消耗任何tokens,但会以降低检索准确性为代价。',+ economicalTip: '使用离线的向量引擎、关键词索引等方式,降低了准确度但无需花费 Token',QATitle: '采用 Q&A 分段模式',QATip: '开启后将会消耗额外的 token',QALanguage: '分段使用',- useQALanguage: '使用 Q&A 分段,语言',estimateCost: '执行嵌入预估消耗',estimateSegment: '预估分段数',segmentCount: '段',@@ -167,15 +153,6 @@ const translation = {indexSettingTip: '要更改索引方法和 embedding 模型,请转到',retrievalSettingTip: '要更改检索方法,请转到',datasetSettingLink: '知识库设置。',- previewChunkTip: '点击左侧的“预览块”按钮来加载预览',- previewChunkCount: '{{count}} 预估块',- switch: '切换',- qaSwitchHighQualityTipTitle: 'Q&A 格式需要高质量的索引方法',- qaSwitchHighQualityTipContent: '目前,只有高质量的索引方法支持 Q&A 格式分块。您要切换到高质量模式吗?',- notAvailableForParentChild: '不支持父子索引',- notAvailableForQA: '不支持 Q&A 索引',- parentChildDelimiterTip: '文本分隔符是用于分隔文本的字符。建议用 \n\n 将原始文档划分为较大的父级片段。您也可以自定义特殊分隔符。',- parentChildChunkDelimiterTip: '文本分隔符是用于分隔文本的字符。建议使用 \n 将父级片段拆分为较小的子级片段。您也可以自定义特殊分隔符。',},stepThree: {creationTitle: '🎉 知识库已创建',diff --git a/web/i18n/zh-Hans/dataset-documents.ts b/web/i18n/zh-Hans/dataset-documents.tsindex 9949f33d873..2f68f04d1df 100644--- a/web/i18n/zh-Hans/dataset-documents.ts+++ b/web/i18n/zh-Hans/dataset-documents.ts@@ -2,14 +2,12 @@ const translation = {list: {title: '文档',desc: '知识库的所有文件都在这里显示,整个知识库都可以链接到 Dify 引用或通过 Chat 插件进行索引。',- learnMore: '了解更多',addFile: '添加文件',addPages: '添加页面',addUrl: '添加 URL',table: {header: {- fileName: '名称',- chunkingMode: '分段模式',+ fileName: '文件名',words: '字符数',hitCount: '召回次数',uploadTime: '上传时间',@@ -317,46 +315,25 @@ const translation = {completed: '嵌入已完成',error: '嵌入发生错误',docName: '预处理文档',- mode: '分段模式',- segmentLength: '最大分段长度',- textCleaning: '文本预处理规则',+ mode: '分段规则',+ segmentLength: '分段长度',+ textCleaning: '文本预定义与清洗',segments: '段落',highQuality: '高质量模式',economy: '经济模式',estimate: '预估消耗',stop: '停止处理',- pause: '暂停',- resume: '恢复',+ resume: '恢复处理',automatic: '自动',custom: '自定义',- hierarchical: '父子分段',previewTip: '段落预览将在嵌入完成后可用',- parentMaxTokens: '父',- childMaxTokens: '子',},segment: {paragraphs: '段落',- chunks_one: '分段',- chunks_other: '分段',- parentChunks_one: '父分段',- parentChunks_other: '父分段',- childChunks_one: '子分段',- childChunks_other: '子分段',- searchResults_zero: '搜索结果',- searchResults_one: '搜索结果',- searchResults_other: '搜索结果',- empty: '未找到分段',- clearFilter: '清空搜索条件',- chunk: '分段',- parentChunk: '父分段',- newChunk: '新分段',- childChunk: '子分段',- newChildChunk: '新子分段',keywords: '关键词',addKeyWord: '添加关键词',keywordError: '关键词最大长度为 20',- characters_one: '字符',- characters_other: '字符',+ characters: '字符',hitCount: '召回次数',vectorHash: '向量哈希:',questionPlaceholder: '在这里添加问题',@@ -367,26 +344,7 @@ const translation = {contentEmpty: '内容不能为空',newTextSegment: '新文本分段',newQaSegment: '新问答分段',- addChunk: '新增分段',- addChildChunk: '新增子分段',- addAnother: '连续新增',delete: '删除这个分段?',- chunkAdded: '新增一个分段',- childChunkAdded: '新增一个子分段',- editChunk: '编辑分段',- editParentChunk: '编辑父分段',- editChildChunk: '编辑子分段',- chunkDetail: '分段详情',- regenerationConfirmTitle: '是否需要重新生成子分段?',- regenerationConfirmMessage: '重新生成的子分段将会覆盖当前的子分段,包括编辑过的分段和新添加的分段。重新生成操作无法撤销。',- regeneratingTitle: '正在生成子分段',- regeneratingMessage: '生成子分段需要一些时间,请耐心等待...',- regenerationSuccessTitle: '子分段已重新生成',- regenerationSuccessMessage: '可以关闭窗口',- edited: '已编辑',- editedAt: '编辑于',- expandChunks: '展开分段',- collapseChunks: '折叠分段',},}diff --git a/web/i18n/zh-Hans/dataset-hit-testing.ts b/web/i18n/zh-Hans/dataset-hit-testing.tsindex 88924edc825..09cfdc2824c 100644--- a/web/i18n/zh-Hans/dataset-hit-testing.ts+++ b/web/i18n/zh-Hans/dataset-hit-testing.ts@@ -1,9 +1,9 @@const translation = {title: '召回测试',settingTitle: '召回设置',- desc: '根据给定的查询文本测试知识的召回效果。',+ desc: '基于给定的查询文本测试知识库的召回效果',dateTimeFormat: 'YYYY-MM-DD HH:mm',- records: '记录',+ recents: '最近查询',table: {header: {source: '数据源',@@ -19,16 +19,12 @@ const translation = {testing: '测试',},hit: {- title: '{{num}} 个召回段落',+ title: '召回段落',emptyTip: '召回测试结果将展示在这里',},noRecentTip: '最近无查询结果',viewChart: '查看向量图表',viewDetail: '查看详情',- chunkDetail: '段落详情',- hitChunks: '命中 {{num}} 个子段落',- open: '打开',- keyword: '关键词',}export default translationdiff --git a/web/i18n/zh-Hans/dataset-settings.ts b/web/i18n/zh-Hans/dataset-settings.tsindex 0817127c19c..423703e04ca 100644--- a/web/i18n/zh-Hans/dataset-settings.ts+++ b/web/i18n/zh-Hans/dataset-settings.ts@@ -7,8 +7,7 @@ const translation = {nameError: '名称不能为空',desc: '知识库描述',descInfo: '请写出清楚的文字描述来概述知识库的内容。当从多个知识库中进行选择匹配时,该描述将用作匹配的基础。',- descPlaceholder: '描述该数据集的内容。详细描述可以让 AI 更快地访问数据集的内容。如果为空,LangGenius 将使用默认的命中策略。',- helpText: '学习如何编写一份优秀的数据集描述。',+ descPlaceholder: '请描述这个知识库包含的内容(可选)',descWrite: '了解如何编写更好的知识库描述。',permissions: '可见权限',permissionsOnlyMe: '只有我',@@ -17,10 +16,9 @@ const translation = {me: '(你)',indexMethod: '索引模式',indexMethodHighQuality: '高质量',- indexMethodHighQualityTip: '调用嵌入模型来处理文档以实现更精确的检索,可以帮助大语言模型生成高质量的回答。',- upgradeHighQualityTip: '一旦升级为高质量模式,将无法切换回经济模式。',+ indexMethodHighQualityTip: '调用 Embedding 模型进行处理,以在用户查询时提供更高的准确度。',indexMethodEconomy: '经济',- indexMethodEconomyTip: '每个块使用 10 个关键词进行检索,不消耗 tokens,但会降低检索准确性。',+ indexMethodEconomyTip: '使用离线的向量引擎、关键词索引等方式,降低了准确度但无需花费 Token',embeddingModel: 'Embedding 模型',embeddingModelTip: '修改 Embedding 模型,请去',embeddingModelTipLink: '设置',@@ -34,7 +32,6 @@ const translation = {externalKnowledgeID: '外部知识库 ID',save: '保存',retrievalSettings: '检索设置',- indexMethodChangeToEconomyDisabledTip: '无法从高质量降级为经济',},}diff --git a/web/i18n/zh-Hans/dataset.ts b/web/i18n/zh-Hans/dataset.tsindex d7834b41162..d057af0c164 100644--- a/web/i18n/zh-Hans/dataset.ts+++ b/web/i18n/zh-Hans/dataset.ts@@ -1,13 +1,5 @@const translation = {knowledge: '知识库',- chunkingMode: {- general: '通用',- parentChild: '父子',- },- parentMode: {- paragraph: '段落',- fullDoc: '全文',- },externalTag: '外部',externalAPI: '外部 API',externalAPIPanelTitle: '外部知识库 API',@@ -20,7 +12,6 @@ const translation = {learnHowToWriteGoodKnowledgeDescription: '了解如何编写良好的知识库描述',externalAPIPanelDescription: '外部知识库 API 用于连接到 Dify 之外的知识库并从中检索知识。',externalAPIPanelDocumentation: '了解如何创建外部知识库 API',- localDocs: '本地文档',documentCount: ' 文档',wordCount: ' 千字符',appCount: ' 关联应用',@@ -124,10 +115,8 @@ const translation = {change: '更改',changeRetrievalMethod: '更改检索方法',},- docsFailedNotice: '文档索引失败',+ docsFailedNotice: '文档无法被索引',retry: '重试',- documentsDisabled: '{{num}} 个文档已禁用 - 未活动超过 30 天',- enable: '启用',indexingTechnique: {high_quality: '高质量',economy: '经济',@@ -157,15 +146,6 @@ const translation = {nTo1RetrievalLegacy: '9 月 1 日起我们将不再提供此能力,推荐使用最新的多路召回获得更好的检索效果。',nTo1RetrievalLegacyLink: '了解更多',nTo1RetrievalLegacyLinkText: '9 月 1 日起我们将不再提供此能力。',- batchAction: {- selected: '已选择',- enable: '启用',- disable: '禁用',- archive: '归档',- delete: '删除',- cancel: '取消',- },- preprocessDocument: '{{num}} 个预处理文档',}export default translationdiff --git a/web/i18n/zh-Hant/dataset-creation.ts b/web/i18n/zh-Hant/dataset-creation.tsindex 20cae924855..8c5673cb3f8 100644--- a/web/i18n/zh-Hant/dataset-creation.ts+++ b/web/i18n/zh-Hant/dataset-creation.ts@@ -37,7 +37,6 @@ const translation = {notionSyncTitle: 'Notion 未繫結',notionSyncTip: '同步 Notion 內容前,須先繫結 Notion 空間',connect: '去繫結',- cancel: '取消',button: '下一步',emptyDatasetCreation: '建立一個空知識庫',modal: {@@ -100,7 +99,7 @@ const translation = {removeExtraSpaces: '替換掉連續的空格、換行符和製表符',removeUrlEmails: '刪除所有 URL 和電子郵件地址',removeStopwords: '去除停用詞,例如 “a”,“an”,“the” 等',- preview: '預覽',+ preview: '確認並預覽',reset: '重置',indexMode: '索引方式',qualified: '高質量',diff --git a/web/models/datasets.ts b/web/models/datasets.tsindex 9d4768b67c2..e2fa608bae3 100644--- a/web/models/datasets.ts+++ b/web/models/datasets.ts@@ -1,7 +1,6 @@import type { DataSourceNotionPage, DataSourceProvider } from './common'import type { AppIconType, AppMode, RetrievalConfig } from '@/types/app'import type { Tag } from '@/app/components/base/tag-management/constant'-import type { IndexingType } from '@/app/components/datasets/create/step-two'export enum DataSourceType {FILE = 'upload_file',@@ -11,12 +10,6 @@ export enum DataSourceType {export type DatasetPermission = 'only_me' | 'all_team_members' | 'partial_members'-export enum ChunkingMode {- 'text' = 'text_model', // General text- 'qa' = 'qa_model', // General QA- 'parentChild' = 'hierarchical_model', // Parent-Child-}-export type DataSet = {id: stringname: string@@ -25,12 +18,11 @@ export type DataSet = {description: stringpermission: DatasetPermissiondata_source_type: DataSourceType- indexing_technique: IndexingType+ indexing_technique: 'high_quality' | 'economy'created_by: stringupdated_by: stringupdated_at: numberapp_count: number- doc_form: ChunkingModedocument_count: numberword_count: numberprovider: string@@ -103,12 +95,6 @@ export type CustomFile = File & {created_at?: number}-export type DocumentItem = {- id: string- name: string- extension: string-}-export type CrawlOptions = {crawl_sub_pages: booleanonly_main_content: boolean@@ -158,7 +144,7 @@ export type IndexingEstimateResponse = {total_price: numbercurrency: stringtotal_segments: number- preview: Array<{ content: string; child_chunks: string[] }>+ preview: string[]qa_preview?: QA[]}@@ -184,12 +170,7 @@ export type IndexingStatusBatchResponse = {data: IndexingStatusResponse[]}-export enum ProcessMode {- general = 'custom',- parentChild = 'hierarchical',-}--export type ParentMode = 'full-doc' | 'paragraph'+export type ProcessMode = 'automatic' | 'custom'export type ProcessRuleResponse = {mode: ProcessMode@@ -200,8 +181,6 @@ export type ProcessRuleResponse = {export type Rules = {pre_processing_rules: PreProcessingRule[]segmentation: Segmentation- parent_mode: ParentMode- subchunk_segmentation: Segmentation}export type Limits = {@@ -216,7 +195,7 @@ export type PreProcessingRule = {export type Segmentation = {separator: stringmax_tokens: number- chunk_overlap?: number+ chunk_overlap: number}export const DocumentIndexingStatusList = [@@ -279,14 +258,13 @@ export type InitialDocumentDetail = {display_status: DocumentDisplayStatuscompleted_segments?: numbertotal_segments?: number- doc_form: ChunkingMode+ doc_form: 'text_model' | 'qa_model'doc_language: string}export type SimpleDocumentDetail = InitialDocumentDetail & {enabled: booleanword_count: number- is_qa: boolean // TODO waiting for backend to add this fielderror?: string | nullarchived: booleanupdated_at: number@@ -311,7 +289,7 @@ export type DocumentListResponse = {export type DocumentReq = {original_document_id?: stringindexing_technique?: string- doc_form: ChunkingMode+ doc_form: 'text_model' | 'qa_model'doc_language: stringprocess_rule: ProcessRule}@@ -353,7 +331,7 @@ export type NotionPage = {}export type ProcessRule = {- mode: ProcessMode+ mode: stringrules: Rules}@@ -363,11 +341,6 @@ export type createDocumentResponse = {documents: InitialDocumentDetail[]}-export type PrecessRule = {- mode: ProcessMode- rules: Rules-}-export type FullDocumentDetail = SimpleDocumentDetail & {batch: stringcreated_api_request_id: string@@ -390,8 +363,6 @@ export type FullDocumentDetail = SimpleDocumentDetail & {doc_type?: DocType | null | 'others'doc_metadata?: DocMetadata | nullsegment_count: number- dataset_process_rule: PrecessRule- document_process_rule: ProcessRule[key: string]: any}@@ -428,12 +399,12 @@ export const SEGMENT_STATUS_LIST = ['waiting', 'completed', 'error', 'indexing']export type SegmentStatus = typeof SEGMENT_STATUS_LIST[number]export type SegmentsQuery = {- page?: string+ last_id?: stringlimit: number// status?: SegmentStatushit_count_gte?: numberkeyword?: string- enabled?: boolean | 'all'+ enabled?: boolean}export type SegmentDetailModel = {@@ -458,8 +429,6 @@ export type SegmentDetailModel = {error: string | nullstopped_at: numberanswer?: string- child_chunks?: ChildChunkDetail[]- updated_at: number}export type SegmentsResponse = {@@ -467,8 +436,6 @@ export type SegmentsResponse = {has_more: booleanlimit: numbertotal: number- total_pages: number- page: number}export type HitTestingRecord = {@@ -481,18 +448,10 @@ export type HitTestingRecord = {created_at: number}-export type HitTestingChildChunk = {- id: string- content: string- position: number- score: number-}export type HitTesting = {segment: Segment- content: Segmentscore: numbertsne_position: TsnePosition- child_chunks?: HitTestingChildChunk[] | null}export type ExternalKnowledgeBaseHitTesting = {@@ -571,7 +530,11 @@ export type SegmentUpdater = {content: stringanswer?: stringkeywords?: string[]- regenerate_child_chunks?: boolean+}++export enum DocForm {+ TEXT = 'text_model',+ QA = 'qa_model',}export type ErrorDocsResponse = {@@ -616,49 +579,3 @@ export const DEFAULT_WEIGHTED_SCORE = {keyword: 0.3,},}--export type ChildChunkType = 'automatic' | 'customized'--export type ChildChunkDetail = {- id: string- position: number- segment_id: string- content: string- word_count: number- created_at: number- updated_at: number- type: ChildChunkType-}--export type ChildSegmentsResponse = {- data: ChildChunkDetail[]- total: number- total_pages: number- page: number- limit: number-}--export type UpdateDocumentParams = {- datasetId: string- documentId: string-}--// Used in api url-export enum DocumentActionType {- enable = 'enable',- disable = 'disable',- archive = 'archive',- unArchive = 'un_archive',- delete = 'delete',-}--export type UpdateDocumentBatchParams = {- datasetId: string- documentId?: string- documentIds?: string[] | string-}--export type BatchImportResponse = {- job_id: string- job_status: string-}diff --git a/web/package.json b/web/package.jsonindex 64721051a97..d9515645c8b 100644--- a/web/package.json+++ b/web/package.json@@ -64,7 +64,6 @@"katex": "^0.16.10","lamejs": "^1.2.1","lexical": "^0.16.0",- "line-clamp": "^1.0.0","lodash-es": "^4.17.21","mermaid": "11.4.1","mime": "^4.0.4",@@ -103,7 +102,6 @@"scheduler": "^0.23.0","server-only": "^0.0.1","sharp": "^0.33.2",- "shave": "^5.0.4","sortablejs": "^1.15.0","swr": "^2.1.0","tailwind-merge": "^2.4.0",diff --git a/web/public/screenshots/Light/Agent.png b/web/public/screenshots/Light/Agent.pngdeleted file mode 100644index fe596a555ff..00000000000Binary files a/web/public/screenshots/Light/Agent.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index dda71b29e92..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 0d05644eab4..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/ChatFlow.png b/web/public/screenshots/Light/ChatFlow.pngdeleted file mode 100644index 1753de77635..00000000000Binary files a/web/public/screenshots/Light/ChatFlow.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 6b72a8d732e..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 7a059af6a41..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/Chatbot.png b/web/public/screenshots/Light/Chatbot.pngdeleted file mode 100644index b628a930fb6..00000000000Binary files a/web/public/screenshots/Light/Chatbot.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 048a9f90363..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 9b7c1f59996..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/Chatflow.png b/web/public/screenshots/Light/Chatflow.pngdeleted file mode 100644index 1753de77635..00000000000Binary files a/web/public/screenshots/Light/Chatflow.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 6b72a8d732e..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 7a059af6a41..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/TextGenerator.png b/web/public/screenshots/Light/TextGenerator.pngdeleted file mode 100644index 14973451cc0..00000000000Binary files a/web/public/screenshots/Light/TextGenerator.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 7e1baae97bb..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 746e9ac1bea..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/Workflow.png b/web/public/screenshots/Light/Workflow.pngdeleted file mode 100644index a82c9a6a4d0..00000000000Binary files a/web/public/screenshots/Light/Workflow.png and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 0a1a19435bc..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/public/screenshots/Light/[email protected] b/web/public/screenshots/Light/[email protected]deleted file mode 100644index 914ce45003e..00000000000Binary files a/web/public/screenshots/Light/[email protected] and /dev/null differdiff --git a/web/service/datasets.ts b/web/service/datasets.tsindex 87f4e3a6385..90411efd4e1 100644--- a/web/service/datasets.ts+++ b/web/service/datasets.ts@@ -5,6 +5,7 @@ import type {CreateDocumentReq,DataSet,DataSetListResponse,+ DocumentDetailResponse,DocumentListResponse,ErrorDocsResponse,ExternalAPIDeleteResponse,@@ -22,6 +23,10 @@ import type {IndexingStatusResponse,ProcessRuleResponse,RelatedAppResponse,+ SegmentDetailModel,+ SegmentUpdater,+ SegmentsQuery,+ SegmentsResponse,createDocumentResponse,} from '@/models/datasets'import type { CreateKnowledgeBaseReq } from '@/app/components/datasets/external-knowledge-base/create/declarations'@@ -148,6 +153,10 @@ export const fetchIndexingStatusBatch: Fetcher<IndexingStatusBatchResponse, Batcreturn get<IndexingStatusBatchResponse>(`/datasets/${datasetId}/batch/${batchId}/indexing-status`, {})}+export const fetchDocumentDetail: Fetcher<DocumentDetailResponse, CommonDocReq & { params: { metadata?: MetadataType } }> = ({ datasetId, documentId, params }) => {+ return get<DocumentDetailResponse>(`/datasets/${datasetId}/documents/${documentId}`, { params })+}+export const renameDocumentName: Fetcher<CommonResponse, CommonDocReq & { name: string }> = ({ datasetId, documentId, name }) => {return post<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/rename`, {body: { name },@@ -162,6 +171,34 @@ export const resumeDocIndexing: Fetcher<CommonResponse, CommonDocReq> = ({ datasreturn patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/processing/resume`)}+export const deleteDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return del<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}`)+}++export const archiveDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/status/archive`)+}++export const unArchiveDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/status/un_archive`)+}++export const enableDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/status/enable`)+}++export const disableDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/status/disable`)+}++export const syncDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/notion/sync`)+}++export const syncWebsite: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {+ return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/website-sync`)+}+export const preImportNotionPages: Fetcher<{ notion_info: DataSourceNotionWorkspace[] }, { url: string; datasetId?: string }> = ({ url, datasetId }) => {return get<{ notion_info: DataSourceNotionWorkspace[] }>(url, { params: { dataset_id: datasetId } })}@@ -170,6 +207,40 @@ export const modifyDocMetadata: Fetcher<CommonResponse, CommonDocReq & { body: {return put<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/metadata`, { body })}+// apis for segments in a document++export const fetchSegments: Fetcher<SegmentsResponse, CommonDocReq & { params: SegmentsQuery }> = ({ datasetId, documentId, params }) => {+ return get<SegmentsResponse>(`/datasets/${datasetId}/documents/${documentId}/segments`, { params })+}++export const enableSegment: Fetcher<CommonResponse, { datasetId: string; segmentId: string }> = ({ datasetId, segmentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/segments/${segmentId}/enable`)+}++export const disableSegment: Fetcher<CommonResponse, { datasetId: string; segmentId: string }> = ({ datasetId, segmentId }) => {+ return patch<CommonResponse>(`/datasets/${datasetId}/segments/${segmentId}/disable`)+}++export const updateSegment: Fetcher<{ data: SegmentDetailModel; doc_form: string }, { datasetId: string; documentId: string; segmentId: string; body: SegmentUpdater }> = ({ datasetId, documentId, segmentId, body }) => {+ return patch<{ data: SegmentDetailModel; doc_form: string }>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}`, { body })+}++export const addSegment: Fetcher<{ data: SegmentDetailModel; doc_form: string }, { datasetId: string; documentId: string; body: SegmentUpdater }> = ({ datasetId, documentId, body }) => {+ return post<{ data: SegmentDetailModel; doc_form: string }>(`/datasets/${datasetId}/documents/${documentId}/segment`, { body })+}++export const deleteSegment: Fetcher<CommonResponse, { datasetId: string; documentId: string; segmentId: string }> = ({ datasetId, documentId, segmentId }) => {+ return del<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}`)+}++export const segmentBatchImport: Fetcher<{ job_id: string; job_status: string }, { url: string; body: FormData }> = ({ url, body }) => {+ return post<{ job_id: string; job_status: string }>(url, { body }, { bodyStringify: false, deleteContentType: true })+}++export const checkSegmentBatchImportProgress: Fetcher<{ job_id: string; job_status: string }, { jobID: string }> = ({ jobID }) => {+ return get<{ job_id: string; job_status: string }>(`/datasets/batch_import_status/${jobID}`)+}+// hit testingexport const hitTesting: Fetcher<HitTestingResponse, { datasetId: string; queryText: string; retrieval_model: RetrievalConfig }> = ({ datasetId, queryText, retrieval_model }) => {return post<HitTestingResponse>(`/datasets/${datasetId}/hit-testing`, { body: { query: queryText, retrieval_model } })diff --git a/web/service/knowledge/use-create-dataset.ts b/web/service/knowledge/use-create-dataset.tsdeleted file mode 100644index ecd3f87a935..00000000000--- a/web/service/knowledge/use-create-dataset.ts+++ /dev/null@@ -1,223 +0,0 @@-import groupBy from 'lodash-es/groupBy'-import type { MutationOptions } from '@tanstack/react-query'-import { useMutation } from '@tanstack/react-query'-import { createDocument, createFirstDocument, fetchDefaultProcessRule, fetchFileIndexingEstimate } from '../datasets'-import { type IndexingType } from '@/app/components/datasets/create/step-two'-import type { ChunkingMode, CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, DataSourceType, FileIndexingEstimateResponse, IndexingEstimateParams, NotionInfo, ProcessRule, ProcessRuleResponse, createDocumentResponse } from '@/models/datasets'-import type { DataSourceProvider, NotionPage } from '@/models/common'--export const getNotionInfo = (- notionPages: NotionPage[],-) => {- const workspacesMap = groupBy(notionPages, 'workspace_id')- const workspaces = Object.keys(workspacesMap).map((workspaceId) => {- return {- workspaceId,- pages: workspacesMap[workspaceId],- }- })- return workspaces.map((workspace) => {- return {- workspace_id: workspace.workspaceId,- pages: workspace.pages.map((page) => {- const { page_id, page_name, page_icon, type } = page- return {- page_id,- page_name,- page_icon,- type,- }- }),- }- }) as NotionInfo[]-}--export const getWebsiteInfo = (- opts: {- websiteCrawlProvider: DataSourceProvider- websiteCrawlJobId: string- websitePages: CrawlResultItem[]- crawlOptions?: CrawlOptions- },-) => {- const { websiteCrawlProvider, websiteCrawlJobId, websitePages, crawlOptions } = opts- return {- provider: websiteCrawlProvider,- job_id: websiteCrawlJobId,- urls: websitePages.map(page => page.source_url),- only_main_content: crawlOptions?.only_main_content,- }-}--type GetFileIndexingEstimateParamsOptionBase = {- docForm: ChunkingMode- docLanguage: string- indexingTechnique: IndexingType- processRule: ProcessRule- dataset_id: string-}--type GetFileIndexingEstimateParamsOptionFile = GetFileIndexingEstimateParamsOptionBase & {- dataSourceType: DataSourceType.FILE- files: CustomFile[]-}--const getFileIndexingEstimateParamsForFile = ({- docForm,- docLanguage,- dataSourceType,- files,- indexingTechnique,- processRule,- dataset_id,-}: GetFileIndexingEstimateParamsOptionFile): IndexingEstimateParams => {- return {- info_list: {- data_source_type: dataSourceType,- file_info_list: {- file_ids: files.map(file => file.id) as string[],- },- },- indexing_technique: indexingTechnique,- process_rule: processRule,- doc_form: docForm,- doc_language: docLanguage,- dataset_id,- }-}--export const useFetchFileIndexingEstimateForFile = (- options: GetFileIndexingEstimateParamsOptionFile,- mutationOptions: MutationOptions<FileIndexingEstimateResponse> = {},-) => {- return useMutation({- mutationFn: async () => {- return fetchFileIndexingEstimate(getFileIndexingEstimateParamsForFile(options))- },- ...mutationOptions,- })-}--type GetFileIndexingEstimateParamsOptionNotion = GetFileIndexingEstimateParamsOptionBase & {- dataSourceType: DataSourceType.NOTION- notionPages: NotionPage[]-}--const getFileIndexingEstimateParamsForNotion = ({- docForm,- docLanguage,- dataSourceType,- notionPages,- indexingTechnique,- processRule,- dataset_id,-}: GetFileIndexingEstimateParamsOptionNotion): IndexingEstimateParams => {- return {- info_list: {- data_source_type: dataSourceType,- notion_info_list: getNotionInfo(notionPages),- },- indexing_technique: indexingTechnique,- process_rule: processRule,- doc_form: docForm,- doc_language: docLanguage,- dataset_id,- }-}--export const useFetchFileIndexingEstimateForNotion = (- options: GetFileIndexingEstimateParamsOptionNotion,- mutationOptions: MutationOptions<FileIndexingEstimateResponse> = {},-) => {- return useMutation({- mutationFn: async () => {- return fetchFileIndexingEstimate(getFileIndexingEstimateParamsForNotion(options))- },- ...mutationOptions,- })-}--type GetFileIndexingEstimateParamsOptionWeb = GetFileIndexingEstimateParamsOptionBase & {- dataSourceType: DataSourceType.WEB- websitePages: CrawlResultItem[]- crawlOptions?: CrawlOptions- websiteCrawlProvider: DataSourceProvider- websiteCrawlJobId: string-}--const getFileIndexingEstimateParamsForWeb = ({- docForm,- docLanguage,- dataSourceType,- websitePages,- crawlOptions,- websiteCrawlProvider,- websiteCrawlJobId,- indexingTechnique,- processRule,- dataset_id,-}: GetFileIndexingEstimateParamsOptionWeb): IndexingEstimateParams => {- return {- info_list: {- data_source_type: dataSourceType,- website_info_list: getWebsiteInfo({- websiteCrawlProvider,- websiteCrawlJobId,- websitePages,- crawlOptions,- }),- },- indexing_technique: indexingTechnique,- process_rule: processRule,- doc_form: docForm,- doc_language: docLanguage,- dataset_id,- }-}--export const useFetchFileIndexingEstimateForWeb = (- options: GetFileIndexingEstimateParamsOptionWeb,- mutationOptions: MutationOptions<FileIndexingEstimateResponse> = {},-) => {- return useMutation({- mutationFn: async () => {- return fetchFileIndexingEstimate(getFileIndexingEstimateParamsForWeb(options))- },- ...mutationOptions,- })-}--export const useCreateFirstDocument = (- mutationOptions: MutationOptions<createDocumentResponse, Error, CreateDocumentReq> = {},-) => {- return useMutation({- mutationFn: async (createDocumentReq: CreateDocumentReq,- ) => {- return createFirstDocument({ body: createDocumentReq })- },- ...mutationOptions,- })-}--export const useCreateDocument = (- datasetId: string,- mutationOptions: MutationOptions<createDocumentResponse, Error, CreateDocumentReq> = {},-) => {- return useMutation({- mutationFn: async (req: CreateDocumentReq) => {- return createDocument({ datasetId, body: req })- },- ...mutationOptions,- })-}--export const useFetchDefaultProcessRule = (- mutationOptions: MutationOptions<ProcessRuleResponse, Error, string> = {},-) => {- return useMutation({- mutationFn: async (url: string) => {- return fetchDefaultProcessRule({ url })- },- ...mutationOptions,- })-}diff --git a/web/service/knowledge/use-dateset.ts b/web/service/knowledge/use-dateset.tsdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.tsdeleted file mode 100644index 2b9981f22f3..00000000000--- a/web/service/knowledge/use-document.ts+++ /dev/null@@ -1,124 +0,0 @@-import {- useMutation,- useQuery,-} from '@tanstack/react-query'-import { del, get, patch } from '../base'-import { useInvalid } from '../use-base'-import type { MetadataType } from '../datasets'-import type { DocumentDetailResponse, SimpleDocumentDetail, UpdateDocumentBatchParams } from '@/models/datasets'-import { DocumentActionType } from '@/models/datasets'-import type { CommonResponse } from '@/models/common'--const NAME_SPACE = 'knowledge/document'--const useDocumentListKey = [NAME_SPACE, 'documentList']-export const useDocumentList = (payload: {- datasetId: string- query: {- keyword: string- page: number- limit: number- }-}) => {- const { query, datasetId } = payload- return useQuery<{ data: SimpleDocumentDetail[] }>({- queryKey: [...useDocumentListKey, datasetId, query],- queryFn: () => get<{ data: SimpleDocumentDetail[] }>(`/datasets/${datasetId}/documents`, {- params: query,- }),- })-}--const useAutoDisabledDocumentKey = [NAME_SPACE, 'autoDisabledDocument']-export const useAutoDisabledDocuments = (datasetId: string) => {- return useQuery({- queryKey: [...useAutoDisabledDocumentKey, datasetId],- queryFn: () => get<{ document_ids: string[] }>(`/datasets/${datasetId}/auto-disable-logs`),- })-}--export const useInvalidDisabledDocument = () => {- return useInvalid(useAutoDisabledDocumentKey)-}--const toBatchDocumentsIdParams = (documentIds: string[] | string) => {- const ids = Array.isArray(documentIds) ? documentIds : [documentIds]- return ids.map(id => `document_id=${id}`).join('&')-}--export const useDocumentBatchAction = (action: DocumentActionType) => {- return useMutation({- mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => {- return patch<CommonResponse>(`/datasets/${datasetId}/documents/status/${action}/batch?${toBatchDocumentsIdParams(documentId || documentIds!)}`)- },- })-}--export const useDocumentEnable = () => {- return useDocumentBatchAction(DocumentActionType.enable)-}--export const useDocumentDisable = () => {- return useDocumentBatchAction(DocumentActionType.disable)-}--export const useDocumentArchive = () => {- return useDocumentBatchAction(DocumentActionType.archive)-}--export const useDocumentUnArchive = () => {- return useDocumentBatchAction(DocumentActionType.unArchive)-}--export const useDocumentDelete = () => {- return useMutation({- mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => {- return del<CommonResponse>(`/datasets/${datasetId}/documents?${toBatchDocumentsIdParams(documentId || documentIds!)}`)- },- })-}--export const useSyncDocument = () => {- return useMutation({- mutationFn: ({ datasetId, documentId }: UpdateDocumentBatchParams) => {- return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/notion/sync`)- },- })-}--export const useSyncWebsite = () => {- return useMutation({- mutationFn: ({ datasetId, documentId }: UpdateDocumentBatchParams) => {- return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/website-sync`)- },- })-}--const useDocumentDetailKey = [NAME_SPACE, 'documentDetail']-export const useDocumentDetail = (payload: {- datasetId: string- documentId: string- params: { metadata: MetadataType }-}) => {- const { datasetId, documentId, params } = payload- return useQuery<DocumentDetailResponse>({- queryKey: [...useDocumentDetailKey, 'withoutMetaData', datasetId, documentId],- queryFn: () => get<DocumentDetailResponse>(`/datasets/${datasetId}/documents/${documentId}`, { params }),- })-}--export const useDocumentMetadata = (payload: {- datasetId: string- documentId: string- params: { metadata: MetadataType }-}) => {- const { datasetId, documentId, params } = payload- return useQuery<DocumentDetailResponse>({- queryKey: [...useDocumentDetailKey, 'withMetaData', datasetId, documentId],- queryFn: () => get<DocumentDetailResponse>(`/datasets/${datasetId}/documents/${documentId}`, { params }),- })-}--export const useInvalidDocumentDetailKey = () => {- return useInvalid(useDocumentDetailKey)-}diff --git a/web/service/knowledge/use-hit-testing.ts b/web/service/knowledge/use-hit-testing.tsdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/web/service/knowledge/use-import.ts b/web/service/knowledge/use-import.tsdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/web/service/knowledge/use-segment.ts b/web/service/knowledge/use-segment.tsdeleted file mode 100644index 749bbf2d286..00000000000--- a/web/service/knowledge/use-segment.ts+++ /dev/null@@ -1,169 +0,0 @@-import { useMutation, useQuery } from '@tanstack/react-query'-import { del, get, patch, post } from '../base'-import type { CommonResponse } from '@/models/common'-import type {- BatchImportResponse,- ChildChunkDetail,- ChildSegmentsResponse,- ChunkingMode,- SegmentDetailModel,- SegmentUpdater,- SegmentsResponse,-} from '@/models/datasets'--const NAME_SPACE = 'segment'--export const useSegmentListKey = [NAME_SPACE, 'chunkList']--export const useSegmentList = (- payload: {- datasetId: string- documentId: string- params: {- page: number- limit: number- keyword: string- enabled: boolean | 'all'- }- },- disable?: boolean,-) => {- const { datasetId, documentId, params } = payload- const { page, limit, keyword, enabled } = params- return useQuery<SegmentsResponse>({- queryKey: [...useSegmentListKey, datasetId, documentId, page, limit, keyword, enabled],- queryFn: () => {- return get<SegmentsResponse>(`/datasets/${datasetId}/documents/${documentId}/segments`, { params })- },- enabled: !disable,- })-}--export const useUpdateSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'update'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentId: string; body: SegmentUpdater }) => {- const { datasetId, documentId, segmentId, body } = payload- return patch<{ data: SegmentDetailModel; doc_form: ChunkingMode }>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}`, { body })- },- })-}--export const useAddSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'add'],- mutationFn: (payload: { datasetId: string; documentId: string; body: SegmentUpdater }) => {- const { datasetId, documentId, body } = payload- return post<{ data: SegmentDetailModel; doc_form: ChunkingMode }>(`/datasets/${datasetId}/documents/${documentId}/segment`, { body })- },- })-}--export const useEnableSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'enable'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentIds: string[] }) => {- const { datasetId, documentId, segmentIds } = payload- const query = segmentIds.map(id => `segment_id=${id}`).join('&')- return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segment/enable?${query}`)- },- })-}--export const useDisableSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'disable'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentIds: string[] }) => {- const { datasetId, documentId, segmentIds } = payload- const query = segmentIds.map(id => `segment_id=${id}`).join('&')- return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segment/disable?${query}`)- },- })-}--export const useDeleteSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'delete'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentIds: string[] }) => {- const { datasetId, documentId, segmentIds } = payload- const query = segmentIds.map(id => `segment_id=${id}`).join('&')- return del<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segments?${query}`)- },- })-}--export const useChildSegmentListKey = [NAME_SPACE, 'childChunkList']--export const useChildSegmentList = (- payload: {- datasetId: string- documentId: string- segmentId: string- params: {- page: number- limit: number- keyword: string- }- },- disable?: boolean,-) => {- const { datasetId, documentId, segmentId, params } = payload- const { page, limit, keyword } = params- return useQuery({- queryKey: [...useChildSegmentListKey, datasetId, documentId, segmentId, page, limit, keyword],- queryFn: () => {- return get<ChildSegmentsResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}/child_chunks`, { params })- },- enabled: !disable,- })-}--export const useDeleteChildSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'childChunk', 'delete'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentId: string; childChunkId: string }) => {- const { datasetId, documentId, segmentId, childChunkId } = payload- return del<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}/child_chunks/${childChunkId}`)- },- })-}--export const useAddChildSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'childChunk', 'add'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentId: string; body: { content: string } }) => {- const { datasetId, documentId, segmentId, body } = payload- return post<{ data: ChildChunkDetail }>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}/child_chunks`, { body })- },- })-}--export const useUpdateChildSegment = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'childChunk', 'update'],- mutationFn: (payload: { datasetId: string; documentId: string; segmentId: string; childChunkId: string; body: { content: string } }) => {- const { datasetId, documentId, segmentId, childChunkId, body } = payload- return patch<{ data: ChildChunkDetail }>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}/child_chunks/${childChunkId}`, { body })- },- })-}--export const useSegmentBatchImport = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'batchImport'],- mutationFn: (payload: { url: string; body: FormData }) => {- const { url, body } = payload- return post<BatchImportResponse>(url, { body }, { bodyStringify: false, deleteContentType: true })- },- })-}--export const useCheckSegmentBatchImportProgress = () => {- return useMutation({- mutationKey: [NAME_SPACE, 'batchImport', 'checkProgress'],- mutationFn: (payload: { jobID: string }) => {- const { jobID } = payload- return get<BatchImportResponse>(`/datasets/batch_import_status/${jobID}`)- },- })-}diff --git a/web/tailwind.config.js b/web/tailwind.config.jsindex 0da4968a7f4..b4e2263167f 100644--- a/web/tailwind.config.js+++ b/web/tailwind.config.js@@ -1,7 +1,6 @@-import tailwindThemeVarDefine from './themes/tailwind-theme-var-define'-/** @type {import('tailwindcss').Config} */-const config = {+import tailwindThemeVarDefine from './themes/tailwind-theme-var-define'+module.exports = {content: ['./app/**/*.{js,ts,jsx,tsx}','./components/**/*.{js,ts,jsx,tsx}',@@ -82,11 +81,6 @@ const config = {'xl': '0px 8px 8px -4px rgba(16, 24, 40, 0.03), 0px 20px 24px -4px rgba(16, 24, 40, 0.08)','2xl': '0px 24px 48px -12px rgba(16, 24, 40, 0.18)','3xl': '0px 32px 64px -12px rgba(16, 24, 40, 0.14)',- 'status-indicator-green-shadow': '0px 2px 6px 0px var(--color-components-badge-status-light-success-halo), 0px 0px 0px 1px var(--color-components-badge-status-light-border-outer)',- 'status-indicator-warning-shadow': '0px 2px 6px 0px var(--color-components-badge-status-light-warning-halo), 0px 0px 0px 1px var(--color-components-badge-status-light-border-outer)',- 'status-indicator-red-shadow': '0px 2px 6px 0px var(--color-components-badge-status-light-error-halo), 0px 0px 0px 1px var(--color-components-badge-status-light-border-outer)',- 'status-indicator-blue-shadow': '0px 2px 6px 0px var(--color-components-badge-status-light-normal-halo), 0px 0px 0px 1px var(--color-components-badge-status-light-border-outer)',- 'status-indicator-gray-shadow': '0px 1px 2px 0px var(--color-components-badge-status-light-disabled-halo), 0px 0px 0px 1px var(--color-components-badge-status-light-border-outer)',},opacity: {2: '0.02',@@ -99,17 +93,6 @@ const config = {'chatbot-bg': 'var(--color-chatbot-bg)','chat-bubble-bg': 'var(--color-chat-bubble-bg)','workflow-process-bg': 'var(--color-workflow-process-bg)',- 'dataset-chunk-process-success-bg': 'var(--color-dataset-chunk-process-success-bg)',- 'dataset-chunk-process-error-bg': 'var(--color-dataset-chunk-process-error-bg)',- 'dataset-chunk-detail-card-hover-bg': 'var(--color-dataset-chunk-detail-card-hover-bg)',- 'dataset-child-chunk-expand-btn-bg': 'var(--color-dataset-child-chunk-expand-btn-bg)',- 'dataset-option-card-blue-gradient': 'var(--color-dataset-option-card-blue-gradient)',- 'dataset-option-card-purple-gradient': 'var(--color-dataset-option-card-purple-gradient)',- 'dataset-option-card-orange-gradient': 'var(--color-dataset-option-card-orange-gradient)',- 'dataset-chunk-list-mask-bg': 'var(--color-dataset-chunk-list-mask-bg)',- },- lineClamp: {- '20': '20','mask-top2bottom-gray-50-to-transparent': 'var(--mask-top2bottom-gray-50-to-transparent)',},},@@ -122,5 +105,3 @@ const config = {preflight: false,},}--export default configdiff --git a/web/themes/manual-dark.css b/web/themes/manual-dark.cssindex 6d4c5f39080..4052e5566de 100644--- a/web/themes/manual-dark.css+++ b/web/themes/manual-dark.css@@ -19,14 +19,6 @@ html[data-theme="dark"] {rgba(34, 34, 37, 0.9) -0.1%,rgba(29, 29, 32, 0.9) 98.26%);- --color-dataset-chunk-process-success-bg: linear-gradient(92deg, rgba(23, 178, 106, 0.30) 0%, rgba(0, 0, 0, 0.00) 100%);- --color-dataset-chunk-process-error-bg: linear-gradient(92deg, rgba(240, 68, 56, 0.30) 0%, rgba(0, 0, 0, 0.00) 100%);- --color-dataset-chunk-detail-card-hover-bg: linear-gradient(180deg, #1D1D20 0%, #222225 100%);- --color-dataset-child-chunk-expand-btn-bg: linear-gradient(90deg, rgba(24, 24, 27, 0.25) 0%, rgba(24, 24, 27, 0.04) 100%);- --color-dataset-option-card-blue-gradient: linear-gradient(90deg, #24252E 0%, #1E1E21 100%);- --color-dataset-option-card-purple-gradient: linear-gradient(90deg, #25242E 0%, #1E1E21 100%);- --color-dataset-option-card-orange-gradient: linear-gradient(90deg, #2B2322 0%, #1E1E21 100%);- --color-dataset-chunk-list-mask-bg: linear-gradient(180deg, rgba(34, 34, 37, 0.00) 0%, #222225 100%);--mask-top2bottom-gray-50-to-transparent: linear-gradient(180deg,rgba(24, 24, 27, 0.08) 0%,diff --git a/web/themes/manual-light.css b/web/themes/manual-light.cssindex 501f9f1d1fd..303963c55da 100644--- a/web/themes/manual-light.css+++ b/web/themes/manual-light.css@@ -19,14 +19,6 @@ html[data-theme="light"] {rgba(249, 250, 251, 0.9) -0.1%,rgba(242, 244, 247, 0.9) 98.26%);- --color-dataset-chunk-process-success-bg: linear-gradient(92deg, rgba(23, 178, 106, 0.25) 0%, rgba(255, 255, 255, 0.00) 100%);- --color-dataset-chunk-process-error-bg: linear-gradient(92deg, rgba(240, 68, 56, 0.25) 0%, rgba(255, 255, 255, 0.00) 100%);- --color-dataset-chunk-detail-card-hover-bg: linear-gradient(180deg, #F2F4F7 0%, #F9FAFB 100%);- --color-dataset-child-chunk-expand-btn-bg: linear-gradient(90deg, rgba(200, 206, 218, 0.20) 0%, rgba(200, 206, 218, 0.04) 100%);- --color-dataset-option-card-blue-gradient: linear-gradient(90deg, #F2F4F7 0%, #F9FAFB 100%);- --color-dataset-option-card-purple-gradient: linear-gradient(90deg, #F0EEFA 0%, #F9FAFB 100%);- --color-dataset-option-card-orange-gradient: linear-gradient(90deg, #F8F2EE 0%, #F9FAFB 100%);- --color-dataset-chunk-list-mask-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.00) 0%, #FCFCFD 100%);--mask-top2bottom-gray-50-to-transparent: linear-gradient(180deg,rgba(200, 206, 218, 0.2) 0%,diff --git a/web/utils/time.ts b/web/utils/time.tsdeleted file mode 100644index ff2e38321fd..00000000000--- a/web/utils/time.ts+++ /dev/null@@ -1,12 +0,0 @@-import dayjs, { type ConfigType } from 'dayjs'-import utc from 'dayjs/plugin/utc'--dayjs.extend(utc)--export const isAfter = (date: ConfigType, compare: ConfigType) => {- return dayjs(date).isAfter(dayjs(compare))-}--export const formatTime = ({ date, dateFormat }: { date: ConfigType; dateFormat: string }) => {- return dayjs(date).format(dateFormat)-}diff --git a/web/yarn.lock b/web/yarn.lockindex 339f47c236e..c9590d6b066 100644--- a/web/yarn.lock+++ b/web/yarn.lock@@ -8748,11 +8748,6 @@ [email protected], lilconfig@^2.0.5, lilconfig@^2.1.0:resolved "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz"integrity sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==-line-clamp@^1.0.0:- version "1.0.0"- resolved "https://registry.yarnpkg.com/line-clamp/-/line-clamp-1.0.0.tgz#e0216489a599e989215595080b912c90ba09192c"- integrity sha512-dCDlvMj572RIRBQ3x9aIX0DTdt2St1bMdpi64jVTAi5vqBck7wf+J97//+J7+pS80rFJaYa8HiyXCTp0flpnBA==-lines-and-columns@^1.1.6:version "1.2.4"resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz"@@ -11771,11 +11766,6 @@ sharp@^0.33.2, sharp@^0.33.3:"@img/sharp-win32-ia32" "0.33.5""@img/sharp-win32-x64" "0.33.5"-shave@^5.0.4:- version "5.0.4"- resolved "https://registry.yarnpkg.com/shave/-/shave-5.0.4.tgz#88a696c5d7f4959a875c6e904a38dd054ff95d8d"- integrity sha512-AnvEI1wM2rQmrwCl364LVLLhzCzSHJ7DQmdd+fHJTnNzbD2mjsUAOcxWLLYKam7Q63skwyQf2CB2TCdJ2O5c8w==-shebang-command@^2.0.0:version "2.0.0"resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz"