Creates a new Message instance.
The role of who this message is from. Either "user", "assistant" or "system".
The content of the message.
The model used for processing this message.
Private
_contentPrivate
_flagsPrivate
_functionPrivate
_isPrivate
_modelPrivate
_namePrivate
_roleA UUID generated for this message by the library.
Private
messagePrivate
messagePrivate
messagePrivate
messagePrivate
messageJSON definition of the message as consumed by OpenAI's API.
The content of the message.
The flags detected by OpenAI's moderation API. Only set after calling moderate
.
Whether the message is flagged by OpenAI's moderation API. Always false
unless moderate
has been called.
Whether the message is currently being streamed.
The model used to generate this message.
The role of who this message is from.
Whether the message is a regular chat completion message
Whether the message is a function call result by the user
Whether the message is a function call by the assistant
Call the OpenAI moderation API to check if the message is flagged. Only called once for the same content.
The OpenAI API key
The request options to pass to fetch
Optional
headers?: Record<string, string>Optional
proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }The flags applied on the message
Removes a message streaming content listener, previously set with onContentStream
.
The previously added listener
You do not need to call this method manually, as this listener automatically unsubscribes all listeners when streaming ends. You should use this if you want to unsubscribe a listener before streaming ends.
Removes a message streaming listener, previously set with onStreamingUpdate
.
The previously added listener
Removes a message streaming start listener, previously set with onStreamingStart
.
The previously added listener
Removes a message streaming stop listener, previously set with onStreamingStop
.
The previously added listener
Removes a message update listener, previously set with onUpdate
.
The previously added listener
Adds a listener that is fired whenever the message content is updated during streaming. Also fires when streaming starts/ends.
The listener to trigger when content
changes during streaming
An unsubscribe function for this listener
Unlike the other listeners which behave like normal event listeners, this special listener is unsubscribed automatically when streaming ends.
If this is not desired, use onUpdate
and onStreamingStart
/onStreamingStop
instead.
Adds a listener for message streaming start.
The listener to trigger when isStreaming
is set to true
An unsubscribe function for this listener
Adds a listener for message streaming stop.
The listener to trigger when isStreaming
is set to false
An unsubscribe function for this listener
Adds a listener for message streaming state changes.
The listener to trigger when isStreaming
changes
An unsubscribe function for this listener
Add a listener for message content changes.
The listener to trigger when content
changes
An unsubscribe function for this listener
Adds a listener that is fired only once whenever the message content is updated during streaming. Also fires when streaming starts/ends.
The listener to trigger when content
changes during streaming
An unsubscribe function for this listener
Unlike the other listeners which behave like normal event listeners, this special listener is unsubscribed automatically when streaming ends, regardless of whether it was called once or not.
If this is not desired, use onceUpdate
and onceStreamingStart
/onceStreamingStop
instead.
Adds a listener that is called only once when the message streaming starts.
The listener to trigger when isStreaming
is set to true
An unsubscribe function for this listener
Adds a listener that is called only once when the message streaming stops.
The listener to trigger when isStreaming
is set to false
An unsubscribe function for this listener
Adds a listener that is called only once when the message streaming state changes.
The listener to trigger when isStreaming
changes
An unsubscribe function for this listener
Add a listener that is called only once when the message content changes.
The listener to trigger when content
changes
An unsubscribe function for this listener
Serializes the message to JSON.
The Message
as a JSON object.
Optional
flags?: null | string[]Optional
function_Optional
id?: stringOptional
model?: stringOptional
name?: stringStatic
fromJSONCreates a new Message
instance from a serialized message.
The JSON object of the Message instance.
Optional
flags?: null | string[]Optional
function_Optional
id?: stringOptional
model?: stringOptional
name?: stringA new Message
instance
Generated using TypeDoc
A message in a Conversation.