Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/openai/lib/AbstractChatCompletionRunner.ts>AbstractChatCompletionRunner

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
class AbstractChatCompletionRunner
Abstract
import { AbstractChatCompletionRunner } from "https://deno.land/x/openai@v4.52.0/lib/AbstractChatCompletionRunner.ts";

Constructors

new
AbstractChatCompletionRunner()

Type Parameters

optional
Events extends CustomEvents<any> = AbstractChatCompletionRunnerEvents

Properties

protected
_chatCompletions: ChatCompletion[]
readonly
aborted: boolean
controller: AbortController
readonly
ended: boolean
readonly
errored: boolean

Methods

protected
_addMessage(message: ChatCompletionMessageParam, emit?)
protected
_connected()
protected
_createChatCompletion(
completions: Completions,
options?: Core.RequestOptions,
): Promise<ChatCompletion>
protected
_emit<Event extends keyof Events>(event: Event, ...args: EventParameters<Events, Event>)
protected
_emitFinal()
protected
_run(executor: () => Promise<any>)
protected
_runChatCompletion(
completions: Completions,
options?: Core.RequestOptions,
): Promise<ChatCompletion>
protected
_runFunctions<FunctionsArgs extends BaseFunctionsArgs>()
protected
_runTools<FunctionsArgs extends BaseFunctionsArgs>(
completions: Completions,
options?: RunnerOptions,
)
done(): Promise<void>
emitted<Event extends keyof Events>(event: Event): Promise<EventParameters<Events, Event> extends [infer Param] ? Param : EventParameters<Events, Event> extends [] ? void : EventParameters<Events, Event>>

This is similar to .once(), but returns a Promise that resolves the next time the event is triggered, instead of calling a listener callback.

finalContent(): Promise<string | null>
finalFunctionCall(): Promise<ChatCompletionMessage.FunctionCall | undefined>
finalFunctionCallResult(): Promise<string | undefined>
off<Event extends keyof Events>(event: Event, listener: ListenerForEvent<Events, Event>): this

Removes the specified listener from the listener array for the event. off() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified event, then off() must be called multiple times to remove each instance.

on<Event extends keyof Events>(event: Event, listener: ListenerForEvent<Events, Event>): this

Adds the listener function to the end of the listeners array for the event. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

once<Event extends keyof Events>(event: Event, listener: ListenerForEvent<Events, Event>): this

Adds a one-time listener function for the event. The next time the event is triggered, this listener is removed and then invoked.