Skip to content
v2.275.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

CustomTopicProps Struct ​

Interface for creating a custom Topic.

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 ​

definitionstringdefinitionstrdefinitionStringDefinitionstringDefinition*stringrequired#
Provide a clear definition to detect and block user inputs and FM responses that fall into this topic.

Avoid starting with "don't".

example
ts
`Investment advice refers to inquiries, guidance, or recommendations
regarding the management or allocation of funds or assets with the goal of
generating returns or achieving specific financial objectives.`
examplesstring[]examplestyping.List[str]examplesList<String>Examplesstring[]Examples*[]*stringrequired#
Representative phrases that refer to the topic.

These phrases can represent a user input or a model response. Add between 1 and 100 phrases, up to 100 characters each.

example
ts
"Where should I invest my money?"
inputActionoptionalGuardrailActioninput_actionoptionalGuardrailActioninputActionoptionalGuardrailActionInputActionoptionalGuardrailActionInputActionoptionalGuardrailAction= GuardrailAction.BLOCK#
The action to take when a topic is detected in the input.
inputEnabledoptionalbooleaninput_enabledoptionalboolinputEnabledoptionalBooleanInputEnabledoptionalboolInputEnabledoptional*bool= true#
Whether the topic filter is enabled for input.
namestringnamestrnameStringNamestringName*stringrequired#
The name of the topic to deny.
outputActionoptionalGuardrailActionoutput_actionoptionalGuardrailActionoutputActionoptionalGuardrailActionOutputActionoptionalGuardrailActionOutputActionoptionalGuardrailAction= GuardrailAction.BLOCK#
The action to take when a topic is detected in the output.
outputEnabledoptionalbooleanoutput_enabledoptionalbooloutputEnabledoptionalBooleanOutputEnabledoptionalboolOutputEnabledoptional*bool= true#
Whether the topic filter is enabled for output.