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.

Hierarchy

Implements

Constructors

constructor

new CondenseQuestionChatEngine(init): CondenseQuestionChatEngine

Parameters

NameType
initObject
init.chatHistoryChatMessage[]
init.condenseMessagePrompt?(__namedParameters: { chatHistory: undefined | string = ""; question: undefined | string = "" }) => string
init.queryEngineBaseQueryEngine
init.serviceContext?ServiceContext

Returns

CondenseQuestionChatEngine

Overrides

PromptMixin.constructor

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:41

Properties

chatHistory

chatHistory: ChatHistory<object>

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:37


condenseMessagePrompt

condenseMessagePrompt: (__namedParameters: { chatHistory: undefined | string = ""; question: undefined | string = "" }) => string

Type declaration

▸ («destructured»): string

Parameters
NameTypeDefault value
«destructured»Objectundefined
› chatHistoryundefined | string""
› questionundefined | string""
Returns

string

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:39


llm

llm: LLM<object, object>

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:38


queryEngine

queryEngine: BaseQueryEngine

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:36

Methods

_getPromptModules

_getPromptModules(): Record<string, any>

Returns

Record<string, any>

Inherited from

PromptMixin._getPromptModules

Defined in

packages/core/src/prompts/Mixin.ts:83


_getPrompts

_getPrompts(): Object

Returns

Object

NameType
condenseMessagePrompt(__namedParameters: { chatHistory: undefined | string = ""; question: undefined | string = "" }) => string

Overrides

PromptMixin._getPrompts

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:56


_updatePrompts

_updatePrompts(promptsDict): void

Parameters

NameType
promptsDictObject
promptsDict.condenseMessagePrompt(__namedParameters: { chatHistory: undefined | string = ""; question: undefined | string = "" }) => string

Returns

void

Overrides

PromptMixin._updatePrompts

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:62


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/CondenseQuestionChatEngine.ts:83

chat(params): Promise<Response>

Parameters

NameType
paramsChatEngineParamsNonStreaming

Returns

Promise<Response>

Implementation of

ChatEngine.chat

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:84


condenseQuestion

condenseQuestion(chatHistory, question): Promise<CompletionResponse>

Parameters

NameType
chatHistoryChatHistory<object>
questionstring

Returns

Promise<CompletionResponse>

Defined in

packages/core/src/engines/chat/CondenseQuestionChatEngine.ts:70


getPrompts

getPrompts(): PromptsDict

Returns all prompts from the mixin and its modules

Returns

PromptsDict

Inherited from

PromptMixin.getPrompts

Defined in

packages/core/src/prompts/Mixin.ts:27


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/CondenseQuestionChatEngine.ts:121


updatePrompts

updatePrompts(promptsDict): void

Updates the prompts in the mixin and its modules

Parameters

NameType
promptsDictPromptsDict

Returns

void

Inherited from

PromptMixin.updatePrompts

Defined in

packages/core/src/prompts/Mixin.ts:48


validatePrompts

validatePrompts(promptsDict, moduleDict): void

Validates the prompt keys and module keys

Parameters

NameType
promptsDictPromptsDict
moduleDictModuleDict

Returns

void

Inherited from

PromptMixin.validatePrompts

Defined in

packages/core/src/prompts/Mixin.ts:10