View module source on GitHub

AsyncStreamWrapper

class AsyncStreamWrapper()

Async wrapper for OpenAI streaming chat completions that handles Maxim logging.

This class wraps an async OpenAI stream to automatically log generation results and trace information when the stream is fully consumed. It accumulates chunks as they are yielded and processes the complete response for logging when the stream ends.