Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:FlowiseAI Flowise PreviewChunks

From Leeroopedia
Attribute Value
Sources packages/ui/src/api/documentstore.js:L17
Domains Document_Store_Ingestion
Last Updated 2026-02-12 14:00 GMT

Overview

PreviewChunks is the API client function that sends a document loader and splitter configuration to the server for trial processing, returning a limited set of sample chunks without persisting them. This enables users to evaluate their configuration before committing to full document processing.

Code Reference

Source Location

Signature

const previewChunks = (body) => client.post('/document-store/loader/preview', body)

This function sends a POST request to the /api/v1/document-store/loader/preview endpoint via the configured axios client instance.

Import

import documentStoreApi from '@/api/documentstore'

The function is accessed as documentStoreApi.previewChunks(body) after importing the default export from the documentstore API module.

I/O Contract

Inputs

Parameter Type Required Description
body object Yes The complete loader and splitter configuration
body.storeId string Yes The document store identifier
body.loaderId string Yes The loader instance identifier (empty string for new loaders)
body.loaderName string Yes The loader component name (e.g., pdfLoader)
body.loaderConfig object Yes Loader-specific configuration (file references, URLs, API keys, etc.)
body.splitterId string No The text splitter component name (e.g., recursiveCharacterTextSplitter)
body.splitterConfig object No Splitter-specific configuration (chunkSize, chunkOverlap, separators)
body.credential string No Credential identifier for loaders requiring authentication
body.previewChunkCount number Yes Maximum number of preview chunks to return (typically 20)

Outputs

Field Type Description
data object The preview result object
data.totalChunks number Total number of chunks that would be produced from full processing
data.chunks Chunk[] Array of sample chunk objects (limited by previewChunkCount)
data.chunks[].pageContent string The text content of the chunk
data.chunks[].metadata object Metadata associated with the chunk (source, page, line numbers, etc.)
data.previewChunkCount number The number of chunks actually returned in this preview

The function returns a Promise<{data: {totalChunks: number, chunks: Chunk[], previewChunkCount: number}}> from the axios response.

Usage Examples

Basic Preview with PDF Loader

import documentStoreApi from '@/api/documentstore'

const previewPdfChunks = async (storeId, fileId) => {
    const body = {
        storeId,
        loaderId: '',
        loaderName: 'pdfLoader',
        loaderConfig: { pdfFile: fileId },
        splitterId: 'recursiveCharacterTextSplitter',
        splitterConfig: {
            chunkSize: 1000,
            chunkOverlap: 200
        },
        previewChunkCount: 20
    }

    const response = await documentStoreApi.previewChunks(body)
    const { totalChunks, chunks } = response.data

    console.log(`Preview: ${chunks.length} of ${totalChunks} total chunks`)
    chunks.forEach((chunk, i) => {
        console.log(`--- Chunk ${i + 1} ---`)
        console.log(`Content: ${chunk.pageContent.substring(0, 200)}...`)
        console.log(`Metadata:`, chunk.metadata)
    })

    return response.data
}

Preview Without a Splitter

import documentStoreApi from '@/api/documentstore'

// Preview using only the loader (no text splitting)
const previewRawDocuments = async (storeId) => {
    const body = {
        storeId,
        loaderId: '',
        loaderName: 'textFile',
        loaderConfig: { textFile: 'uploaded-file-ref' },
        previewChunkCount: 10
    }

    const response = await documentStoreApi.previewChunks(body)
    return response.data
}

Iterative Configuration Tuning

import documentStoreApi from '@/api/documentstore'

const tuneChunkSize = async (storeId, loaderConfig) => {
    const chunkSizes = [500, 1000, 1500, 2000]

    for (const chunkSize of chunkSizes) {
        const body = {
            storeId,
            loaderId: '',
            loaderName: 'pdfLoader',
            loaderConfig,
            splitterId: 'recursiveCharacterTextSplitter',
            splitterConfig: { chunkSize, chunkOverlap: Math.floor(chunkSize * 0.2) },
            previewChunkCount: 5
        }

        const response = await documentStoreApi.previewChunks(body)
        console.log(`Chunk size ${chunkSize}: ${response.data.totalChunks} total chunks`)
    }
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment