🚨 Breaking Changes 🚨
- The order of arguments passed into option callbacks in
RPCLink
has changed.
🌟 Event Source / SSE Support 🌟
Streaming support is now built-in—no extra configuration needed!
const streaming = os
.output(eventIterator(z.object({ message: z.string() })))
.handler(async function* ({ input, lastEventId }) {
try {
while (true) {
yield withEventMeta({ message: 'Hello, world!' }, { id: 'event-id', retry: 1000 })
await new Promise(resolve => setTimeout(resolve, 1000))
}
} finally {
// cleanup logic here
}
})
const result = await client.streaming(
{ prompt: 'Hello' },
{ lastEventId: 'you also can pass initial last event id here' }
)
// Process the incoming stream of events using async iteration
for await (const event of result) {
console.log(event)
}
// To close the connection manually, call result.return()