Ana içeriğe geç

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)

Parameters

NameType
initObject
init.chatHistory?ChatMessage[]
init.chatModel?LLM
init.contextSystemPrompt?(__namedParameters: Object) => string
init.nodePostprocessors?BaseNodePostprocessor[]
init.retrieverBaseRetriever

Defined in

packages/core/src/ChatEngine.ts:243

Properties

chatHistory

chatHistory: ChatMessage[]

Defined in

packages/core/src/ChatEngine.ts:240


chatModel

chatModel: LLM

Defined in

packages/core/src/ChatEngine.ts:239


contextGenerator

contextGenerator: ContextGenerator

Defined in

packages/core/src/ChatEngine.ts:241

Methods

chat

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

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

Type parameters

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

Parameters

NameTypeDescription
messageMessageContent
chatHistory?ChatMessage[]optional chat history if you want to customize the chat history
streaming?Toptional streaming flag, which auto-sets the return value if True.

Returns

Promise<R>

Implementation of

ChatEngine.chat

Defined in

packages/core/src/ChatEngine.ts:259


reset

reset(): void

Resets the chat history so that it's empty.

Returns

void

Implementation of

ChatEngine.reset

Defined in

packages/core/src/ChatEngine.ts:336


streamChat

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

Parameters

NameType
messageMessageContent
chatHistory?ChatMessage[]

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/ChatEngine.ts:300