Skip to main content

Class: abstract ChatHistory<AdditionalMessageOptions>

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

Extended by

Type Parameters

AdditionalMessageOptions extends object = object

Constructors

new ChatHistory()

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

Returns

ChatHistory<AdditionalMessageOptions>

Accessors

messages

get abstract messages(): ChatMessage<AdditionalMessageOptions>[]

Returns

ChatMessage<AdditionalMessageOptions>[]

Defined in

packages/llamaindex/src/ChatHistory.ts:16

Methods

addMessage()

abstract addMessage(message): void

Adds a message to the chat history.

Parameters

message: ChatMessage<AdditionalMessageOptions>

Returns

void

Defined in

packages/llamaindex/src/ChatHistory.ts:21


newMessages()

abstract 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/llamaindex/src/ChatHistory.ts:38


requestMessages()

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

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

Parameters

transientMessages?: ChatMessage<AdditionalMessageOptions>[]

Returns

Promise<ChatMessage<AdditionalMessageOptions>[]>

Defined in

packages/llamaindex/src/ChatHistory.ts:26


reset()

abstract reset(): void

Resets the chat history so that it's empty.

Returns

void

Defined in

packages/llamaindex/src/ChatHistory.ts:33