| | |
| | | import cn from '@/utils/classnames' |
| | | import Divider from '@/app/components/base/divider' |
| | | import { ToastContext } from '@/app/components/base/toast' |
| | | import type { IndexingStatusResponse } from '@/models/datasets' |
| | | import { ProcessMode, type ProcessRuleResponse } from '@/models/datasets' |
| | | import type { CommonResponse } from '@/models/common' |
| | | import { asyncRunSafe, sleep } from '@/utils' |
| | |
| | | const localDatasetId = dstId ?? datasetId |
| | | const localDocumentId = docId ?? documentId |
| | | |
| | | const [indexingStatusDetail, setIndexingStatusDetail] = useState<IndexingStatusResponse | null>(null) |
| | | const [indexingStatusDetail, setIndexingStatusDetail] = useState<any>(null) |
| | | const fetchIndexingStatus = async () => { |
| | | const status = await doFetchIndexingStatus({ datasetId: localDatasetId, documentId: localDocumentId }) |
| | | setIndexingStatusDetail(status) |
| | |
| | | await sleep(2500) |
| | | await startQueryStatus() |
| | | } |
| | | catch { |
| | | catch (e) { |
| | | await sleep(2500) |
| | | await startQueryStatus() |
| | | } |
| | |
| | | |
| | | return ( |
| | | <> |
| | | <div className='flex flex-col gap-y-2 px-16 py-12'> |
| | | <div className='flex h-6 items-center gap-x-1'> |
| | | {isEmbedding && <RiLoader2Line className='h-4 w-4 animate-spin text-text-secondary' />} |
| | | <span className='system-md-semibold-uppercase grow text-text-secondary'> |
| | | <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')} |
| | |
| | | {isEmbedding && ( |
| | | <button |
| | | type='button' |
| | | className={`flex items-center gap-x-1 rounded-md border-[0.5px] |
| | | border-components-button-secondary-border bg-components-button-secondary-bg px-1.5 py-1 shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]`} |
| | | 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='h-3.5 w-3.5 text-components-button-secondary-text' /> |
| | | <span className='system-xs-medium pr-[3px] text-components-button-secondary-text'> |
| | | <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> |
| | |
| | | {isEmbeddingPaused && ( |
| | | <button |
| | | type='button' |
| | | className={`flex items-center gap-x-1 rounded-md border-[0.5px] |
| | | border-components-button-secondary-border bg-components-button-secondary-bg px-1.5 py-1 shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]`} |
| | | 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='h-3.5 w-3.5 text-components-button-secondary-text' /> |
| | | <span className='system-xs-medium pr-[3px] text-components-button-secondary-text'> |
| | | <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> |
| | |
| | | </div> |
| | | {/* progress bar */} |
| | | <div className={cn( |
| | | 'flex h-2 w-full items-center overflow-hidden rounded-md border border-components-progress-bar-border', |
| | | '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 |
| | |
| | | style={{ width: `${percent}%` }} |
| | | /> |
| | | </div> |
| | | <div className={'flex w-full items-center'}> |
| | | <span className='system-xs-medium text-text-secondary'> |
| | | <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> |
| | | </div> |