Class: HistoryChatEngine
HistoryChatEngine is a ChatEngine that uses a ChatHistory
object
to keeps track of chat's message history.
A ChatHistory
object is passed as a parameter for each call to the chat
method,
so the state of the chat engine is preserved between calls.
Optionally, a ContextGenerator
can be used to generate an additional context for each call to chat
.
Constructors
constructor
• new HistoryChatEngine(init?
)
Parameters
Name | Type |
---|---|
init? | Partial <HistoryChatEngine > |
Defined in
packages/core/src/ChatEngine.ts:381
Properties
contextGenerator
• Optional
contextGenerator: ContextGenerator
Defined in
packages/core/src/ChatEngine.ts:379
llm
• llm: LLM
Defined in
packages/core/src/ChatEngine.ts:378
Methods
chat
▸ chat<T
, R
>(message
, chatHistory
, streaming?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | extends undefined | boolean = undefined |
R | T extends true ? AsyncGenerator <string , void , unknown > : Response |
Parameters
Name | Type |
---|---|
message | MessageContent |
chatHistory | ChatHistory |
streaming? | T |
Returns
Promise
<R
>
Defined in
packages/core/src/ChatEngine.ts:386
prepareRequestMessages
▸ Private
prepareRequestMessages(message
, chatHistory
): Promise
<ChatMessage
[]>
Parameters
Name | Type |
---|---|
message | MessageContent |
chatHistory | ChatHistory |
Returns
Promise
<ChatMessage
[]>
Defined in
packages/core/src/ChatEngine.ts:433
streamChat
▸ Protected
streamChat(message
, chatHistory
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
message | MessageContent |
chatHistory | ChatHistory |
Returns
AsyncGenerator
<string
, void
, unknown
>