Streaming
Stream agent responses in real-time using callback-based chunk delivery.
Basic Streaming
agent = aiAgent(
name : "StreamAgent",
description: "Streaming assistant"
)
// Accumulate response as it streams
response = ""
agent.stream(
callback: ( chunk ) => {
content = chunk.choices?.first()?.delta?.content ?: ""
response &= content
print( content ) // Print each chunk immediately
},
input: "Write a short story about BoxLang"
)
// response now contains the full text
println( "" ) // New line after streamStreaming with Parameters
Streaming in a Pipeline
Streaming with Memory
Streaming with Per-Call Identity (v3.0+)
Resume Streaming (v3.0+)
Related Pages
Last updated