arrows-rotateTransform Pipelines

Using transformations to clean, reshape, and enrich data as it flows through a pipeline — before, after, and around AI calls.

Transformations are the glue that connects incompatible steps and shapes data at every stage of a pipeline.

Simple Transformations

Extract, format, or modify data in a single step:

// Extract content from an AI response
pipeline = aiMessage()
    .user( "Say hello" )
    .toDefaultModel()
    .transform( r => r.content )

// Chain multiple transforms
pipeline = aiMessage()
    .user( "List 3 colors separated by commas" )
    .toDefaultModel()
    .transform( r => r.content )                           // Extract
    .transform( text => text.split( "," ) )                // Split into array
    .transform( arr => arr.map( s => s.trim() ) )          // Trim each
    .transform( arr => arr.filter( s => s.len() > 0 ) )    // Remove empties

result = pipeline.run()
// Result: ["Red", "Blue", "Green"]

Pre-Processing

Clean or enhance input before it reaches the AI model:

Post-Processing

Process AI output after generation:

Bidirectional Processing

Combine pre-processing and post-processing in a single pipeline:

Using Named Transformer Types

BoxLang AI ships with several built-in transformer classes for common tasks:

See Transformers for the full reference on built-in transformer types.

Last updated