> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# CustomTopicProps

Interface for creating a custom Topic.

Used as props by: [Topic](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.Topic.html)
Used as argument in: [Topic.custom](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.Topic.html#custom)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`bedrock/guardrails/guardrail-filters.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/guardrails/guardrail-filters.ts#L173)

## Example

TypeScript:

```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,
  })
);
```

Python:

```python
guardrail = bedrock.Guardrail(self, "bedrockGuardrails",
    guardrail_name="my-BedrockGuardrails",
    # Configure tier for topic filters (optional)
    topics_tier_config=bedrock.TierConfig.STANDARD
)

# Use a predefined topic
guardrail.add_denied_topic_filter(bedrock.Topic.FINANCIAL_ADVICE)

# Create a custom topic with input/output actions
guardrail.add_denied_topic_filter(
    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
        input_action=bedrock.GuardrailAction.BLOCK,
        input_enabled=True,
        output_action=bedrock.GuardrailAction.NONE,
        output_enabled=True
    ))
```

Java:

```java
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()));
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var guardrail = new Guardrail(this, "bedrockGuardrails", new GuardrailProps {
    GuardrailName = "my-BedrockGuardrails",
    // Configure tier for topic filters (optional)
    TopicsTierConfig = TierConfig.STANDARD
});

// Use a predefined topic
guardrail.AddDeniedTopicFilter(Topic.FINANCIAL_ADVICE);

// Create a custom topic with input/output actions
guardrail.AddDeniedTopicFilter(Topic.Custom(new CustomTopicProps {
    Name = "Legal_Advice",
    Definition = "Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities.",
    Examples = new [] { "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
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
guardrail := bedrock.NewGuardrail(this, jsii.String("bedrockGuardrails"), &GuardrailProps{
	GuardrailName: jsii.String("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(&CustomTopicProps{
	Name: jsii.String("Legal_Advice"),
	Definition: jsii.String("Offering guidance or suggestions on legal matters, legal actions, interpretation of laws, or legal rights and responsibilities."),
	Examples: []*string{
		jsii.String("Can I sue someone for this?"),
		jsii.String("What are my legal rights in this situation?"),
		jsii.String("Is this action against the law?"),
		jsii.String("What should I do to file a legal complaint?"),
		jsii.String("Can you explain this law to me?"),
	},
	// props below are optional
	InputAction: bedrock.GuardrailAction_BLOCK,
	InputEnabled: jsii.Boolean(true),
	OutputAction: bedrock.GuardrailAction_NONE,
	OutputEnabled: jsii.Boolean(true),
}))
```

## Properties

- `definition`: string (required) — Provide a clear definition to detect and block user inputs and FM responses that fall into this topic.

  Avoid starting with "don't".

  ```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.`
  ```

- `examples`: string[] (required) — 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.

  ```ts
  "Where should I invest my money?"
  ```

- `inputAction`: [GuardrailAction](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailAction.html) = GuardrailAction.BLOCK — The action to take when a topic is detected in the input.

- `inputEnabled`: boolean = true — Whether the topic filter is enabled for input.

- `name`: string (required) — The name of the topic to deny.

- `outputAction`: [GuardrailAction](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailAction.html) = GuardrailAction.BLOCK — The action to take when a topic is detected in the output.

- `outputEnabled`: boolean = true — Whether the topic filter is enabled for output.
