IronFlowDocs

ai_chunk

Split text into chunks using fixed-size, delimiter, or subtitle cue strategies.

Parameters

modestringdefault "fixed"
Chunking strategy: "fixed", "split", or "cues"
source_keystringrequired
Context key holding text to chunk (fixed/split) or a subtitle cues array (cues)
output_keystringdefault "chunks"
Prefix for output context keys
sizenumberdefault 4096
Target chunk size in bytes (mode=fixed)
delimitersstringdefault see below
Delimiter characters (e.g. "\n.")
prefixbooldefault false
Put delimiter at start of next chunk (mode=fixed)
min_charsnumberdefault 0
Minimum characters per segment (mode=split)

Delimiter defaults

  • mode=fixed: no delimiters (hard split at size boundary)
  • mode=split: "\n.?"

Context Output

KeyTypeDescription
{output_key}arrayArray of chunk strings (fixed/split) or cue segment objects (cues)
{output_key}_countnumberNumber of chunks
{output_key}_successbooleantrue on success

Modes

fixed — Size-based chunking

Walks the text in size-byte windows. In each window, searches backward for a delimiter byte. If found, splits there; otherwise hard-splits at the size boundary.

split — Delimiter splitting

Splits text at every occurrence of a delimiter character. Short segments (below min_chars) are merged into the previous segment.

Examples

Fixed-size chunking

flow:step("chunk", nodes.ai_chunk({
    mode = "fixed",
    source_key = "document",
    output_key = "parts",
    size = 2048,
    delimiters = "\n."
}))

Delimiter splitting

flow:step("split", nodes.ai_chunk({
    mode = "split",
    source_key = "document",
    output_key = "sentences",
    delimiters = ".?!",
    min_chars = 50
}))

Mode: cues (timestamp-preserving)

Groups an ordered array of subtitle cues (as produced by extract_vtt / extract_srt under their cues_key, default cues) into size-bounded chunks that keep each chunk's start/end timecodes. A single cue is never split; a cue whose text alone exceeds size becomes its own chunk.

Parameters

ParamTypeDefaultNotes
modestringSet to "cues".
source_keystringContext key holding the cues array (each cue: text, start_ms, end_ms, start, end).
sizenumber1200Max characters per chunk (cue boundaries are respected).
output_keystringchunksBase key for outputs.

Output

  • <output_key> — array of { text, ts_start, ts_end, start_ms, end_ms, cue_count }
  • <output_key>_texts — parallel array of the chunk text strings (feed straight into ai_embed's input_key)
  • <output_key>_count — number of chunks
  • <output_key>_successtrue

Sample segment

{
  "text": "We propose the new telemetry pipeline ...",
  "ts_start": "00:03:12.120",
  "ts_end": "00:03:27.940",
  "start_ms": 192120,
  "end_ms": 207940,
  "cue_count": 3
}

IronFlow documentation

Find the next step

Type a keyword to search the documentation.

to move · Enter to open · Esc to close