|
|
|
@ -1,12 +1,11 @@
|
|
|
|
import React, { useMemo, useState } from 'react'
|
|
|
|
import React, { useState } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { PreviewContainer } from '../../../preview/container'
|
|
|
|
import { PreviewContainer } from '../../../preview/container'
|
|
|
|
import { PreviewHeader } from '../../../preview/header'
|
|
|
|
import { PreviewHeader } from '../../../preview/header'
|
|
|
|
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
|
|
|
|
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
|
|
|
|
import type { CrawlResultItem, CustomFile, DocumentItem, FileIndexingEstimateResponse } from '@/models/datasets'
|
|
|
|
import type { CrawlResultItem, CustomFile, DocumentItem, FileIndexingEstimateResponse } from '@/models/datasets'
|
|
|
|
import { ChunkingMode, DataSourceType } from '@/models/datasets'
|
|
|
|
import { ChunkingMode } from '@/models/datasets'
|
|
|
|
import type { NotionPage } from '@/models/common'
|
|
|
|
import type { NotionPage } from '@/models/common'
|
|
|
|
import { DataSourceProvider } from '@/models/common'
|
|
|
|
|
|
|
|
import PreviewDocumentPicker from '../../../common/document-picker/preview-document-picker'
|
|
|
|
import PreviewDocumentPicker from '../../../common/document-picker/preview-document-picker'
|
|
|
|
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
|
|
|
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
|
|
|
import { ChunkContainer, QAPreview } from '../../../chunk'
|
|
|
|
import { ChunkContainer, QAPreview } from '../../../chunk'
|
|
|
|
@ -16,6 +15,7 @@ import { SkeletonContainer, SkeletonPoint, SkeletonRectangle, SkeletonRow } from
|
|
|
|
import { RiSearchEyeLine } from '@remixicon/react'
|
|
|
|
import { RiSearchEyeLine } from '@remixicon/react'
|
|
|
|
import Badge from '@/app/components/base/badge'
|
|
|
|
import Badge from '@/app/components/base/badge'
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
|
|
|
|
import { DatasourceType } from '@/models/pipeline'
|
|
|
|
|
|
|
|
|
|
|
|
type ChunkPreviewProps = {
|
|
|
|
type ChunkPreviewProps = {
|
|
|
|
datasource: Datasource
|
|
|
|
datasource: Datasource
|
|
|
|
@ -45,12 +45,7 @@ const ChunkPreview = ({
|
|
|
|
const [previewNotionPage, setPreviewNotionPage] = useState<NotionPage>(notionPages[0])
|
|
|
|
const [previewNotionPage, setPreviewNotionPage] = useState<NotionPage>(notionPages[0])
|
|
|
|
const [previewWebsitePage, setPreviewWebsitePage] = useState<CrawlResultItem>(websitePages[0])
|
|
|
|
const [previewWebsitePage, setPreviewWebsitePage] = useState<CrawlResultItem>(websitePages[0])
|
|
|
|
|
|
|
|
|
|
|
|
const dataSourceType = useMemo(() => {
|
|
|
|
const dataSourceType = datasource?.type
|
|
|
|
const type = datasource.type
|
|
|
|
|
|
|
|
if (type === DataSourceProvider.fireCrawl || type === DataSourceProvider.jinaReader || type === DataSourceProvider.waterCrawl)
|
|
|
|
|
|
|
|
return DataSourceType.WEB
|
|
|
|
|
|
|
|
return type
|
|
|
|
|
|
|
|
}, [datasource.type])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<PreviewContainer
|
|
|
|
<PreviewContainer
|
|
|
|
@ -58,7 +53,7 @@ const ChunkPreview = ({
|
|
|
|
title={t('datasetCreation.stepTwo.preview')}
|
|
|
|
title={t('datasetCreation.stepTwo.preview')}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className='flex items-center gap-1'>
|
|
|
|
<div className='flex items-center gap-1'>
|
|
|
|
{dataSourceType === DataSourceType.FILE
|
|
|
|
{dataSourceType === DatasourceType.localFile
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
files={files as Array<Required<CustomFile>>}
|
|
|
|
files={files as Array<Required<CustomFile>>}
|
|
|
|
onChange={(selected) => {
|
|
|
|
onChange={(selected) => {
|
|
|
|
@ -67,7 +62,7 @@ const ChunkPreview = ({
|
|
|
|
value={previewFile}
|
|
|
|
value={previewFile}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{dataSourceType === DataSourceType.NOTION
|
|
|
|
{dataSourceType === DatasourceType.onlineDocument
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
files={
|
|
|
|
files={
|
|
|
|
notionPages.map(page => ({
|
|
|
|
notionPages.map(page => ({
|
|
|
|
@ -87,7 +82,7 @@ const ChunkPreview = ({
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{dataSourceType === DataSourceType.WEB
|
|
|
|
{dataSourceType === DatasourceType.websiteCrawl
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
&& <PreviewDocumentPicker
|
|
|
|
files={
|
|
|
|
files={
|
|
|
|
websitePages.map(page => ({
|
|
|
|
websitePages.map(page => ({
|
|
|
|
|