class ChatMessage
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Bedrock.Alpha.ChatMessage |
![]() | github.com/aws/aws-cdk-go/awsbedrockalpha/v2#ChatMessage |
![]() | software.amazon.awscdk.services.bedrock.alpha.ChatMessage |
![]() | aws_cdk.aws_bedrock_alpha.ChatMessage |
![]() | @aws-cdk/aws-bedrock-alpha ยป ChatMessage |
Represents a message in a chat conversation.
Example
const cmk = new kms.Key(this, 'cmk', {});
const variantChat = bedrock.PromptVariant.chat({
variantName: 'variant1',
model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
messages: [
bedrock.ChatMessage.user('From now on, you speak Japanese!'),
bedrock.ChatMessage.assistant('Konnichiwa!'),
bedrock.ChatMessage.user('From now on, you speak {{language}}!'),
],
system: 'You are a helpful assistant that only speaks the language you`re told.',
promptVariables: ['language'],
toolConfiguration: {
toolChoice: bedrock.ToolChoice.AUTO,
tools: [
bedrock.Tool.function({
name: 'top_song',
description: 'Get the most popular song played on a radio station.',
inputSchema: {
type: 'object',
properties: {
sign: {
type: 'string',
description: 'The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.',
},
},
required: ['sign'],
},
}),
],
},
});
new bedrock.Prompt(this, 'prompt1', {
promptName: 'prompt-chat',
description: 'my first chat prompt',
defaultVariant: variantChat,
variants: [variantChat],
kmsKey: cmk,
});
Initializer
new ChatMessage(role: ChatMessageRole, text: string)
Parameters
- role
Chat
Message Role - text
string
Properties
Name | Type | Description |
---|---|---|
role | Chat | The role of the message sender. |
text | string | The text content of the message. |
role
Type:
Chat
The role of the message sender.
text
Type:
string
The text content of the message.
Methods
Name | Description |
---|---|
static assistant(text) | Creates an assistant message. |
static user(text) | Creates a user message. |
static assistant(text)
public static assistant(text: string): ChatMessage
Parameters
- text
string
โ - The text content of the assistant message.
Returns
Creates an assistant message.
static user(text)
public static user(text: string): ChatMessage
Parameters
- text
string
โ - The text content of the user message.
Returns
Creates a user message.