Class PromptVariant
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.bedrock.alpha.PromptVariant
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)",
date="2025-07-29T17:51:11.513Z")
@Stability(Experimental)
public class PromptVariant
extends software.amazon.jsii.JsiiObject
(experimental) Factory class for creating prompt variants.
Provides static methods to create different types of prompt variants with proper configuration and type safety.
Example:
Key cmk = Key.Builder.create(this, "cmk").build(); // Assuming you have an existing agent and alias IAgent agent = Agent.fromAgentAttributes(this, "ImportedAgent", AgentAttributes.builder() .agentArn("arn:aws:bedrock:region:account:agent/agent-id") .roleArn("arn:aws:iam::account:role/agent-role") .build()); IAgentAlias agentAlias = AgentAlias.fromAttributes(this, "ImportedAlias", AgentAliasAttributes.builder() .aliasId("alias-id") .aliasName("my-alias") .agentVersion("1") .agent(agent) .build()); IPromptVariant agentVariant = PromptVariant.agent(AgentPromptVariantProps.builder() .variantName("agent-variant") .model(BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0) .agentAlias(agentAlias) .promptText("Use the agent to help with: {{task}}. Please be thorough and provide detailed explanations.") .promptVariables(List.of("task")) .build()); Prompt.Builder.create(this, "agentPrompt") .promptName("agent-prompt") .description("Prompt for agent interactions") .defaultVariant(agentVariant) .variants(List.of(agentVariant)) .kmsKey(cmk) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PromptVariant
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
PromptVariant
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic IPromptVariant
agent
(AgentPromptVariantProps props) (experimental) Creates an agent prompt template variant.static IPromptVariant
chat
(ChatPromptVariantProps props) (experimental) Creates a chat template variant.static IPromptVariant
text
(TextPromptVariantProps props) (experimental) Creates a text template variant.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
PromptVariant
protected PromptVariant(software.amazon.jsii.JsiiObjectRef objRef) -
PromptVariant
protected PromptVariant(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
agent
@Stability(Experimental) @NotNull public static IPromptVariant agent(@NotNull AgentPromptVariantProps props) (experimental) Creates an agent prompt template variant.- Parameters:
props
-- Properties for the agent prompt variant.
- Returns:
- A PromptVariant configured for agent interactions
-
chat
@Stability(Experimental) @NotNull public static IPromptVariant chat(@NotNull ChatPromptVariantProps props) (experimental) Creates a chat template variant.Use this template type when the model supports the Converse API or the Anthropic Claude Messages API. This allows you to include a System prompt and previous User messages and Assistant messages for context.
- Parameters:
props
-- Properties for the chat prompt variant.
- Returns:
- A PromptVariant configured for chat interactions
-
text
@Stability(Experimental) @NotNull public static IPromptVariant text(@NotNull TextPromptVariantProps props) (experimental) Creates a text template variant.- Parameters:
props
-- Properties for the text prompt variant.
- Returns:
- A PromptVariant configured for text processing
-