Package com.sap.ai.sdk.orchestration
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceIntermediate object to build a template reference.static interfaceIntermediate object to build a template reference with the given scenario, name, and version.static interfaceIntermediate object to build a template reference with the given scenario, name, and version.static interfaceIntermediate object to build a template reference with the given scenario, name, and version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanstatic LocalPromptTemplateBuild a template from the given messages.static LocalPromptTemplateBuild a template containing a single user message.booleanstatic LocalPromptTemplateCreate anLocalPromptTemplatefrom a JSON provided as String.static LocalPromptTemplateCreate anLocalPromptTemplatefrom a YAML provided as String.Get the placeholder values supplied for this template.Get the message history to prepend to the conversation for this template.inthashCode()Build a template reference with tenant level scope.protected abstract PromptTemplatingModuleConfigPromptCreate a low-level representation of the template.
-
Constructor Details
-
PromptTemplate
public PromptTemplate()
-
-
Method Details
-
getInputParameters
Get the placeholder values supplied for this template.- Returns:
- the placeholder values supplied for this template.
-
getMessageHistory
Get the message history to prepend to the conversation for this template.- Returns:
- the message history for this template.
-
toLowLevel
Create a low-level representation of the template.- Returns:
- the low-level representation of the template.
-
create
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
Create anLocalPromptTemplatefrom 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
Create anLocalPromptTemplatefrom 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
Build a template reference with tenant level scope.- Returns:
- an intermediate object to build the template reference.
-
equals
-
canEqual
-
hashCode
public int hashCode()
-