io.github.cdklabs.generative_ai_cdk_constructs.bedrock.GuardrailProps Maven / Gradle / Ivy
Show all versions of generative-ai-cdk-constructs Show documentation
package io.github.cdklabs.generative_ai_cdk_constructs.bedrock;
/**
* (experimental) Properties for creating a Guardrail.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.104.0 (build e79254c)", date = "2024-11-13T15:10:43.895Z")
@software.amazon.jsii.Jsii(module = io.github.cdklabs.generative_ai_cdk_constructs.$Module.class, fqn = "@cdklabs/generative-ai-cdk-constructs.bedrock.GuardrailProps")
@software.amazon.jsii.Jsii.Proxy(GuardrailProps.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface GuardrailProps extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) The name of the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull java.lang.String getName();
/**
* (experimental) The message to return when the guardrail blocks a prompt.
*
* Default: "Sorry, your query violates our usage policy."
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getBlockedInputMessaging() {
return null;
}
/**
* (experimental) The message to return when the guardrail blocks a model response.
*
* Default: "Sorry, I am unable to answer your question because of our usage policy."
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getBlockedOutputsMessaging() {
return null;
}
/**
* (experimental) The content filters to apply to the guardrail.
*
* Note, if one of
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getContentFilters() {
return null;
}
/**
* (experimental) The contextual grounding filters to apply to the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getContextualGroundingFilters() {
return null;
}
/**
* (experimental) Up to 30 denied topics to block user inputs or model responses associated with the topic.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getDeniedTopics() {
return null;
}
/**
* (experimental) The description of the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getDescription() {
return null;
}
/**
* (experimental) A custom KMS key to use for encrypting data.
*
* Default: "Your data is encrypted by default with a key that AWS owns and manages for you."
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.kms.IKey getKmsKey() {
return null;
}
/**
* (experimental) The managed word filters to apply to the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getManagedWordListFilters() {
return null;
}
/**
* (experimental) The PII filters to apply to the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getPiiFilters() {
return null;
}
/**
* (experimental) The regular expression (regex) filters to apply to the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getRegexFilters() {
return null;
}
/**
* (experimental) The word filters to apply to the guardrail.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getWordFilters() {
return null;
}
/**
* @return a {@link Builder} of {@link GuardrailProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link GuardrailProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.String name;
java.lang.String blockedInputMessaging;
java.lang.String blockedOutputsMessaging;
java.util.List contentFilters;
java.util.List contextualGroundingFilters;
java.util.List deniedTopics;
java.lang.String description;
software.amazon.awscdk.services.kms.IKey kmsKey;
java.util.List managedWordListFilters;
java.util.List piiFilters;
java.util.List regexFilters;
java.util.List wordFilters;
/**
* Sets the value of {@link GuardrailProps#getName}
* @param name The name of the guardrail. This parameter is required.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder name(java.lang.String name) {
this.name = name;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getBlockedInputMessaging}
* @param blockedInputMessaging The message to return when the guardrail blocks a prompt.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder blockedInputMessaging(java.lang.String blockedInputMessaging) {
this.blockedInputMessaging = blockedInputMessaging;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getBlockedOutputsMessaging}
* @param blockedOutputsMessaging The message to return when the guardrail blocks a model response.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder blockedOutputsMessaging(java.lang.String blockedOutputsMessaging) {
this.blockedOutputsMessaging = blockedOutputsMessaging;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getContentFilters}
* @param contentFilters The content filters to apply to the guardrail.
* Note, if one of
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder contentFilters(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ContentFilter> contentFilters) {
this.contentFilters = (java.util.List)contentFilters;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getContextualGroundingFilters}
* @param contextualGroundingFilters The contextual grounding filters to apply to the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder contextualGroundingFilters(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ContextualGroundingFilter> contextualGroundingFilters) {
this.contextualGroundingFilters = (java.util.List)contextualGroundingFilters;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getDeniedTopics}
* @param deniedTopics Up to 30 denied topics to block user inputs or model responses associated with the topic.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder deniedTopics(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Topic> deniedTopics) {
this.deniedTopics = (java.util.List)deniedTopics;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getDescription}
* @param description The description of the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder description(java.lang.String description) {
this.description = description;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getKmsKey}
* @param kmsKey A custom KMS key to use for encrypting data.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder kmsKey(software.amazon.awscdk.services.kms.IKey kmsKey) {
this.kmsKey = kmsKey;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getManagedWordListFilters}
* @param managedWordListFilters The managed word filters to apply to the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder managedWordListFilters(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ManagedWordFilterType> managedWordListFilters) {
this.managedWordListFilters = (java.util.List)managedWordListFilters;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getPiiFilters}
* @param piiFilters The PII filters to apply to the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder piiFilters(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PIIFilter> piiFilters) {
this.piiFilters = (java.util.List)piiFilters;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getRegexFilters}
* @param regexFilters The regular expression (regex) filters to apply to the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder regexFilters(java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.RegexFilter> regexFilters) {
this.regexFilters = (java.util.List)regexFilters;
return this;
}
/**
* Sets the value of {@link GuardrailProps#getWordFilters}
* @param wordFilters The word filters to apply to the guardrail.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder wordFilters(java.util.List wordFilters) {
this.wordFilters = wordFilters;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link GuardrailProps}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public GuardrailProps build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link GuardrailProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements GuardrailProps {
private final java.lang.String name;
private final java.lang.String blockedInputMessaging;
private final java.lang.String blockedOutputsMessaging;
private final java.util.List contentFilters;
private final java.util.List contextualGroundingFilters;
private final java.util.List deniedTopics;
private final java.lang.String description;
private final software.amazon.awscdk.services.kms.IKey kmsKey;
private final java.util.List managedWordListFilters;
private final java.util.List piiFilters;
private final java.util.List regexFilters;
private final java.util.List wordFilters;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.name = software.amazon.jsii.Kernel.get(this, "name", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.blockedInputMessaging = software.amazon.jsii.Kernel.get(this, "blockedInputMessaging", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.blockedOutputsMessaging = software.amazon.jsii.Kernel.get(this, "blockedOutputsMessaging", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.contentFilters = software.amazon.jsii.Kernel.get(this, "contentFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ContentFilter.class)));
this.contextualGroundingFilters = software.amazon.jsii.Kernel.get(this, "contextualGroundingFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ContextualGroundingFilter.class)));
this.deniedTopics = software.amazon.jsii.Kernel.get(this, "deniedTopics", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Topic.class)));
this.description = software.amazon.jsii.Kernel.get(this, "description", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.kmsKey = software.amazon.jsii.Kernel.get(this, "kmsKey", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.kms.IKey.class));
this.managedWordListFilters = software.amazon.jsii.Kernel.get(this, "managedWordListFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.ManagedWordFilterType.class)));
this.piiFilters = software.amazon.jsii.Kernel.get(this, "piiFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PIIFilter.class)));
this.regexFilters = software.amazon.jsii.Kernel.get(this, "regexFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.RegexFilter.class)));
this.wordFilters = software.amazon.jsii.Kernel.get(this, "wordFilters", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
@SuppressWarnings("unchecked")
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.name = java.util.Objects.requireNonNull(builder.name, "name is required");
this.blockedInputMessaging = builder.blockedInputMessaging;
this.blockedOutputsMessaging = builder.blockedOutputsMessaging;
this.contentFilters = (java.util.List)builder.contentFilters;
this.contextualGroundingFilters = (java.util.List)builder.contextualGroundingFilters;
this.deniedTopics = (java.util.List)builder.deniedTopics;
this.description = builder.description;
this.kmsKey = builder.kmsKey;
this.managedWordListFilters = (java.util.List)builder.managedWordListFilters;
this.piiFilters = (java.util.List)builder.piiFilters;
this.regexFilters = (java.util.List)builder.regexFilters;
this.wordFilters = builder.wordFilters;
}
@Override
public final java.lang.String getName() {
return this.name;
}
@Override
public final java.lang.String getBlockedInputMessaging() {
return this.blockedInputMessaging;
}
@Override
public final java.lang.String getBlockedOutputsMessaging() {
return this.blockedOutputsMessaging;
}
@Override
public final java.util.List getContentFilters() {
return this.contentFilters;
}
@Override
public final java.util.List getContextualGroundingFilters() {
return this.contextualGroundingFilters;
}
@Override
public final java.util.List getDeniedTopics() {
return this.deniedTopics;
}
@Override
public final java.lang.String getDescription() {
return this.description;
}
@Override
public final software.amazon.awscdk.services.kms.IKey getKmsKey() {
return this.kmsKey;
}
@Override
public final java.util.List getManagedWordListFilters() {
return this.managedWordListFilters;
}
@Override
public final java.util.List getPiiFilters() {
return this.piiFilters;
}
@Override
public final java.util.List getRegexFilters() {
return this.regexFilters;
}
@Override
public final java.util.List getWordFilters() {
return this.wordFilters;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("name", om.valueToTree(this.getName()));
if (this.getBlockedInputMessaging() != null) {
data.set("blockedInputMessaging", om.valueToTree(this.getBlockedInputMessaging()));
}
if (this.getBlockedOutputsMessaging() != null) {
data.set("blockedOutputsMessaging", om.valueToTree(this.getBlockedOutputsMessaging()));
}
if (this.getContentFilters() != null) {
data.set("contentFilters", om.valueToTree(this.getContentFilters()));
}
if (this.getContextualGroundingFilters() != null) {
data.set("contextualGroundingFilters", om.valueToTree(this.getContextualGroundingFilters()));
}
if (this.getDeniedTopics() != null) {
data.set("deniedTopics", om.valueToTree(this.getDeniedTopics()));
}
if (this.getDescription() != null) {
data.set("description", om.valueToTree(this.getDescription()));
}
if (this.getKmsKey() != null) {
data.set("kmsKey", om.valueToTree(this.getKmsKey()));
}
if (this.getManagedWordListFilters() != null) {
data.set("managedWordListFilters", om.valueToTree(this.getManagedWordListFilters()));
}
if (this.getPiiFilters() != null) {
data.set("piiFilters", om.valueToTree(this.getPiiFilters()));
}
if (this.getRegexFilters() != null) {
data.set("regexFilters", om.valueToTree(this.getRegexFilters()));
}
if (this.getWordFilters() != null) {
data.set("wordFilters", om.valueToTree(this.getWordFilters()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@cdklabs/generative-ai-cdk-constructs.bedrock.GuardrailProps"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GuardrailProps.Jsii$Proxy that = (GuardrailProps.Jsii$Proxy) o;
if (!name.equals(that.name)) return false;
if (this.blockedInputMessaging != null ? !this.blockedInputMessaging.equals(that.blockedInputMessaging) : that.blockedInputMessaging != null) return false;
if (this.blockedOutputsMessaging != null ? !this.blockedOutputsMessaging.equals(that.blockedOutputsMessaging) : that.blockedOutputsMessaging != null) return false;
if (this.contentFilters != null ? !this.contentFilters.equals(that.contentFilters) : that.contentFilters != null) return false;
if (this.contextualGroundingFilters != null ? !this.contextualGroundingFilters.equals(that.contextualGroundingFilters) : that.contextualGroundingFilters != null) return false;
if (this.deniedTopics != null ? !this.deniedTopics.equals(that.deniedTopics) : that.deniedTopics != null) return false;
if (this.description != null ? !this.description.equals(that.description) : that.description != null) return false;
if (this.kmsKey != null ? !this.kmsKey.equals(that.kmsKey) : that.kmsKey != null) return false;
if (this.managedWordListFilters != null ? !this.managedWordListFilters.equals(that.managedWordListFilters) : that.managedWordListFilters != null) return false;
if (this.piiFilters != null ? !this.piiFilters.equals(that.piiFilters) : that.piiFilters != null) return false;
if (this.regexFilters != null ? !this.regexFilters.equals(that.regexFilters) : that.regexFilters != null) return false;
return this.wordFilters != null ? this.wordFilters.equals(that.wordFilters) : that.wordFilters == null;
}
@Override
public final int hashCode() {
int result = this.name.hashCode();
result = 31 * result + (this.blockedInputMessaging != null ? this.blockedInputMessaging.hashCode() : 0);
result = 31 * result + (this.blockedOutputsMessaging != null ? this.blockedOutputsMessaging.hashCode() : 0);
result = 31 * result + (this.contentFilters != null ? this.contentFilters.hashCode() : 0);
result = 31 * result + (this.contextualGroundingFilters != null ? this.contextualGroundingFilters.hashCode() : 0);
result = 31 * result + (this.deniedTopics != null ? this.deniedTopics.hashCode() : 0);
result = 31 * result + (this.description != null ? this.description.hashCode() : 0);
result = 31 * result + (this.kmsKey != null ? this.kmsKey.hashCode() : 0);
result = 31 * result + (this.managedWordListFilters != null ? this.managedWordListFilters.hashCode() : 0);
result = 31 * result + (this.piiFilters != null ? this.piiFilters.hashCode() : 0);
result = 31 * result + (this.regexFilters != null ? this.regexFilters.hashCode() : 0);
result = 31 * result + (this.wordFilters != null ? this.wordFilters.hashCode() : 0);
return result;
}
}
}