Class: ChatHistory
A ChatHistory is used to keep the state of back and forth chat messages
Hierarchy
-
ChatHistory
Constructors
constructor
• new ChatHistory(): ChatHistory
Returns
Accessors
messages
• get
messages(): { content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]
Returns
{ content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]
Defined in
packages/core/src/ChatHistory.ts:12
Methods
addMessage
▸ addMessage(message
): void
Adds a message to the chat history.
Parameters
Name | Type |
---|---|
message | Object |
message.content | MessageContent |
message.options? | Record <string , unknown > |
message.role | MessageType |
Returns
void
Defined in
packages/core/src/ChatHistory.ts:17
newMessages
▸ newMessages(): { content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]
Returns the new messages since the last call to this function (or since calling the constructor)
Returns
{ content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]
Defined in
packages/core/src/ChatHistory.ts:34
requestMessages
▸ requestMessages(transientMessages?
): Promise
<{ content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]>
Returns the messages that should be used as input to the LLM.
Parameters
Name | Type |
---|---|
transientMessages? | { content : MessageContent ; options? : Record <string , unknown > ; role : MessageType }[] |
Returns
Promise
<{ content
: MessageContent
; options?
: Record
<string
, unknown
> ; role
: MessageType
}[]>
Defined in
packages/core/src/ChatHistory.ts:22
reset
▸ reset(): void
Resets the chat history so that it's empty.
Returns
void