Transformers
Using transformers with agents to process inputs and outputs, enabling structured extraction and multi-stage pipelines.
Output Transformation
import bxModules.bxai.models.transformers.TextCleanerTransformer;
agent = aiAgent(
name : "Content Generator",
instructions: "Generate content based on user requests"
)
// Post-process the agent's output
cleaner = new TextCleanerTransformer( {
stripHTML : true,
removeExtraSpaces: true
} )
pipeline = aiMessage()
.user( "${prompt}" )
.to( agent )
.transform( r => r.content )
.to( cleaner )
.transform( cleaned => {
return {
cleaned : cleaned,
wordCount : cleaned.listLen( " " ),
charCount : len( cleaned )
}
} )
result = pipeline.run( { prompt: "Write about BoxLang AI" } )
println( "Word count: #result.wordCount#" )Input Processing
Structured Output from Agents
Multi-Stage Agent Processing
Related Pages
Last updated