Streaming
To stream your response back, you need to do two things:
- Set
stream: truein your LLM call.
ts
const response = llm("What is the capital of France?", { stream: true })- Provide an
onStreamcallback function to handle the streamed data.
You can provide callbacks in Agency code or TypeScript code. Here is an example in Agency code.
ts
node main() {
callback("onStream") as data {
printJSON(data)
}
const response = llm("What is the capital of India?", stream: true)
}Read more about callbacks here.