Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
PromptTemplateConfiguration Class
Abstract base class for prompt template configurations.
This provides a high-level abstraction over the underlying CloudFormation template configuration properties, offering a more developer-friendly interface while maintaining full compatibility with the underlying AWS Bedrock service.
| Stability | Experimental |
|---|---|
| Source | bedrock/prompts/prompt-template-configuration.ts |
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as bedrock_alpha from '@aws-cdk/aws-bedrock-alpha';
declare const chatMessage: bedrock_alpha.ChatMessage;
declare const tool: bedrock_alpha.Tool;
declare const toolChoice: bedrock_alpha.ToolChoice;
const promptTemplateConfiguration = bedrock_alpha.PromptTemplateConfiguration.chat({
messages: [chatMessage],
// the properties below are optional
inputVariables: ['inputVariables'],
system: 'system',
toolConfiguration: {
toolChoice: toolChoice,
tools: [tool],
},
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_bedrock_alpha as bedrock_alpha
# chat_message: bedrock_alpha.ChatMessage
# tool: bedrock_alpha.Tool
# tool_choice: bedrock_alpha.ToolChoice
prompt_template_configuration = bedrock_alpha.PromptTemplateConfiguration.chat(
messages=[chat_message],
# the properties below are optional
input_variables=["inputVariables"],
system="system",
tool_configuration=bedrock_alpha.ToolConfiguration(
tool_choice=tool_choice,
tools=[tool]
)
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.alpha.*;
ChatMessage chatMessage;
Tool tool;
ToolChoice toolChoice;
PromptTemplateConfiguration promptTemplateConfiguration = PromptTemplateConfiguration.chat(ChatTemplateConfigurationProps.builder()
.messages(List.of(chatMessage))
// the properties below are optional
.inputVariables(List.of("inputVariables"))
.system("system")
.toolConfiguration(ToolConfiguration.builder()
.toolChoice(toolChoice)
.tools(List.of(tool))
.build())
.build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock.Alpha;
ChatMessage chatMessage;
Tool tool;
ToolChoice toolChoice;
var promptTemplateConfiguration = PromptTemplateConfiguration.Chat(new ChatTemplateConfigurationProps {
Messages = new [] { chatMessage },
// the properties below are optional
InputVariables = new [] { "inputVariables" },
System = "system",
ToolConfiguration = new ToolConfiguration {
ToolChoice = toolChoice,
Tools = new [] { tool }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import bedrock_alpha "github.com/aws/aws-cdk-go/awsbedrockalpha"
var chatMessage ChatMessage
var tool Tool
var toolChoice ToolChoice
promptTemplateConfiguration := bedrock_alpha.PromptTemplateConfiguration_Chat(&ChatTemplateConfigurationProps{
Messages: []ChatMessage{
chatMessage,
},
// the properties below are optional
InputVariables: []*string{
jsii.String("inputVariables"),
},
System: jsii.String("system"),
ToolConfiguration: &ToolConfiguration{
ToolChoice: toolChoice,
Tools: []Tool{
tool,
},
},
})
Initializer
ts
new PromptTemplateConfiguration()
python
PromptTemplateConfiguration()
java
new PromptTemplateConfiguration()
csharp
new PromptTemplateConfiguration()
go
NewPromptTemplateConfiguration()
Methods
chat(props: ChatTemplateConfigurationProps): PromptTemplateConfiguration // chainable@staticmethod def chat(props: ChatTemplateConfigurationProps) -> PromptTemplateConfigurationpublic static PromptTemplateConfiguration chat(ChatTemplateConfigurationProps props)public static PromptTemplateConfiguration Chat(ChatTemplateConfigurationProps props)func Chat(Props ChatTemplateConfigurationProps) PromptTemplateConfiguration static #Creates a chat template configuration.
text(props: TextTemplateConfigurationProps): PromptTemplateConfiguration // chainable@staticmethod def text(props: TextTemplateConfigurationProps) -> PromptTemplateConfigurationpublic static PromptTemplateConfiguration text(TextTemplateConfigurationProps props)public static PromptTemplateConfiguration Text(TextTemplateConfigurationProps props)func Text(Props TextTemplateConfigurationProps) PromptTemplateConfiguration static #Creates a text template configuration.