انتقل إلى المحتوى الرئيسي

Class: SimpleChatHistory

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

Hierarchy

Constructors

constructor

new SimpleChatHistory(init?): SimpleChatHistory

Parameters

NameType
init?Partial<SimpleChatHistory>

Returns

SimpleChatHistory

Overrides

ChatHistory.constructor

Defined in

packages/core/src/ChatHistory.ts:41

Properties

messages

messages: { content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]

Overrides

ChatHistory.messages

Defined in

packages/core/src/ChatHistory.ts:38


messagesBefore

Private messagesBefore: number

Defined in

packages/core/src/ChatHistory.ts:39

Methods

addMessage

addMessage(message): void

Adds a message to the chat history.

Parameters

NameType
messageObject
message.contentMessageContent
message.options?Record<string, unknown>
message.roleMessageType

Returns

void

Overrides

ChatHistory.addMessage

Defined in

packages/core/src/ChatHistory.ts:47


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 }[]

Overrides

ChatHistory.newMessages

Defined in

packages/core/src/ChatHistory.ts:59


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

NameType
transientMessages?{ content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]

Returns

Promise<{ content: MessageContent ; options?: Record<string, unknown> ; role: MessageType }[]>

Overrides

ChatHistory.requestMessages

Defined in

packages/core/src/ChatHistory.ts:51


reset

reset(): void

Resets the chat history so that it's empty.

Returns

void

Overrides

ChatHistory.reset

Defined in

packages/core/src/ChatHistory.ts:55