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 GetFileChunks

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

Overview

GetFileChunks encompasses the API client functions for retrieving and editing stored document chunks. The getFileChunks function retrieves paginated chunks from the server, while editChunkFromStore updates individual chunk content and metadata.

Code Reference

Source Location

  • File: packages/ui/src/api/documentstore.js, Lines 13-16
  • Repository: FlowiseAI/Flowise

Signature

const getFileChunks = (storeId, fileId, pageNo) => client.get(`/document-store/chunks/${storeId}/${fileId}/${pageNo}`)

const editChunkFromStore = (storeId, loaderId, chunkId, body) =>
    client.put(`/document-store/chunks/${storeId}/${loaderId}/${chunkId}`, body)
  • getFileChunks sends a GET request to /api/v1/document-store/chunks/{storeId}/{fileId}/{pageNo}.
  • editChunkFromStore sends a PUT request to /api/v1/document-store/chunks/{storeId}/{loaderId}/{chunkId}.

Import

import documentStoreApi from '@/api/documentstore'

The functions are accessed as documentStoreApi.getFileChunks(storeId, fileId, pageNo) and documentStoreApi.editChunkFromStore(storeId, loaderId, chunkId, body) after importing the default export.

I/O Contract

Inputs for getFileChunks

Parameter Type Required Description
storeId string Yes The document store identifier
fileId string Yes The file/loader identifier, or "all" to retrieve chunks from all files
pageNo number Yes The page number (1-indexed). Each page contains up to 50 chunks

Outputs for getFileChunks

Field Type Description
data object The paginated chunk response
data.count number Total number of chunks matching the query
data.chunks Chunk[] Array of chunk objects for the current page
data.chunks[].pageContent string The text content of the chunk
data.chunks[].metadata object Metadata associated with the chunk (source, page, etc.)
data.currentPage number The current page number

The function returns a Promise<{data: {count: number, chunks: Chunk[], currentPage: number}}>.

Inputs for editChunkFromStore

Parameter Type Required Description
storeId string Yes The document store identifier
loaderId string Yes The loader identifier that owns this chunk
chunkId string Yes The unique chunk identifier
body object Yes The updated chunk data
body.pageContent string Yes The new text content for the chunk
body.metadata object Yes The new metadata object for the chunk

Outputs for editChunkFromStore

Field Type Description
data Chunk The updated chunk object
data.pageContent string The updated text content
data.metadata object The updated metadata

The function returns a Promise<{data: Chunk}>.

Usage Examples

Paginated Chunk Browsing

import documentStoreApi from '@/api/documentstore'

const browseAllChunks = async (storeId) => {
    let page = 1
    let totalChunks = 0

    // Fetch the first page
    const response = await documentStoreApi.getFileChunks(storeId, 'all', page)
    totalChunks = response.data.count
    const totalPages = Math.ceil(totalChunks / 50)

    console.log(`Total chunks: ${totalChunks}, Pages: ${totalPages}`)
    console.log(`Page ${page}:`, response.data.chunks.length, 'chunks')

    // Display chunk summaries
    response.data.chunks.forEach((chunk, i) => {
        console.log(`  [${i + 1}] ${chunk.pageContent.substring(0, 80)}...`)
    })

    return response.data
}

Fetching Chunks for a Specific File

import documentStoreApi from '@/api/documentstore'

const getChunksForFile = async (storeId, fileId) => {
    const response = await documentStoreApi.getFileChunks(storeId, fileId, 1)
    console.log(`File has ${response.data.count} chunks`)
    return response.data
}

Editing a Chunk

import documentStoreApi from '@/api/documentstore'

const fixChunkContent = async (storeId, loaderId, chunkId) => {
    const updatedChunk = await documentStoreApi.editChunkFromStore(
        storeId,
        loaderId,
        chunkId,
        {
            pageContent: 'Corrected text content with fixed OCR errors',
            metadata: {
                source: 'product-docs.pdf',
                page: 5,
                editedBy: 'manual-review',
                editedAt: new Date().toISOString()
            }
        }
    )

    console.log('Chunk updated:', updatedChunk.data.pageContent.substring(0, 50))
    return updatedChunk.data
}

Bulk Review Workflow

import documentStoreApi from '@/api/documentstore'

const reviewChunksPage = async (storeId, pageNo) => {
    const response = await documentStoreApi.getFileChunks(storeId, 'all', pageNo)
    const { chunks, count, currentPage } = response.data

    // Flag chunks that may need attention
    const shortChunks = chunks.filter(c => c.pageContent.length < 50)
    const noMetadata = chunks.filter(c => Object.keys(c.metadata).length === 0)

    console.log(`Page ${currentPage}: ${chunks.length} chunks`)
    console.log(`  Short chunks (< 50 chars): ${shortChunks.length}`)
    console.log(`  Missing metadata: ${noMetadata.length}`)

    return { chunks, shortChunks, noMetadata }
}

Related Pages

Page Connections

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