Class PromptTemplate

java.lang.Object
com.sap.ai.sdk.orchestration.PromptTemplate
Direct Known Subclasses:
LocalPromptTemplate, PromptTemplateReference

public abstract sealed class PromptTemplate extends Object permits LocalPromptTemplate, PromptTemplateReference
Create a prompt template locally or reference an existing prompt template stored in context registry. Upon request execution, this template will be enhanced with any messages and parameter values. SAP AI Core: Orchestration - Templating
Since:
2.0.0
  • Constructor Details

    • PromptTemplate

      public PromptTemplate()
  • Method Details

    • getInputParameters

      @Nonnull public abstract Map<String,String> getInputParameters()
      Get the placeholder values supplied for this template.
      Returns:
      the placeholder values supplied for this template.
    • getMessageHistory

      @Nonnull public abstract List<Message> getMessageHistory()
      Get the message history to prepend to the conversation for this template.
      Returns:
      the message history for this template.
    • toLowLevel

      @Nonnull protected abstract PromptTemplatingModuleConfigPrompt toLowLevel()
      Create a low-level representation of the template.
      Returns:
      the low-level representation of the template.
    • create

      @Nonnull public static LocalPromptTemplate create(@Nonnull String message)
      Build a template containing a single user message.
      Parameters:
      message - the text of the user message.
      Returns:
      a new template containing the user message.
    • create

      @Nonnull public static LocalPromptTemplate create(@Nonnull Message message, @Nonnull Message... moreMessages)
      Build a template from the given messages.
      Parameters:
      message - the first message to use in the template.
      moreMessages - additional messages to use in the template.
      Returns:
      a new template containing the given messages.
    • fromJson

      @Nonnull public static LocalPromptTemplate fromJson(@Nonnull String inputJson) throws IOException
      Create an LocalPromptTemplate from a JSON provided as String.
      Parameters:
      inputJson - the provided JSON.
      Returns:
      a template representing the provided JSON.
      Throws:
      IOException - if the JSON cannot be deserialized.
      Since:
      1.7.0
    • fromYaml

      @Nonnull public static LocalPromptTemplate fromYaml(@Nonnull String inputYaml) throws IOException
      Create an LocalPromptTemplate from a YAML provided as String.
      Parameters:
      inputYaml - the provided YAML.
      Returns:
      a template representing the provided YAML.
      Throws:
      IOException - if the YAML cannot be parsed or deserialized.
      Since:
      1.7.0
    • reference

      @Nonnull public static PromptTemplate.ReferenceBuilder reference()
      Build a template reference with tenant level scope.
      Returns:
      an intermediate object to build the template reference.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object