| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import type { FC } from 'react' | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | import React, { useMemo, useState } from 'react' | 
					
						
							|  |  |  | import { createContext, useContext, useContextSelector } from 'use-context-selector' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							|  |  |  | import { useRouter } from 'next/navigation' | 
					
						
							| 
									
										
										
										
											2025-04-14 15:45:23 +08:00
										 |  |  | import { RiArrowLeftLine, RiLayoutLeft2Line, RiLayoutRight2Line } from '@remixicon/react' | 
					
						
							| 
									
										
										
										
											2025-05-21 16:37:02 +08:00
										 |  |  | import Operations from '../operations' | 
					
						
							|  |  |  | import StatusItem from '../status-item' | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | import DocumentPicker from '../../common/document-picker' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import Completed from './completed' | 
					
						
							|  |  |  | import Embedding from './embedding' | 
					
						
							| 
									
										
										
										
											2025-03-18 11:01:06 +08:00
										 |  |  | import Metadata from '@/app/components/datasets/metadata/metadata-document' | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  | import SegmentAdd, { ProcessStatus } from './segment-add' | 
					
						
							|  |  |  | import BatchModal from './batch-modal' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | import style from './style.module.css' | 
					
						
							| 
									
										
										
										
											2024-07-09 15:05:40 +08:00
										 |  |  | import cn from '@/utils/classnames' | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  | import Divider from '@/app/components/base/divider' | 
					
						
							|  |  |  | import Loading from '@/app/components/base/loading' | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  | import { ToastContext } from '@/app/components/base/toast' | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | import type { ChunkingMode, ParentMode, ProcessMode } from '@/models/datasets' | 
					
						
							| 
									
										
										
										
											2023-08-30 17:27:19 +08:00
										 |  |  | import { useDatasetDetailContext } from '@/context/dataset-detail' | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  | import FloatRightContainer from '@/app/components/base/float-right-container' | 
					
						
							|  |  |  | import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  | import { useCheckSegmentBatchImportProgress, useChildSegmentListKey, useSegmentBatchImport, useSegmentListKey } from '@/service/knowledge/use-segment' | 
					
						
							| 
									
										
										
										
											2025-03-10 15:34:40 +08:00
										 |  |  | import { useDocumentDetail, useDocumentMetadata, useInvalidDocumentList } from '@/service/knowledge/use-document' | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  | import { useInvalid } from '@/service/use-base' | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | 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) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | type DocumentTitleProps = { | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |   datasetId: string | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |   extension?: string | 
					
						
							|  |  |  |   name?: string | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |   processMode?: ProcessMode | 
					
						
							|  |  |  |   parent_mode?: ParentMode | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |   iconCls?: string | 
					
						
							|  |  |  |   textCls?: string | 
					
						
							|  |  |  |   wrapperCls?: string | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | export const DocumentTitle: FC<DocumentTitleProps> = ({ datasetId, extension, name, processMode, parent_mode, wrapperCls }) => { | 
					
						
							|  |  |  |   const router = useRouter() | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <div className={cn('flex flex-1 items-center justify-start', wrapperCls)}> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |       <DocumentPicker | 
					
						
							|  |  |  |         datasetId={datasetId} | 
					
						
							|  |  |  |         value={{ | 
					
						
							|  |  |  |           name, | 
					
						
							|  |  |  |           extension, | 
					
						
							|  |  |  |           processMode, | 
					
						
							|  |  |  |           parentMode: parent_mode, | 
					
						
							|  |  |  |         }} | 
					
						
							|  |  |  |         onChange={(doc) => { | 
					
						
							|  |  |  |           router.push(`/datasets/${datasetId}/documents/${doc.id}`) | 
					
						
							|  |  |  |         }} | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type Props = { | 
					
						
							|  |  |  |   datasetId: string | 
					
						
							|  |  |  |   documentId: string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => { | 
					
						
							|  |  |  |   const router = useRouter() | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   const { t } = useTranslation() | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const media = useBreakpoints() | 
					
						
							|  |  |  |   const isMobile = media === MediaType.mobile | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   const { notify } = useContext(ToastContext) | 
					
						
							| 
									
										
										
										
											2023-08-30 17:27:19 +08:00
										 |  |  |   const { dataset } = useDatasetDetailContext() | 
					
						
							|  |  |  |   const embeddingAvailable = !!dataset?.embedding_available | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |   const [showMetadata, setShowMetadata] = useState(!isMobile) | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   const [newSegmentModalVisible, setNewSegmentModalVisible] = useState(false) | 
					
						
							|  |  |  |   const [batchModalVisible, setBatchModalVisible] = useState(false) | 
					
						
							|  |  |  |   const [importStatus, setImportStatus] = useState<ProcessStatus | string>() | 
					
						
							|  |  |  |   const showNewSegmentModal = () => setNewSegmentModalVisible(true) | 
					
						
							|  |  |  |   const showBatchModal = () => setBatchModalVisible(true) | 
					
						
							|  |  |  |   const hideBatchModal = () => setBatchModalVisible(false) | 
					
						
							|  |  |  |   const resetProcessStatus = () => setImportStatus('') | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const { mutateAsync: checkSegmentBatchImportProgress } = useCheckSegmentBatchImportProgress() | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   const checkProcess = async (jobID: string) => { | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     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}` : ''}` }) | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const { mutateAsync: segmentBatchImport } = useSegmentBatchImport() | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   const runBatch = async (csv: File) => { | 
					
						
							|  |  |  |     const formData = new FormData() | 
					
						
							|  |  |  |     formData.append('file', csv) | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     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}` : ''}` }) | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |   const { data: documentDetail, error, refetch: detailMutate } = useDocumentDetail({ | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     datasetId, | 
					
						
							|  |  |  |     documentId, | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     params: { metadata: 'without' }, | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-14 11:27:14 +08:00
										 |  |  |   const { data: documentMetadata } = useDocumentMetadata({ | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     datasetId, | 
					
						
							|  |  |  |     documentId, | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     params: { metadata: 'only' }, | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const backToPrev = () => { | 
					
						
							|  |  |  |     router.push(`/datasets/${datasetId}/documents`) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const isDetailLoading = !documentDetail && !error | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const embedding = ['queuing', 'indexing', 'paused'].includes((documentDetail?.display_status || '').toLowerCase()) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  |   const invalidChunkList = useInvalid(useSegmentListKey) | 
					
						
							|  |  |  |   const invalidChildChunkList = useInvalid(useChildSegmentListKey) | 
					
						
							| 
									
										
										
										
											2025-03-10 15:34:40 +08:00
										 |  |  |   const invalidDocumentList = useInvalidDocumentList(datasetId) | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |   const handleOperate = (operateName?: string) => { | 
					
						
							| 
									
										
										
										
											2025-03-10 15:34:40 +08:00
										 |  |  |     invalidDocumentList() | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  |     if (operateName === 'delete') { | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |       backToPrev() | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |       detailMutate() | 
					
						
							| 
									
										
										
										
											2025-03-10 15:34:40 +08:00
										 |  |  |       // If operation is not rename, refresh the chunk list after 5 seconds
 | 
					
						
							|  |  |  |       if (operateName) { | 
					
						
							|  |  |  |         setTimeout(() => { | 
					
						
							|  |  |  |           invalidChunkList() | 
					
						
							|  |  |  |           invalidChildChunkList() | 
					
						
							|  |  |  |         }, 5000) | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2025-01-02 16:07:21 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |   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]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     <DocumentContext.Provider value={{ | 
					
						
							|  |  |  |       datasetId, | 
					
						
							|  |  |  |       documentId, | 
					
						
							|  |  |  |       docForm: documentDetail?.doc_form || '', | 
					
						
							|  |  |  |       mode, | 
					
						
							|  |  |  |       parentMode, | 
					
						
							|  |  |  |     }}> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |       <div className='flex h-full flex-col bg-background-default'> | 
					
						
							|  |  |  |         <div className='flex min-h-16 flex-wrap items-center justify-between border-b border-b-divider-subtle py-2.5 pl-3 pr-4'> | 
					
						
							|  |  |  |           <div onClick={backToPrev} className={'flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full hover:bg-components-button-tertiary-bg'}> | 
					
						
							|  |  |  |             <RiArrowLeftLine className='h-4 w-4 text-components-button-ghost-text hover:text-text-tertiary' /> | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |           <DocumentTitle | 
					
						
							|  |  |  |             datasetId={datasetId} | 
					
						
							|  |  |  |             extension={documentDetail?.data_source_info?.upload_file?.extension} | 
					
						
							|  |  |  |             name={documentDetail?.name} | 
					
						
							|  |  |  |             wrapperCls='mr-2' | 
					
						
							|  |  |  |             parent_mode={parentMode} | 
					
						
							|  |  |  |             processMode={mode} | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |           <div className='flex flex-wrap items-center'> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |             {embeddingAvailable && documentDetail && !documentDetail.archived && !isFullDocMode && ( | 
					
						
							|  |  |  |               <> | 
					
						
							|  |  |  |                 <SegmentAdd | 
					
						
							|  |  |  |                   importStatus={importStatus} | 
					
						
							|  |  |  |                   clearProcessStatus={resetProcessStatus} | 
					
						
							|  |  |  |                   showNewSegmentModal={showNewSegmentModal} | 
					
						
							|  |  |  |                   showBatchModal={showBatchModal} | 
					
						
							|  |  |  |                   embedding={embedding} | 
					
						
							|  |  |  |                 /> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |                 <Divider type='vertical' className='!mx-3 !h-[14px] !bg-divider-regular' /> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |               </> | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |             )} | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |             <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} | 
					
						
							|  |  |  |             /> | 
					
						
							| 
									
										
										
										
											2025-05-21 16:37:02 +08:00
										 |  |  |             <Operations | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |               scene='detail' | 
					
						
							|  |  |  |               embeddingAvailable={embeddingAvailable} | 
					
						
							|  |  |  |               detail={{ | 
					
						
							| 
									
										
										
										
											2024-06-04 15:10:34 +08:00
										 |  |  |                 name: documentDetail?.name || '', | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |                 enabled: documentDetail?.enabled || false, | 
					
						
							|  |  |  |                 archived: documentDetail?.archived || false, | 
					
						
							|  |  |  |                 id: documentId, | 
					
						
							|  |  |  |                 data_source_type: documentDetail?.data_source_type || '', | 
					
						
							|  |  |  |                 doc_form: documentDetail?.doc_form || '', | 
					
						
							|  |  |  |               }} | 
					
						
							|  |  |  |               datasetId={datasetId} | 
					
						
							|  |  |  |               onUpdate={handleOperate} | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |               className='!w-[200px]' | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |             /> | 
					
						
							|  |  |  |             <button | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |               className={style.layoutRightIcon} | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |               onClick={() => setShowMetadata(!showMetadata)} | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |             > | 
					
						
							|  |  |  |               { | 
					
						
							|  |  |  |                 showMetadata | 
					
						
							| 
									
										
										
										
											2025-04-14 15:45:23 +08:00
										 |  |  |                   ? <RiLayoutLeft2Line className='h-4 w-4 text-components-button-secondary-text' /> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |                   : <RiLayoutRight2Line className='h-4 w-4 text-components-button-secondary-text' /> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |               } | 
					
						
							|  |  |  |             </button> | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         <div className='flex flex-1 flex-row' style={{ height: 'calc(100% - 4rem)' }}> | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |           {isDetailLoading | 
					
						
							|  |  |  |             ? <Loading type='app' /> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |             : <div className={cn('flex h-full min-w-0 grow flex-col', | 
					
						
							|  |  |  |               embedding ? '' : isFullDocMode ? 'relative pl-11 pr-11 pt-4' : 'relative pl-5 pr-11 pt-3', | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |             )}> | 
					
						
							| 
									
										
										
										
											2023-07-28 20:47:15 +08:00
										 |  |  |               {embedding | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |                 ? <Embedding | 
					
						
							|  |  |  |                   detailUpdate={detailMutate} | 
					
						
							|  |  |  |                   indexingType={dataset?.indexing_technique} | 
					
						
							|  |  |  |                   retrievalMethod={dataset?.retrieval_model_dict?.search_method} | 
					
						
							|  |  |  |                 /> | 
					
						
							| 
									
										
										
										
											2023-07-28 20:47:15 +08:00
										 |  |  |                 : <Completed | 
					
						
							| 
									
										
										
										
											2023-08-30 17:27:19 +08:00
										 |  |  |                   embeddingAvailable={embeddingAvailable} | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |                   showNewSegmentModal={newSegmentModalVisible} | 
					
						
							|  |  |  |                   onNewSegmentModalChange={setNewSegmentModalVisible} | 
					
						
							|  |  |  |                   importStatus={importStatus} | 
					
						
							|  |  |  |                   archived={documentDetail?.archived} | 
					
						
							| 
									
										
										
										
											2023-07-28 20:47:15 +08:00
										 |  |  |                 /> | 
					
						
							|  |  |  |               } | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |             </div> | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2025-04-22 09:59:14 +08:00
										 |  |  |           <FloatRightContainer showClose isOpen={showMetadata} onClose={() => setShowMetadata(false)} isMobile={isMobile} panelClassName='!justify-start' footer={null}> | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |             <Metadata | 
					
						
							| 
									
										
										
										
											2025-03-18 11:01:06 +08:00
										 |  |  |               className='mr-2 mt-3' | 
					
						
							|  |  |  |               datasetId={datasetId} | 
					
						
							|  |  |  |               documentId={documentId} | 
					
						
							| 
									
										
										
										
											2023-11-27 11:47:48 +08:00
										 |  |  |               docDetail={{ ...documentDetail, ...documentMetadata, doc_type: documentMetadata?.doc_type === 'others' ? '' : documentMetadata?.doc_type } as any} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           </FloatRightContainer> | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |         <BatchModal | 
					
						
							|  |  |  |           isShow={batchModalVisible} | 
					
						
							|  |  |  |           onCancel={hideBatchModal} | 
					
						
							|  |  |  |           onConfirm={runBatch} | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |           docForm={documentDetail?.doc_form as ChunkingMode} | 
					
						
							| 
									
										
										
										
											2023-08-18 17:37:31 +08:00
										 |  |  |         /> | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     </DocumentContext.Provider> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default DocumentDetail |