メインコンテンツまでスキップ

Class: ChatHistory<AdditionalMessageOptions>

A ChatHistory is used to keep the state of back and forth chat messages

Type parameters

NameType
AdditionalMessageOptionsextends object = object

Hierarchy

Constructors

constructor

new ChatHistory<AdditionalMessageOptions>(): ChatHistory<AdditionalMessageOptions>

Type parameters

NameType
AdditionalMessageOptionsextends object = object

Returns

ChatHistory<AdditionalMessageOptions>

Accessors

messages

get messages(): ChatMessage<AdditionalMessageOptions>[]

Returns

ChatMessage<AdditionalMessageOptions>[]

Defined in

packages/core/src/ChatHistory.ts:14

Methods

addMessage

addMessage(message): void

Adds a message to the chat history.

Parameters

NameType
messageChatMessage<AdditionalMessageOptions>

Returns

void

Defined in

packages/core/src/ChatHistory.ts:19


newMessages

newMessages(): ChatMessage<AdditionalMessageOptions>[]

Returns the new messages since the last call to this function (or since calling the constructor)

Returns

ChatMessage<AdditionalMessageOptions>[]

Defined in

packages/core/src/ChatHistory.ts:36


requestMessages

requestMessages(transientMessages?): Promise<ChatMessage<AdditionalMessageOptions>[]>

Returns the messages that should be used as input to the LLM.

Parameters

NameType
transientMessages?ChatMessage<AdditionalMessageOptions>[]

Returns

Promise<ChatMessage<AdditionalMessageOptions>[]>

Defined in

packages/core/src/ChatHistory.ts:24


reset

reset(): void

Resets the chat history so that it's empty.

Returns

void

Defined in

packages/core/src/ChatHistory.ts:31