Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Topic Class
Represents predefined topics that can be used to filter content.
Example
ts
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,
})
);
Properties
Definition of the topic.
examplesmay be undefinedstring[]examplesmay be undefinedtyping.List[str]examplesmay be undefinedList<String>Examplesmay be undefinedstring[]Examplesmay be undefined*[]*string#Representative phrases that refer to the topic.
FINANCIAL_ADVICETopicfinancial_adviceTopicFINANCIAL_ADVICETopicFINANCIAL_ADVICETopicFINANCIAL_ADVICETopicstatic#Filter for financial advice and investment recommendations.
INAPPROPRIATE_CONTENTTopicinappropriate_contentTopicINAPPROPRIATE_CONTENTTopicINAPPROPRIATE_CONTENTTopicINAPPROPRIATE_CONTENTTopicstatic#Filter for inappropriate or explicit content.
inputActionmay be undefinedGuardrailActioninput_actionmay be undefinedGuardrailActioninputActionmay be undefinedGuardrailActionInputActionmay be undefinedGuardrailActionInputActionmay be undefinedGuardrailAction= GuardrailAction.BLOCK#The action to take when a topic is detected in the input.
inputEnabledmay be undefinedbooleaninput_enabledmay be undefinedboolinputEnabledmay be undefinedBooleanInputEnabledmay be undefinedboolInputEnabledmay be undefined*bool= true#Whether the topic filter is enabled for input.
Filter for legal advice and recommendations.
MEDICAL_ADVICETopicmedical_adviceTopicMEDICAL_ADVICETopicMEDICAL_ADVICETopicMEDICAL_ADVICETopicstatic#Filter for medical advice and health recommendations.
The name of the topic to deny.
outputActionmay be undefinedGuardrailActionoutput_actionmay be undefinedGuardrailActionoutputActionmay be undefinedGuardrailActionOutputActionmay be undefinedGuardrailActionOutputActionmay be undefinedGuardrailAction= GuardrailAction.BLOCK#The action to take when a topic is detected in the output.
outputEnabledmay be undefinedbooleanoutput_enabledmay be undefinedbooloutputEnabledmay be undefinedBooleanOutputEnabledmay be undefinedboolOutputEnabledmay be undefined*bool= true#Whether the topic filter is enabled for output.
Methods
custom(props: CustomTopicProps): Topic // chainable@staticmethod def custom(props: CustomTopicProps) -> Topicpublic static Topic custom(CustomTopicProps props)public static Topic Custom(CustomTopicProps props)func Custom(Props CustomTopicProps) Topicstatic#Create a custom topic filter.
1 parameter
Parameters
propspropspropspropsProps— Properties for the custom topic filter.