Optional
allowOptional
endThe message type to end on.
If specified then every message after the last occurrence of this type is ignored.
If strategy === "last"
then this is done before we attempt to get the last maxTokens
.
If strategy === "first"
then this is done after we get the first maxTokens
.
Can be specified as string names (e.g. "system", "human", "ai", ...) or as BaseMessage
classes
(e.g. SystemMessage
, HumanMessage
, AIMessage
, ...). Can be a single type or an array of types.
Optional
includeOptional
startThe message type to start on.
Should only be specified if strategy: "last"
. If specified then every message before the first occurrence
of this type is ignored. This is done after we trim the initial messages to the last maxTokens
.
Does not apply to a SystemMessage
at index 0 if includeSystem: true
.
Can be specified as string names (e.g. "system", "human", "ai", ...) or as BaseMessage
classes
(e.g. SystemMessage
, HumanMessage
, AIMessage
, ...). Can be a single type or an array of types.
Optional
strategyOptional
textFunction or BaseDocumentTransformer
for
splitting the string contents of a message. Only used if allowPartial: true
.
If strategy: "last"
then the last split tokens from a partial message will be included.
If strategy: "first"
then the first split tokens from a partial message will be included.
Token splitter assumes that separators are kept, so that split contents can be directly concatenated
to recreate the original text. Defaults to splitting on newlines.
Param: allowPartial
Whether to split a message if only part of the message can be included. If
strategy: "last"
then the last partial contents of a message are included. Ifstrategy: "first"
then the first partial contents of a message are included.Default