Class Template

java.lang.Object
com.sap.ai.sdk.orchestration.model.Template
All Implemented Interfaces:
PromptTemplatingModuleConfigPrompt

public class Template extends Object implements PromptTemplatingModuleConfigPrompt
Template
  • Constructor Details

    • Template

      protected Template()
      Default constructor for Template.
  • Method Details

    • template

      @Nonnull public Template template(@Nonnull List<ChatMessage> template)
      Set the template of this Template instance 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 Template class
    • addTemplateItem

      @Nonnull public Template addTemplateItem(@Nonnull ChatMessage templateItem)
      Add one template instance to this Template.
      Parameters:
      templateItem - The template that should be added
      Returns:
      The same instance of type Template
    • getTemplate

      @Nonnull public List<ChatMessage> 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 Template instance.
    • setTemplate

      public void setTemplate(@Nonnull List<ChatMessage> template)
      Set the template of this Template 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.
    • defaults

      @Nonnull public Template defaults(@Nullable Map<String,String> defaults)
      Set the defaults of this Template instance 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 Template class
    • putdefaultsItem

      @Nonnull public Template putdefaultsItem(@Nonnull String key, @Nonnull String defaultsItem)
      Put one defaults instance to this Template instance.
      Parameters:
      key - The String key of this defaults instance
      defaultsItem - The defaults that should be added under the given key
      Returns:
      The same instance of type Template
    • getDefaults

      @Nonnull public Map<String,String> getDefaults()
      Optional default values for the template. If a parameter has no default it is required.
      Returns:
      defaults The defaults of this Template instance.
    • setDefaults

      public void setDefaults(@Nullable Map<String,String> defaults)
      Set the defaults of this Template instance.
      Parameters:
      defaults - Optional default values for the template. If a parameter has no default it is required.
    • responseFormat

      @Nonnull public Template responseFormat(@Nullable TemplateResponseFormat responseFormat)
      Set the responseFormat of this Template instance and return the same instance.
      Parameters:
      responseFormat - The responseFormat of this Template
      Returns:
      The same instance of this Template class
    • getResponseFormat

      @Nonnull public TemplateResponseFormat getResponseFormat()
      Get responseFormat
      Returns:
      responseFormat The responseFormat of this Template instance.
    • setResponseFormat

      public void setResponseFormat(@Nullable TemplateResponseFormat responseFormat)
      Set the responseFormat of this Template instance.
      Parameters:
      responseFormat - The responseFormat of this Template
    • tools

      @Nonnull public Template tools(@Nullable List<ChatCompletionTool> tools)
      Set the tools of this Template instance 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 Template class
    • addToolsItem

      @Nonnull public Template addToolsItem(@Nonnull ChatCompletionTool toolsItem)
      Add one tools instance to this Template.
      Parameters:
      toolsItem - The tools that should be added
      Returns:
      The same instance of type Template
    • getTools

      @Nonnull public List<ChatCompletionTool> 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 Template instance.
    • setTools

      public void setTools(@Nullable List<ChatCompletionTool> tools)
      Set the tools of this Template 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.
    • getCustomFieldNames

      @Nonnull public Set<String> getCustomFieldNames()
      Get the names of the unrecognizable properties of the Template.
      Returns:
      The set of properties names
    • getCustomField

      @Nullable @Deprecated public Object getCustomField(@Nonnull String name) throws NoSuchElementException
      Deprecated.
      Use toMap() instead.
      Get the value of an unrecognizable property of this Template instance.
      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

      @Nonnull public Map<String,Object> toMap()
      Get the value of all properties of this Template instance including unrecognized properties.
      Returns:
      The map of all properties
    • setCustomField

      public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue)
      Set an unrecognizable property of this Template instance. 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 property
      customFieldValue - The value of the property
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • create

      public static Template.Builder create()
      Create a type-safe, fluent-api builder object to construct a new Template instance with all required arguments.