Skip to content

armgit / dify

Public Imported from GitHub
0

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.

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

Wu Tianweie58e573f3e62
diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx
index c0e6a0f1d38..8353467bec6 100644
--- a/web/app/components/datasets/create/step-two/index.tsx
+++ b/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 Checkbox from '@/app/components/base/checkbox'
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 { getNotionInfo, getWebsiteInfo, useCreateDocument, useCreateFirstDocument, useFetchDefaultProcessRule, useFetchFileIndexingEstimateForFile, useFetchFileIndexingEstimateForNotion, useFetchFileIndexingEstimateForWeb } from '@/service/knowledge/use-create-dataset'
import Badge from '@/app/components/base/badge'
@@ -1105,6 +1105,9 @@ const StepTwo = ({
{currentDocForm === ChunkingMode.parentChild && currentEstimateMutation.data?.preview && (
estimate?.preview?.map((item, index) => {
const indexForLabel = index + 1
+ const childChunks = parentChildConfig.chunkForContext === 'full-doc'
+ ? item.child_chunks.slice(0, FULL_DOC_PREVIEW_LENGTH)
+ : item.child_chunks
return (
<ChunkContainer
key={item.content}
@@ -1112,7 +1115,7 @@ const StepTwo = ({
characterCount={item.content.length}
>
<FormattedText>
- {item.child_chunks.map((child, index) => {
+ {childChunks.map((child, index) => {
const indexForLabel = index + 1
return (
<PreviewSlice
diff --git a/web/config/index.ts b/web/config/index.ts
index 9eb4889441b..b87c027de16 100644
--- a/web/config/index.ts
+++ b/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 DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true'
+
+export const FULL_DOC_PREVIEW_LENGTH = 50