Class: SummaryChatHistory
A ChatHistory is used to keep the state of back and forth chat messages
Hierarchy
↳
SummaryChatHistory
Constructors
constructor
• new SummaryChatHistory(init?
)
Parameters
Name | Type |
---|---|
init? | Partial <SummaryChatHistory > |
Overrides
Defined in
packages/core/src/ChatHistory.ts:74
Properties
llm
• llm: LLM
Defined in
packages/core/src/ChatHistory.ts:71
messages
• messages: ChatMessage
[]
Overrides
Defined in
packages/core/src/ChatHistory.ts:69
messagesBefore
• Private
messagesBefore: number
Defined in
packages/core/src/ChatHistory.ts:72
summaryPrompt
• summaryPrompt: (__namedParameters
: Object
) => string
Type declaration
▸ («destructured»
): string
Parameters
Name | Type |
---|---|
«destructured» | Object |
Returns
string
Defined in
packages/core/src/ChatHistory.ts:70
tokensToSummarize
• tokensToSummarize: number
Defined in
packages/core/src/ChatHistory.ts:68
Accessors
nonSystemMessages
• Private
get
nonSystemMessages(): ChatMessage
[]
Returns
Defined in
packages/core/src/ChatHistory.ts:142
systemMessages
• Private
get
systemMessages(): ChatMessage
[]
Returns
Defined in
packages/core/src/ChatHistory.ts:137
Methods
addMessage
▸ addMessage(message
): void
Adds a message to the chat history.
Parameters
Name | Type |
---|---|
message | ChatMessage |
Returns
void
Overrides
Defined in
packages/core/src/ChatHistory.ts:116
calcConversationMessages
▸ Private
calcConversationMessages(transformSummary?
): ChatMessage
[]
Calculates the messages that describe the conversation so far. If there's no memory, all non-system messages are used. If there's a memory, uses all messages after the last summary message.
Parameters
Name | Type |
---|---|
transformSummary? | boolean |
Returns
Defined in
packages/core/src/ChatHistory.ts:152
calcCurrentRequestMessages
▸ Private
calcCurrentRequestMessages(transientMessages?
): ChatMessage
[]
Parameters
Name | Type |
---|---|
transientMessages? | ChatMessage [] |
Returns
Defined in
packages/core/src/ChatHistory.ts:170
getLastSummary
▸ getLastSummary(): null
| ChatMessage
Returns
null
| ChatMessage
Defined in
packages/core/src/ChatHistory.ts:132
getLastSummaryIndex
▸ Private
getLastSummaryIndex(): null
| number
Returns
null
| number
Defined in
packages/core/src/ChatHistory.ts:121
newMessages
▸ newMessages(): ChatMessage
[]
Returns the new messages since the last call to this function (or since calling the constructor)
Returns
Overrides
Defined in
packages/core/src/ChatHistory.ts:210
requestMessages
▸ requestMessages(transientMessages?
): Promise
<ChatMessage
[]>
Returns the messages that should be used as input to the LLM.
Parameters
Name | Type |
---|---|
transientMessages? | ChatMessage [] |
Returns
Promise
<ChatMessage
[]>
Overrides
Defined in
packages/core/src/ChatHistory.ts:180
reset
▸ reset(): void
Resets the chat history so that it's empty.
Returns
void
Overrides
Defined in
packages/core/src/ChatHistory.ts:206
summarize
▸ Private
summarize(): Promise
<ChatMessage
>
Returns
Promise
<ChatMessage
>