Explorar o código

fix: add full doc mode preview length limit (#12310)

ok
Wu Tianwei hai 4 meses
pai
achega
e58e573f3e

+ 5 - 2
web/app/components/datasets/create/step-two/index.tsx

@@ -53,7 +53,7 @@ import type { DefaultModel } from '@/app/components/header/account-setting/model
 import { ModelTypeEnum } 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 Checkbox from '@/app/components/base/checkbox'
 import RadioCard from '@/app/components/base/radio-card'
 import RadioCard from '@/app/components/base/radio-card'
-import { IS_CE_EDITION } from '@/config'
+import { FULL_DOC_PREVIEW_LENGTH, IS_CE_EDITION } from '@/config'
 import Divider from '@/app/components/base/divider'
 import Divider from '@/app/components/base/divider'
 import { getNotionInfo, getWebsiteInfo, useCreateDocument, useCreateFirstDocument, useFetchDefaultProcessRule, useFetchFileIndexingEstimateForFile, useFetchFileIndexingEstimateForNotion, useFetchFileIndexingEstimateForWeb } from '@/service/knowledge/use-create-dataset'
 import { getNotionInfo, getWebsiteInfo, useCreateDocument, useCreateFirstDocument, useFetchDefaultProcessRule, useFetchFileIndexingEstimateForFile, useFetchFileIndexingEstimateForNotion, useFetchFileIndexingEstimateForWeb } from '@/service/knowledge/use-create-dataset'
 import Badge from '@/app/components/base/badge'
 import Badge from '@/app/components/base/badge'
@@ -1105,6 +1105,9 @@ const StepTwo = ({
           {currentDocForm === ChunkingMode.parentChild && currentEstimateMutation.data?.preview && (
           {currentDocForm === ChunkingMode.parentChild && currentEstimateMutation.data?.preview && (
             estimate?.preview?.map((item, index) => {
             estimate?.preview?.map((item, index) => {
               const indexForLabel = index + 1
               const indexForLabel = index + 1
+              const childChunks = parentChildConfig.chunkForContext === 'full-doc'
+                ? item.child_chunks.slice(0, FULL_DOC_PREVIEW_LENGTH)
+                : item.child_chunks
               return (
               return (
                 <ChunkContainer
                 <ChunkContainer
                   key={item.content}
                   key={item.content}
@@ -1112,7 +1115,7 @@ const StepTwo = ({
                   characterCount={item.content.length}
                   characterCount={item.content.length}
                 >
                 >
                   <FormattedText>
                   <FormattedText>
-                    {item.child_chunks.map((child, index) => {
+                    {childChunks.map((child, index) => {
                       const indexForLabel = index + 1
                       const indexForLabel = index + 1
                       return (
                       return (
                         <PreviewSlice
                         <PreviewSlice

+ 2 - 0
web/config/index.ts

@@ -258,3 +258,5 @@ else if (globalThis.document?.body?.getAttribute('data-public-text-generation-ti
 export const TEXT_GENERATION_TIMEOUT_MS = textGenerationTimeoutMs
 export const TEXT_GENERATION_TIMEOUT_MS = textGenerationTimeoutMs
 
 
 export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true'
 export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true'
+
+export const FULL_DOC_PREVIEW_LENGTH = 50