StaticconsumeConverts an async iterable to a callback-based stream
The async iterable to convert
Streaming options with callbacks
A promise that resolves with the final chunk
StaticmergeStaticfromCreates an async iterable from a callback-based stream
Function that sets up the stream with callbacks
An async iterable of chunks
const stream = StreamingHelper.fromCallbacks<ChatOutput>((emit, end, error) => {
llmProvider.stream(input, {
onChunk: (data) => emit({ data, done: false }),
onComplete: (data) => { emit({ data, done: true }); end(); },
onError: error
});
});
for await (const chunk of stream) {
console.log(chunk.data);
}
Utility class to help implement streaming agents