class Topic
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Bedrock.Alpha.Topic |
![]() | github.com/aws/aws-cdk-go/awsbedrockalpha/v2#Topic |
![]() | software.amazon.awscdk.services.bedrock.alpha.Topic |
![]() | aws_cdk.aws_bedrock_alpha.Topic |
![]() | @aws-cdk/aws-bedrock-alpha ยป Topic |
Represents predefined topics that can be used to filter content.
Example
const guardrail = new bedrock.Guardrail(this, 'bedrockGuardrails', {
guardrailName: 'my-BedrockGuardrails',
// Configure tier for topic filters (optional)
topicsTierConfig: bedrock.TierConfig.STANDARD,
});
// Use a predefined topic
guardrail.addDeniedTopicFilter(bedrock.Topic.FINANCIAL_ADVICE);
// Create a custom topic with input/output actions
guardrail.addDeniedTopicFilter(
bedrock.Topic.custom({
name: 'Legal_Advice',
definition: 'Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities.',
examples: [
'Can I sue someone for this?',
'What are my legal rights in this situation?',
'Is this action against the law?',
'What should I do to file a legal complaint?',
'Can you explain this law to me?',
],
// props below are optional
inputAction: bedrock.GuardrailAction.BLOCK,
inputEnabled: true,
outputAction: bedrock.GuardrailAction.NONE,
outputEnabled: true,
})
);
Initializer (protected)
super(props: CustomTopicProps)
Parameters
- props
Custom
Topic Props
Properties
Name | Type | Description |
---|---|---|
definition | string | Definition of the topic. |
name | string | The name of the topic to deny. |
examples? | string[] | Representative phrases that refer to the topic. |
input | Guardrail | The action to take when a topic is detected in the input. |
input | boolean | Whether the topic filter is enabled for input. |
output | Guardrail | The action to take when a topic is detected in the output. |
output | boolean | Whether the topic filter is enabled for output. |
static FINANCIAL_ADVICE | Topic | Filter for financial advice and investment recommendations. |
static INAPPROPRIATE_CONTENT | Topic | Filter for inappropriate or explicit content. |
static LEGAL_ADVICE | Topic | Filter for legal advice and recommendations. |
static MEDICAL_ADVICE | Topic | Filter for medical advice and health recommendations. |
static POLITICAL_ADVICE | Topic | Filter for political advice and recommendations. |
definition
Type:
string
Definition of the topic.
name
Type:
string
The name of the topic to deny.
examples?
Type:
string[]
(optional)
Representative phrases that refer to the topic.
inputAction?
Type:
Guardrail
(optional, default: GuardrailAction.BLOCK)
The action to take when a topic is detected in the input.
inputEnabled?
Type:
boolean
(optional, default: true)
Whether the topic filter is enabled for input.
outputAction?
Type:
Guardrail
(optional, default: GuardrailAction.BLOCK)
The action to take when a topic is detected in the output.
outputEnabled?
Type:
boolean
(optional, default: true)
Whether the topic filter is enabled for output.
static FINANCIAL_ADVICE
Type:
Topic
Filter for financial advice and investment recommendations.
static INAPPROPRIATE_CONTENT
Type:
Topic
Filter for inappropriate or explicit content.
static LEGAL_ADVICE
Type:
Topic
Filter for legal advice and recommendations.
static MEDICAL_ADVICE
Type:
Topic
Filter for medical advice and health recommendations.
static POLITICAL_ADVICE
Type:
Topic
Filter for political advice and recommendations.
Methods
Name | Description |
---|---|
static custom(props) | Create a custom topic filter. |
static custom(props)
public static custom(props: CustomTopicProps): Topic
Parameters
- props
Custom
โ Properties for the custom topic filter.Topic Props
Returns
Create a custom topic filter.