Interface CustomTopicProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
CustomTopicProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.113.0 (build fc68b25)", date="2025-09-02T11:25:42.799Z") @Stability(Experimental) public interface CustomTopicProps extends software.amazon.jsii.JsiiSerializable
(experimental) Interface for creating a custom Topic.

Example:

 Guardrail guardrail = Guardrail.Builder.create(this, "bedrockGuardrails")
         .guardrailName("my-BedrockGuardrails")
         // Configure tier for topic filters (optional)
         .topicsTierConfig(TierConfig.STANDARD)
         .build();
 // Use a predefined topic
 guardrail.addDeniedTopicFilter(Topic.FINANCIAL_ADVICE);
 // Create a custom topic with input/output actions
 guardrail.addDeniedTopicFilter(Topic.custom(CustomTopicProps.builder()
         .name("Legal_Advice")
         .definition("Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities.")
         .examples(List.of("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(GuardrailAction.BLOCK)
         .inputEnabled(true)
         .outputAction(GuardrailAction.NONE)
         .outputEnabled(true)
         .build()));
 
  • Method Details

    • getDefinition

      @Stability(Experimental) @NotNull String getDefinition()
      (experimental) Provide a clear definition to detect and block user inputs and FM responses that fall into this topic.

      Avoid starting with "don't".

      Example:

       "Investment advice refers to inquiries, guidance, or recommendations\nregarding the management or allocation of funds or assets with the goal of\ngenerating returns or achieving specific financial objectives.";
       
    • getExamples

      @Stability(Experimental) @NotNull List<String> getExamples()
      (experimental) 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:

       "Where should I invest my money?";
       
    • getName

      @Stability(Experimental) @NotNull String getName()
      (experimental) The name of the topic to deny.
    • getInputAction

      @Stability(Experimental) @Nullable default GuardrailAction getInputAction()
      (experimental) The action to take when a topic is detected in the input.

      Default: GuardrailAction.BLOCK

    • getInputEnabled

      @Stability(Experimental) @Nullable default Boolean getInputEnabled()
      (experimental) Whether the topic filter is enabled for input.

      Default: true

    • getOutputAction

      @Stability(Experimental) @Nullable default GuardrailAction getOutputAction()
      (experimental) The action to take when a topic is detected in the output.

      Default: GuardrailAction.BLOCK

    • getOutputEnabled

      @Stability(Experimental) @Nullable default Boolean getOutputEnabled()
      (experimental) Whether the topic filter is enabled for output.

      Default: true

    • builder

      @Stability(Experimental) static CustomTopicProps.Builder builder()
      Returns:
      a CustomTopicProps.Builder of CustomTopicProps