Skip to main content
Module

x/openai/streaming.ts>Stream

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
class Stream
implements AsyncIterable<Item>
import { Stream } from "https://deno.land/x/openai@v4.40.0/streaming.ts";

Constructors

new
Stream(iterator: () => AsyncIterator<Item>, controller: AbortController)

Methods

Splits the stream into two streams which can be independently read from at different speeds.

Converts this stream to a newline-separated ReadableStream of JSON stringified values in the stream which can be turned back into a Stream with Stream.fromReadableStream().

[Symbol.asyncIterator](): AsyncIterator<Item>

Static Methods

fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController)

Generates a Stream from a newline-separated ReadableStream where each item is a JSON value.

fromSSEResponse<Item>(response: Response, controller: AbortController)