跳到主要内容

Class: SimpleChatHistory

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

Implements

Constructors

constructor

new SimpleChatHistory(init?)

Parameters

NameType
init?Partial<SimpleChatHistory>

Defined in

packages/core/src/ChatHistory.ts:39

Properties

messages

messages: ChatMessage[]

Implementation of

ChatHistory.messages

Defined in

packages/core/src/ChatHistory.ts:36


messagesBefore

Private messagesBefore: number

Defined in

packages/core/src/ChatHistory.ts:37

Methods

addMessage

addMessage(message): void

Adds a message to the chat history.

Parameters

NameType
messageChatMessage

Returns

void

Implementation of

ChatHistory.addMessage

Defined in

packages/core/src/ChatHistory.ts:44


newMessages

newMessages(): ChatMessage[]

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

Returns

ChatMessage[]

Implementation of

ChatHistory.newMessages

Defined in

packages/core/src/ChatHistory.ts:56


requestMessages

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

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

Parameters

NameType
transientMessages?ChatMessage[]

Returns

Promise<ChatMessage[]>

Implementation of

ChatHistory.requestMessages

Defined in

packages/core/src/ChatHistory.ts:48


reset

reset(): void

Resets the chat history so that it's empty.

Returns

void

Implementation of

ChatHistory.reset

Defined in

packages/core/src/ChatHistory.ts:52