class PromptVariant
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Bedrock.Alpha.PromptVariant |
![]() | github.com/aws/aws-cdk-go/awsbedrockalpha/v2#PromptVariant |
![]() | software.amazon.awscdk.services.bedrock.alpha.PromptVariant |
![]() | aws_cdk.aws_bedrock_alpha.PromptVariant |
![]() | @aws-cdk/aws-bedrock-alpha ยป PromptVariant |
Factory class for creating prompt variants.
Provides static methods to create different types of prompt variants with proper configuration and type safety.
Example
const cmk = new kms.Key(this, 'cmk', {});
// Assuming you have an existing agent and alias
const agent = bedrock.Agent.fromAgentAttributes(this, 'ImportedAgent', {
agentArn: 'arn:aws:bedrock:region:account:agent/agent-id',
roleArn: 'arn:aws:iam::account:role/agent-role',
});
const agentAlias = bedrock.AgentAlias.fromAttributes(this, 'ImportedAlias', {
aliasId: 'alias-id',
aliasName: 'my-alias',
agentVersion: '1',
agent: agent,
});
const agentVariant = bedrock.PromptVariant.agent({
variantName: 'agent-variant',
model: bedrock.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: ['task'],
});
new bedrock.Prompt(this, 'agentPrompt', {
promptName: 'agent-prompt',
description: 'Prompt for agent interactions',
defaultVariant: agentVariant,
variants: [agentVariant],
kmsKey: cmk,
});
Methods
Name | Description |
---|---|
static agent(props) | Creates an agent prompt template variant. |
static chat(props) | Creates a chat template variant. |
static text(props) | Creates a text template variant. |
static agent(props)
public static agent(props: AgentPromptVariantProps): IPromptVariant
Parameters
- props
Agent
โ - Properties for the agent prompt variant.Prompt Variant Props
Returns
Creates an agent prompt template variant.
static chat(props)
public static chat(props: ChatPromptVariantProps): IPromptVariant
Parameters
- props
Chat
โ - Properties for the chat prompt variant.Prompt Variant Props
Returns
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.
static text(props)
public static text(props: TextPromptVariantProps): IPromptVariant
Parameters
- props
Text
โ - Properties for the text prompt variant.Prompt Variant Props
Returns
Creates a text template variant.