Saltar al contenido principal

Class: CondenseQuestionChatEngine

CondenseQuestionChatEngine is used in conjunction with a Index (for example VectorStoreIndex). It does two steps on taking a user's chat message: first, it condenses the chat message with the previous chat history into a question with more context. Then, it queries the underlying Index using the new question with context and returns the response. CondenseQuestionChatEngine performs well when the input is primarily questions about the underlying data. It performs less well when the chat messages are not questions about the data, or are very referential to previous context.

Implements

Constructors

constructor

new CondenseQuestionChatEngine(init)

Parameters

NameType
initObject
init.chatHistoryChatMessage[]
init.condenseMessagePrompt?(__namedParameters: Object) => string
init.queryEngineBaseQueryEngine
init.serviceContext?ServiceContext

Defined in

packages/core/src/ChatEngine.ts:122

Properties

chatHistory

chatHistory: ChatMessage[]

Defined in

packages/core/src/ChatEngine.ts:118


condenseMessagePrompt

condenseMessagePrompt: (__namedParameters: Object) => string

Type declaration

▸ («destructured»): string

Parameters
NameType
«destructured»Object
Returns

string

Defined in

packages/core/src/ChatEngine.ts:120


queryEngine

queryEngine: BaseQueryEngine

Defined in

packages/core/src/ChatEngine.ts:117


serviceContext

serviceContext: ServiceContext

Defined in

packages/core/src/ChatEngine.ts:119

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:147


condenseQuestion

Private condenseQuestion(chatHistory, question): Promise<ChatResponse>

Parameters

NameType
chatHistoryChatMessage[]
questionstring

Returns

Promise<ChatResponse>

Defined in

packages/core/src/ChatEngine.ts:136


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:169