メインコンテンツまでスキップ

Class: ContextChatEngine

ContextChatEngine uses the Index to get the appropriate context for each query. The context is stored in the system prompt, and the chat history is preserved, ideally allowing the appropriate context to be surfaced for each query.

Implements

Constructors

constructor

new ContextChatEngine(init): ContextChatEngine

Parameters

NameType
initObject
init.chatHistory?ChatMessage[]
init.chatModel?LLM
init.contextSystemPrompt?(__namedParameters: { context: undefined | string = "" }) => string
init.nodePostprocessors?BaseNodePostprocessor[]
init.retrieverBaseRetriever

Returns

ContextChatEngine

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:29

Properties

chatHistory

chatHistory: ChatHistory

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:26


chatModel

chatModel: LLM

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:25


contextGenerator

contextGenerator: ContextGenerator

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:27

Methods

chat

chat(params): Promise<AsyncIterable<Response>>

Send message along with the class's current chat history to the LLM.

Parameters

NameType
paramsChatEngineParamsStreaming

Returns

Promise<AsyncIterable<Response>>

Implementation of

ChatEngine.chat

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:46

chat(params): Promise<Response>

Parameters

NameType
paramsChatEngineParamsNonStreaming

Returns

Promise<Response>

Implementation of

ChatEngine.chat

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:47


prepareRequestMessages

prepareRequestMessages(message, chatHistory, parentEvent?): Promise<{ messages: ChatMessage[] ; nodes: BaseNode<Metadata>[] }>

Parameters

NameType
messageMessageContent
chatHistoryChatHistory
parentEvent?Event

Returns

Promise<{ messages: ChatMessage[] ; nodes: BaseNode<Metadata>[] }>

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:96


reset

reset(): void

Resets the chat history so that it's empty.

Returns

void

Implementation of

ChatEngine.reset

Defined in

packages/core/src/engines/chat/ContextChatEngine.ts:92