The PromptTemplate class is part of the ai.knowly.langtoch.prompt.template package. It represents a string template with variables that can be replaced with specified values. The template uses the format {{$var}} for variables, where variables must be one or more word characters (letters, digits, or underscores).
Usage
To create an instance of the PromptTemplate, use the builder() method to create a new Builder object. Use the builder's methods to set the template, examples, example header, and variables as needed, then call build() to create the PromptTemplate.
The format() method replaces the variables in the template with their corresponding values and returns the formatted string. If an optional example header and examples are provided, they are included in the formatted string.
The Builder class is an inner class of PromptTemplate. It is used to create instances of the PromptTemplate class. The following methods are available:
setTemplate(String template)
Sets the template string containing variables in the form of {{$var}}.
setExamples(List<String> examples)
Sets a list of strings to be used as examples for few-shot prompting.
setExampleHeader(String exampleHeader)
Sets an optional string that can be used to describe the examples.