Skip to content

< Back


PromptTemplateTransformer

Namespace: LLama.Transformers

A prompt formatter that will use llama.cpp's template formatter If your model is not supported, you will need to define your own formatter according the cchat prompt specification for your model

1
public class PromptTemplateTransformer : LLama.Abstractions.IHistoryTransform

Inheritance ObjectPromptTemplateTransformer
Implements IHistoryTransform
Attributes NullableContextAttribute, NullableAttribute

Constructors

PromptTemplateTransformer(LLamaWeights, Boolean)

A prompt formatter that will use llama.cpp's template formatter If your model is not supported, you will need to define your own formatter according the cchat prompt specification for your model

1
public PromptTemplateTransformer(LLamaWeights model, bool withAssistant)

Parameters

model LLamaWeights

withAssistant Boolean

Methods

HistoryToText(ChatHistory)

1
public string HistoryToText(ChatHistory history)

Parameters

history ChatHistory

Returns

String

TextToHistory(AuthorRole, String)

1
public ChatHistory TextToHistory(AuthorRole role, string text)

Parameters

role AuthorRole

text String

Returns

ChatHistory

Clone()

1
public IHistoryTransform Clone()

Returns

IHistoryTransform

ToModelPrompt(LLamaTemplate)

Apply the template to the messages and return the resulting prompt as a string

1
public static string ToModelPrompt(LLamaTemplate template)

Parameters

template LLamaTemplate

Returns

String
The formatted template string as defined by the model


< Back