Skip to main content

Class: SummaryChatHistory

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

Extends

Constructors

new SummaryChatHistory()

new SummaryChatHistory(init?): SummaryChatHistory

Parameters

init?: Partial<SummaryChatHistory>

Returns

SummaryChatHistory

Overrides

ChatHistory.constructor

Defined in

packages/llamaindex/src/ChatHistory.ts:80

Properties

llm

llm: LLM<object, object>

Defined in

packages/llamaindex/src/ChatHistory.ts:77


messages

messages: ChatMessage[]

Overrides

ChatHistory.messages

Defined in

packages/llamaindex/src/ChatHistory.ts:75


summaryPrompt()

summaryPrompt: (__namedParameters) => string

Parameters

__namedParameters

__namedParameters.context: undefined | string = ""

Returns

string

Defined in

packages/llamaindex/src/ChatHistory.ts:76


tokenizer

tokenizer: Tokenizer

Tokenizer function that converts text to tokens, this is used to calculate the number of tokens in a message.

Defined in

packages/llamaindex/src/ChatHistory.ts:73


tokensToSummarize

tokensToSummarize: number

Defined in

packages/llamaindex/src/ChatHistory.ts:74

Methods

addMessage()

addMessage(message): void

Adds a message to the chat history.

Parameters

message: ChatMessage

Returns

void

Overrides

ChatHistory.addMessage

Defined in

packages/llamaindex/src/ChatHistory.ts:129


getLastSummary()

getLastSummary(): null | ChatMessage

Returns

null | ChatMessage

Defined in

packages/llamaindex/src/ChatHistory.ts:145


newMessages()

newMessages(): ChatMessage[]

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

Returns

ChatMessage[]

Overrides

ChatHistory.newMessages

Defined in

packages/llamaindex/src/ChatHistory.ts:227


requestMessages()

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

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

Parameters

transientMessages?: ChatMessage[]

Returns

Promise<ChatMessage[]>

Overrides

ChatHistory.requestMessages

Defined in

packages/llamaindex/src/ChatHistory.ts:193


reset()

reset(): void

Resets the chat history so that it's empty.

Returns

void

Overrides

ChatHistory.reset

Defined in

packages/llamaindex/src/ChatHistory.ts:223