Skip to content

bmel:chunk-count

Category: LLM · Returns: bmel:integer

Signature
bmel:chunk-count(text: bmel:string, chunkSize: bmel:integer)

Description

Returns the number of chunks that a text would be split into given a fixed chunk size in tokens. Computed as ceil(token-count(text) / chunkSize). Useful for estimating RAG retrieval overhead and indexing cost before processing.

Arguments

Parameter Type Required Description
text bmel:string The input text to chunk.
chunkSize bmel:integer Target chunk size in tokens.

Examples

Chunks of 512 tokens needed for the prompt
bmel:chunk-count({invokeAgent:Request Payload}.$.prompt, 512)
Chunks of the agent's answer, in 1,024-token windows
bmel:chunk-count({invokeAgent:Response Payload}.$.output_text, 1024)

← Back to BMEL Reference