diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsx index afc78b7844..102a7da012 100644 --- a/web/app/components/datasets/settings/form/index.tsx +++ b/web/app/components/datasets/settings/form/index.tsx @@ -357,7 +357,9 @@ const Form = () => { )} { - indexMethod === IndexingType.QUALIFIED && ( + indexMethod === IndexingType.QUALIFIED + && [ChunkingMode.text, ChunkingMode.parentChild].includes(currentDataset?.doc_form as ChunkingMode) + && ( <> { const summaryElement = useMemo(() => { if (chunkType === ChunkingMode.parentChild) { - return (content as ParentChildChunk).parent_content.summary + return (content as ParentChildChunk).parent_summary } if (chunkType === ChunkingMode.text) { return (content as GeneralChunk).summary diff --git a/web/app/components/rag-pipeline/components/chunk-card-list/index.spec.tsx b/web/app/components/rag-pipeline/components/chunk-card-list/index.spec.tsx index 8a15193d2e..470942eeb3 100644 --- a/web/app/components/rag-pipeline/components/chunk-card-list/index.spec.tsx +++ b/web/app/components/rag-pipeline/components/chunk-card-list/index.spec.tsx @@ -22,7 +22,7 @@ const createGeneralChunks = (overrides: GeneralChunks = []): GeneralChunks => { const createParentChildChunk = (overrides: Partial = {}): ParentChildChunk => ({ child_contents: ['Child content 1', 'Child content 2'], - parent_content: { content: 'This is the parent content that contains the children.' }, + parent_content: 'This is the parent content that contains the children.', parent_mode: 'paragraph', ...overrides, }) @@ -32,7 +32,7 @@ const createParentChildChunks = (overrides: Partial = {}): Pa createParentChildChunk(), createParentChildChunk({ child_contents: ['Another child 1', 'Another child 2', 'Another child 3'], - parent_content: { content: 'Another parent content here.' }, + parent_content: 'Another parent content here.', }), ], parent_mode: 'paragraph', @@ -706,7 +706,7 @@ describe('ChunkCardList', () => { const chunks = createParentChildChunks({ parent_child_chunks: [ createParentChildChunk({ - parent_content: { content: 'Parent' }, // 6 characters + parent_content: 'Parent', // 6 characters child_contents: ['Child'], }), ], @@ -1047,7 +1047,7 @@ describe('ChunkCardList Integration', () => { const parentChildChunks = createParentChildChunks({ parent_child_chunks: [ { - parent_content: { content: 'Main section about React components and their lifecycle.' }, + parent_content: 'Main section about React components and their lifecycle.', child_contents: [ 'React components are building blocks.', 'Lifecycle methods control component behavior.', diff --git a/web/app/components/rag-pipeline/components/chunk-card-list/index.tsx b/web/app/components/rag-pipeline/components/chunk-card-list/index.tsx index 6bd69bc46e..176298b2e8 100644 --- a/web/app/components/rag-pipeline/components/chunk-card-list/index.tsx +++ b/web/app/components/rag-pipeline/components/chunk-card-list/index.tsx @@ -25,7 +25,7 @@ export const ChunkCardList = (props: ChunkCardListProps) => { const getWordCount = (seg: GeneralChunk | ParentChildChunk | QAChunk) => { if (chunkType === ChunkingMode.parentChild) - return (seg as ParentChildChunk).parent_content.content?.length + return (seg as ParentChildChunk).parent_content?.length if (chunkType === ChunkingMode.text) return (seg as GeneralChunk).content.length return (seg as QAChunk).question.length + (seg as QAChunk).answer.length diff --git a/web/app/components/rag-pipeline/components/chunk-card-list/types.ts b/web/app/components/rag-pipeline/components/chunk-card-list/types.ts index 331f17d17c..6117855b3b 100644 --- a/web/app/components/rag-pipeline/components/chunk-card-list/types.ts +++ b/web/app/components/rag-pipeline/components/chunk-card-list/types.ts @@ -5,7 +5,8 @@ export type GeneralChunk = { export type GeneralChunks = GeneralChunk[] export type ParentChildChunk = { child_contents: string[] - parent_content: GeneralChunk + parent_content: string + parent_summary?: string parent_mode: string } diff --git a/web/app/components/rag-pipeline/components/panel/test-run/result/result-preview/utils.ts b/web/app/components/rag-pipeline/components/panel/test-run/result/result-preview/utils.ts index 0e62941053..de3666224f 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/result/result-preview/utils.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/result/result-preview/utils.ts @@ -1,4 +1,4 @@ -import type { ChunkInfo, GeneralChunk, GeneralChunks, ParentChildChunks, QAChunks } from '../../../../chunk-card-list/types' +import type { ChunkInfo, GeneralChunks, ParentChildChunks, QAChunks } from '../../../../chunk-card-list/types' import type { ParentMode } from '@/models/datasets' import { RAG_PIPELINE_PREVIEW_CHUNK_NUM } from '@/config' import { ChunkingMode } from '@/models/datasets' @@ -22,8 +22,9 @@ const formatGeneralChunks = (outputs: any) => { } type ParentChildChunkPreview = { - content: GeneralChunk + content: string child_chunks: string[] + summary?: string } const formatParentChildChunks = (outputs: any, parentMode: ParentMode) => { @@ -36,6 +37,7 @@ const formatParentChildChunks = (outputs: any, parentMode: ParentMode) => { chunks.slice(0, RAG_PIPELINE_PREVIEW_CHUNK_NUM).forEach((chunk) => { chunkInfo.parent_child_chunks?.push({ parent_content: chunk.content, + parent_summary: chunk.summary, child_contents: chunk.child_chunks, parent_mode: parentMode, }) diff --git a/web/app/components/workflow/nodes/knowledge-base/panel.tsx b/web/app/components/workflow/nodes/knowledge-base/panel.tsx index e6d4752714..6e0f038b70 100644 --- a/web/app/components/workflow/nodes/knowledge-base/panel.tsx +++ b/web/app/components/workflow/nodes/knowledge-base/panel.tsx @@ -170,7 +170,9 @@ const Panel: FC> = ({ { - data.indexing_technique === IndexMethodEnum.QUALIFIED && ( + data.indexing_technique === IndexMethodEnum.QUALIFIED + && [ChunkStructureEnum.general, ChunkStructureEnum.parent_child].includes(data.chunk_structure) + && ( <>