Class ChatStream<Item>

Implements an async iterable that processes the readable stream of an assistant chat response.

This class expects each chunk of data in the stream to begin with data: and be followed by a valid chunk of JSON. If a chunk contains malformed JSON, it is skipped, and a debug message is logged.

Type Parameters

  • Item

    The type of items yielded by the iterable.

Hierarchy

  • ChatStream

Implements

  • AsyncIterable<Item>

Constructors

Properties

Methods

Constructors

Properties

stream: Readable

Methods

  • Returns AsyncIterator<Item, any, undefined>