Class Template
java.lang.Object
com.sap.ai.sdk.prompt.registry.model.Template
- All Implemented Interfaces:
PromptTemplatingModuleConfigPrompt
Template
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTemplateItem(ChatMessage templateItem) Add one template instance to thisTemplate.addToolsItem(ChatCompletionTool toolsItem) Add one tools instance to thisTemplate.static Template.Buildercreate()Create a type-safe, fluent-api builder object to construct a newTemplateinstance with all required arguments.Set the defaults of thisTemplateinstance and return the same instance.booleangetCustomField(String name) Deprecated.Get the names of the unrecognizable properties of theTemplate.Optional default values for the template.Get responseFormatA chat message array to be formatted with values from placeholder_values.getTools()A list of tools the model may call.inthashCode()putdefaultsItem(String key, String defaultsItem) Put one defaults instance to thisTemplateinstance.responseFormat(TemplateResponseFormat responseFormat) Set the responseFormat of thisTemplateinstance and return the same instance.voidsetCustomField(String customFieldName, Object customFieldValue) Set an unrecognizable property of thisTemplateinstance.voidsetDefaults(Map<String, String> defaults) Set the defaults of thisTemplateinstance.voidsetResponseFormat(TemplateResponseFormat responseFormat) Set the responseFormat of thisTemplateinstance.voidsetTemplate(List<ChatMessage> template) Set the template of thisTemplateinstance.voidsetTools(List<ChatCompletionTool> tools) Set the tools of thisTemplateinstance.template(List<ChatMessage> template) Set the template of thisTemplateinstance and return the same instance.toMap()Get the value of all properties of thisTemplateinstance including unrecognized properties.tools(List<ChatCompletionTool> tools) Set the tools of thisTemplateinstance and return the same instance.toString()
-
Constructor Details
-
Template
protected Template()Default constructor for Template.
-
-
Method Details
-
template
Set the template of thisTemplateinstance and return the same instance.- Parameters:
template- A chat message array to be formatted with values from placeholder_values. Both role and content can be templated. If messages_history is provided, the templated messages will be appended.- Returns:
- The same instance of this
Templateclass
-
addTemplateItem
Add one template instance to thisTemplate.- Parameters:
templateItem- The template that should be added- Returns:
- The same instance of type
Template
-
getTemplate
A chat message array to be formatted with values from placeholder_values. Both role and content can be templated. If messages_history is provided, the templated messages will be appended.- Returns:
- template The template of this
Templateinstance.
-
setTemplate
Set the template of thisTemplateinstance.- Parameters:
template- A chat message array to be formatted with values from placeholder_values. Both role and content can be templated. If messages_history is provided, the templated messages will be appended.
-
defaults
Set the defaults of thisTemplateinstance and return the same instance.- Parameters:
defaults- Optional default values for the template. If a parameter has no default it is required.- Returns:
- The same instance of this
Templateclass
-
putdefaultsItem
Put one defaults instance to thisTemplateinstance.- Parameters:
key- The String key of this defaults instancedefaultsItem- The defaults that should be added under the given key- Returns:
- The same instance of type
Template
-
getDefaults
Optional default values for the template. If a parameter has no default it is required.- Returns:
- defaults The defaults of this
Templateinstance.
-
setDefaults
Set the defaults of thisTemplateinstance.- Parameters:
defaults- Optional default values for the template. If a parameter has no default it is required.
-
responseFormat
Set the responseFormat of thisTemplateinstance and return the same instance. -
getResponseFormat
Get responseFormat- Returns:
- responseFormat The responseFormat of this
Templateinstance.
-
setResponseFormat
Set the responseFormat of thisTemplateinstance.- Parameters:
responseFormat- The responseFormat of thisTemplate
-
tools
Set the tools of thisTemplateinstance and return the same instance.- Parameters:
tools- A list of tools the model may call. Used to provide a list of functions the model may generate JSON inputs for. This is the same as the OpenAI definition.- Returns:
- The same instance of this
Templateclass
-
addToolsItem
Add one tools instance to thisTemplate.- Parameters:
toolsItem- The tools that should be added- Returns:
- The same instance of type
Template
-
getTools
A list of tools the model may call. Used to provide a list of functions the model may generate JSON inputs for. This is the same as the OpenAI definition.- Returns:
- tools The tools of this
Templateinstance.
-
setTools
Set the tools of thisTemplateinstance.- Parameters:
tools- A list of tools the model may call. Used to provide a list of functions the model may generate JSON inputs for. This is the same as the OpenAI definition.
-
getCustomFieldNames
Get the names of the unrecognizable properties of theTemplate.- Returns:
- The set of properties names
-
getCustomField
@Nullable @Deprecated public Object getCustomField(@Nonnull String name) throws NoSuchElementException Deprecated.UsetoMap()instead.Get the value of an unrecognizable property of thisTemplateinstance.- Parameters:
name- The name of the property- Returns:
- The value of the property
- Throws:
NoSuchElementException- If no property with the given name could be found.
-
toMap
Get the value of all properties of thisTemplateinstance including unrecognized properties.- Returns:
- The map of all properties
-
setCustomField
Set an unrecognizable property of thisTemplateinstance. If the map previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
customFieldName- The name of the propertycustomFieldValue- The value of the property
-
equals
-
hashCode
public int hashCode() -
toString
-
create
Create a type-safe, fluent-api builder object to construct a newTemplateinstance with all required arguments.
-
toMap()instead.