Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
PromptVariant Class
Factory class for creating prompt variants.
Provides static methods to create different types of prompt variants with proper configuration and type safety.
Example
ts
const cmk = new kms.Key(this, 'cmk', {});
const claudeModel = bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_SONNET_V1_0;
const variant1 = bedrock.PromptVariant.text({
variantName: 'variant1',
model: claudeModel,
promptVariables: ['topic'],
promptText: 'This is my first text prompt. Please summarize our conversation on: {{topic}}.',
inferenceConfiguration: bedrock.PromptInferenceConfiguration.text({
temperature: 1.0,
topP: 0.999,
maxTokens: 2000,
}),
});
const prompt1 = new bedrock.Prompt(this, 'prompt1', {
promptName: 'prompt1',
description: 'my first prompt',
defaultVariant: variant1,
variants: [variant1],
kmsKey: cmk,
});
Methods
agent(props: AgentPromptVariantProps): IPromptVariant@staticmethod def agent(props: AgentPromptVariantProps) -> IPromptVariantpublic static IPromptVariant agent(AgentPromptVariantProps props)public static IPromptVariant Agent(AgentPromptVariantProps props)func Agent(Props AgentPromptVariantProps) IPromptVariantstatic#Creates an agent prompt template variant.
1 parameter · returns
Parameters
propspropspropspropsProps— - Properties for the agent prompt variant.
Returns: A PromptVariant configured for agent interactions
chat(props: ChatPromptVariantProps): IPromptVariant@staticmethod def chat(props: ChatPromptVariantProps) -> IPromptVariantpublic static IPromptVariant chat(ChatPromptVariantProps props)public static IPromptVariant Chat(ChatPromptVariantProps props)func Chat(Props ChatPromptVariantProps) IPromptVariantstatic#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.
1 parameter · returns
Parameters
propspropspropspropsProps— - Properties for the chat prompt variant.
Returns: A PromptVariant configured for chat interactions
text(props: TextPromptVariantProps): IPromptVariant@staticmethod def text(props: TextPromptVariantProps) -> IPromptVariantpublic static IPromptVariant text(TextPromptVariantProps props)public static IPromptVariant Text(TextPromptVariantProps props)func Text(Props TextPromptVariantProps) IPromptVariantstatic#Creates a text template variant.
1 parameter · returns
Parameters
propspropspropspropsProps— - Properties for the text prompt variant.
Returns: A PromptVariant configured for text processing