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.
Hierarchy
-
↳
ContextChatEngine
Implements
Constructors
constructor
• new ContextChatEngine(init
): ContextChatEngine
Parameters
Name | Type |
---|---|
init | Object |
init.chatHistory? | ChatMessage [] |
init.chatModel? | LLM |
init.contextSystemPrompt? | (__namedParameters : { context : undefined | string = "" }) => string |
init.nodePostprocessors? | BaseNodePostprocessor [] |
init.retriever | BaseRetriever |
Returns
Overrides
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:34
Properties
chatHistory
• chatHistory: ChatHistory
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:31
chatModel
• chatModel: LLM
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:30
contextGenerator
• contextGenerator: ContextGenerator
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:32
Methods
_getPromptModules
▸ _getPromptModules(): Record
<string
, ContextGenerator
>
Returns
Record
<string
, ContextGenerator
>
Overrides
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:53
_getPrompts
▸ _getPrompts(): PromptsDict
Returns
PromptsDict
Inherited from
Defined in
packages/core/src/prompts/Mixin.ts:78
_updatePrompts
▸ _updatePrompts(promptsDict
): void
Parameters
Name | Type |
---|---|
promptsDict | PromptsDict |
Returns
void
Inherited from
Defined in
packages/core/src/prompts/Mixin.ts:86
chat
▸ chat(params
): Promise
<AsyncIterable
<Response
>>
Send message along with the class's current chat history to the LLM.
Parameters
Name | Type |
---|---|
params | ChatEngineParamsStreaming |
Returns
Promise
<AsyncIterable
<Response
>>
Implementation of
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:59
▸ chat(params
): Promise
<Response
>
Parameters
Name | Type |
---|---|
params | ChatEngineParamsNonStreaming |
Returns
Promise
<Response
>
Implementation of
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:60
getPrompts
▸ getPrompts(): PromptsDict
Returns all prompts from the mixin and its modules
Returns
PromptsDict
Inherited from
Defined in
packages/core/src/prompts/Mixin.ts:27
prepareRequestMessages
▸ prepareRequestMessages(message
, chatHistory
): Promise
<{ messages
: ChatMessage
[] ; nodes
: BaseNode
<Metadata
>[] }>
Parameters
Name | Type |
---|---|
message | MessageContent |
chatHistory | ChatHistory |
Returns
Promise
<{ messages
: ChatMessage
[] ; nodes
: BaseNode
<Metadata
>[] }>
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:101
reset
▸ reset(): void
Resets the chat history so that it's empty.
Returns
void
Implementation of
Defined in
packages/core/src/engines/chat/ContextChatEngine.ts:97
updatePrompts
▸ updatePrompts(promptsDict
): void
Updates the prompts in the mixin and its modules
Parameters
Name | Type |
---|---|
promptsDict | PromptsDict |
Returns
void
Inherited from
Defined in
packages/core/src/prompts/Mixin.ts:48
validatePrompts
▸ validatePrompts(promptsDict
, moduleDict
): void
Validates the prompt keys and module keys
Parameters
Name | Type |
---|---|
promptsDict | PromptsDict |
moduleDict | ModuleDict |
Returns
void