ChatCompletionsAPIClient
Constructors
Methods
addEventListener(event: | , callback: Function
): void
Adds a handler for the specified OpenAI.ChatCompletionsAPIEvents or OpenAI.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.
Parameters
event:
Event class (i.e., OpenAI.ChatCompletionsAPIEvents.ContentDelta)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
close(): void
Closes the OpenAI connection (over WebSocket) or connection attempt.
Returns
type:
void
createChatCompletions(parameters: Object
): void
Creates a model response for the given chat conversation. https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create
You can use this API not only with OpenAI, but also with other OpenAI-compatible providers (configure the connector via OpenAI.ChatCompletionsAPIClientParameters.baseUrl). Third-party providers often pass custom model settings through the chat_template_kwargs request parameter.
Parameters
parameters:
Object
Chat completion parameters
Returns
type:
void
id(): string
Returns the ChatCompletionsAPIClient id.
Returns
type:
string
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified OpenAI.ChatCompletionsAPIEvents or OpenAI.Events event.
Parameters
event:
Event class (i.e., OpenAI.ChatCompletionsAPIEvents.ContentDelta)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
webSocketId(): string
Returns the OpenAI WebSocket id.
Returns
type:
string