Nhảy tới nội dung

Class: HistoryChatEngine

HistoryChatEngine is a ChatEngine that uses a ChatHistory object to keeps track of chat's message history. A ChatHistory object is passed as a parameter for each call to the chat method, so the state of the chat engine is preserved between calls. Optionally, a ContextGenerator can be used to generate an additional context for each call to chat.

Constructors

constructor

new HistoryChatEngine(init?)

Parameters

NameType
init?Partial<HistoryChatEngine>

Defined in

packages/core/src/ChatEngine.ts:381

Properties

contextGenerator

Optional contextGenerator: ContextGenerator

Defined in

packages/core/src/ChatEngine.ts:379


llm

llm: LLM

Defined in

packages/core/src/ChatEngine.ts:378

Methods

chat

chat<T, R>(message, chatHistory, streaming?): Promise<R>

Type parameters

NameType
Textends undefined | boolean = undefined
RT extends true ? AsyncGenerator<string, void, unknown> : Response

Parameters

NameType
messageMessageContent
chatHistoryChatHistory
streaming?T

Returns

Promise<R>

Defined in

packages/core/src/ChatEngine.ts:386


prepareRequestMessages

Private prepareRequestMessages(message, chatHistory): Promise<ChatMessage[]>

Parameters

NameType
messageMessageContent
chatHistoryChatHistory

Returns

Promise<ChatMessage[]>

Defined in

packages/core/src/ChatEngine.ts:433


streamChat

Protected streamChat(message, chatHistory): AsyncGenerator<string, void, unknown>

Parameters

NameType
messageMessageContent
chatHistoryChatHistory

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/ChatEngine.ts:407