Class: JinjaTemplateChatWrapper
A chat wrapper based on a Jinja template. Useful for using the original model's Jinja template as-is without any additional conversion work to chat with a model.
If you want to create a new chat wrapper from scratch, using this chat wrapper is not recommended, and instead you better inherit from the ChatWrapper
class and implement a custom chat wrapper of your own in TypeScript.
For a simpler way to create a chat wrapper, see the TemplateChatWrapper
class.
Example
import {JinjaTemplateChatWrapper} from "node-llama-cpp";
const chatWrapper = new JinjaTemplateChatWrapper({
template: "<Jinja template here>",
// functionCallMessageTemplate: { // optional
// call: "[[call: {{functionName}}({{functionParams}})]]",
// result: " [[result: {{functionCallResult}}]]"
// }
});
Extends
Constructors
new JinjaTemplateChatWrapper()
new JinjaTemplateChatWrapper(options: JinjaTemplateChatWrapperOptions): JinjaTemplateChatWrapper
Parameters
Parameter | Type | Description |
---|---|---|
options | JinjaTemplateChatWrapperOptions |
Returns
Overrides
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:119
Properties
defaultSettings
static defaultSettings: ChatWrapperSettings;
Inherited from
Defined in
wrapperName
readonly wrapperName: "JinjaTemplate" = "JinjaTemplate";
Overrides
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:102
settings
readonly settings: ChatWrapperSettings;
Overrides
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:103
template
readonly template: string;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:105
modelRoleName
readonly modelRoleName: string;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:106
userRoleName
readonly userRoleName: string;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:107
systemRoleName
readonly systemRoleName: string;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:108
convertUnsupportedSystemMessagesToUserMessages?
readonly optional convertUnsupportedSystemMessagesToUserMessages: JinjaTemplateChatWrapperOptionsConvertMessageFormat;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:109
joinAdjacentMessagesOfTheSameType
readonly joinAdjacentMessagesOfTheSameType: boolean;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:110
trimLeadingWhitespaceInResponses
readonly trimLeadingWhitespaceInResponses: boolean;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:111
additionalRenderParameters?
readonly optional additionalRenderParameters: Record<string, any>;
Defined in
chatWrappers/generic/JinjaTemplateChatWrapper.ts:112
Methods
generateFunctionCallsAndResults()
generateFunctionCallsAndResults(functionCalls: ChatModelFunctionCall[], useRawCall: boolean): LlamaText
Parameters
Parameter | Type | Default value |
---|---|---|
functionCalls | ChatModelFunctionCall [] | undefined |
useRawCall | boolean | true |
Returns
Inherited from
ChatWrapper
.generateFunctionCallsAndResults
Defined in
generateFunctionCall()
generateFunctionCall(name: string, params: any): LlamaText
Parameters
Parameter | Type |
---|---|
name | string |
params | any |
Returns
Inherited from
ChatWrapper
.generateFunctionCall
Defined in
generateFunctionCallResult()
generateFunctionCallResult(
functionName: string,
functionParams: any,
result: any): LlamaText
Parameters
Parameter | Type |
---|---|
functionName | string |
functionParams | any |
result | any |
Returns
Inherited from
ChatWrapper
.generateFunctionCallResult
Defined in
generateModelResponseText()
generateModelResponseText(modelResponse: (string | ChatModelFunctionCall)[], useRawCall: boolean): LlamaText
Parameters
Parameter | Type | Default value |
---|---|---|
modelResponse | (string | ChatModelFunctionCall )[] | undefined |
useRawCall | boolean | true |
Returns
Inherited from
ChatWrapper
.generateModelResponseText
Defined in
generateAvailableFunctionsSystemText()
generateAvailableFunctionsSystemText(availableFunctions: ChatModelFunctions, __namedParameters: {
documentParams: true;
}): LlamaText
Parameters
Parameter | Type |
---|---|
availableFunctions | ChatModelFunctions |
__namedParameters | object |
__namedParameters.documentParams ? | boolean |
Returns
Inherited from
ChatWrapper
.generateAvailableFunctionsSystemText
Defined in
addAvailableFunctionsSystemMessageToHistory()
addAvailableFunctionsSystemMessageToHistory(
history: readonly ChatHistoryItem[],
availableFunctions?: ChatModelFunctions,
__namedParameters?: {
documentParams: true;
}): readonly ChatHistoryItem[]
Parameters
Parameter | Type |
---|---|
history | readonly ChatHistoryItem [] |
availableFunctions ? | ChatModelFunctions |
__namedParameters ? | object |
__namedParameters.documentParams ? | boolean |
Returns
readonly ChatHistoryItem
[]
Inherited from
ChatWrapper
.addAvailableFunctionsSystemMessageToHistory
Defined in
generateInitialChatHistory()
generateInitialChatHistory(__namedParameters: ChatWrapperGenerateInitialHistoryOptions): ChatHistoryItem[]
Parameters
Parameter | Type |
---|---|
__namedParameters | ChatWrapperGenerateInitialHistoryOptions |
Returns
Inherited from
ChatWrapper
.generateInitialChatHistory
Defined in
generateContextState()
generateContextState(__namedParameters: ChatWrapperGenerateContextStateOptions): ChatWrapperGeneratedContextState & {
transformedSystemMessagesToUserMessages: boolean;
}
Parameters
Parameter | Type |
---|---|
__namedParameters | ChatWrapperGenerateContextStateOptions |
Returns
ChatWrapperGeneratedContextState
& { transformedSystemMessagesToUserMessages
: boolean
; }
Overrides
ChatWrapper
.generateContextState