io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt Maven / Gradle / Ivy
Show all versions of generative-ai-cdk-constructs Show documentation
package io.github.cdklabs.generative_ai_cdk_constructs.bedrock;
/**
* (experimental) Prompts are a specific set of inputs that guide FMs on Amazon Bedrock to generate an appropriate response or output for a given task or instruction.
*
* You can optimize the prompt for specific use cases and models.
*
* @see https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management.html
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.103.1 (build bef2dea)", date = "2024-10-01T15:41:28.756Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Jsii(module = io.github.cdklabs.generative_ai_cdk_constructs.$Module.class, fqn = "@cdklabs/generative-ai-cdk-constructs.bedrock.Prompt")
public class Prompt extends software.constructs.Construct implements io.github.cdklabs.generative_ai_cdk_constructs.bedrock.IPrompt {
protected Prompt(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected Prompt(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* @param scope This parameter is required.
* @param id This parameter is required.
* @param props This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Prompt(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") });
}
/**
* @param promptArn This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static @org.jetbrains.annotations.NotNull io.github.cdklabs.generative_ai_cdk_constructs.bedrock.IPrompt fromPromptArn(final @org.jetbrains.annotations.NotNull java.lang.String promptArn) {
return software.amazon.jsii.JsiiObject.jsiiStaticCall(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt.class, "fromPromptArn", software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.IPrompt.class), new Object[] { java.util.Objects.requireNonNull(promptArn, "promptArn is required") });
}
/**
* (experimental) Adds a prompt variant.
*
* @param variant This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void addVariant(final @org.jetbrains.annotations.NotNull io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptVariant variant) {
software.amazon.jsii.Kernel.call(this, "addVariant", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(variant, "variant is required") });
}
/**
* (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.
*
* @param description
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void createVersion(final @org.jetbrains.annotations.Nullable java.lang.String description) {
software.amazon.jsii.Kernel.call(this, "createVersion", software.amazon.jsii.NativeType.VOID, new Object[] { description });
}
/**
* (experimental) Creates a prompt version, a static snapshot of your prompt that can be deployed to production.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public void createVersion() {
software.amazon.jsii.Kernel.call(this, "createVersion", software.amazon.jsii.NativeType.VOID);
}
/**
* (experimental) The ARN of the prompt.
*
* Example:
*
*
* "arn:aws:bedrock:us-east-1:123456789012:prompt/PROMPT12345"
*
*/
@Override
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.NotNull java.lang.String getPromptArn() {
return software.amazon.jsii.Kernel.get(this, "promptArn", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* (experimental) The ID of the prompt.
*
* Example:
*
*
* "PROMPT12345"
*
*/
@Override
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.NotNull java.lang.String getPromptId() {
return software.amazon.jsii.Kernel.get(this, "promptId", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* (experimental) The name of the prompt.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.NotNull java.lang.String getPromptName() {
return software.amazon.jsii.Kernel.get(this, "promptName", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* (experimental) The variants of the prompt.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.NotNull java.util.List getVariants() {
return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "variants", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptVariant.class))));
}
/**
* (experimental) The KMS key that the prompt is encrypted with.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.kms.IKey getEncryptionKey() {
return software.amazon.jsii.Kernel.get(this, "encryptionKey", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.kms.IKey.class));
}
/**
* (experimental) A fluent builder for {@link io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param scope This parameter is required.
* @param id This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static Builder create(final software.constructs.Construct scope, final java.lang.String id) {
return new Builder(scope, id);
}
private final software.constructs.Construct scope;
private final java.lang.String id;
private final io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptProps.Builder props;
private Builder(final software.constructs.Construct scope, final java.lang.String id) {
this.scope = scope;
this.id = id;
this.props = new io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptProps.Builder();
}
/**
* (experimental) The name of the prompt.
*
* @return {@code this}
* @param promptName The name of the prompt. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder promptName(final java.lang.String promptName) {
this.props.promptName(promptName);
return this;
}
/**
* (experimental) The Prompt Variant that will be used by default.
*
* Default: - No default variant provided.
*
* @return {@code this}
* @param defaultVariant The Prompt Variant that will be used by default. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder defaultVariant(final io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptVariant defaultVariant) {
this.props.defaultVariant(defaultVariant);
return this;
}
/**
* (experimental) A description of what the prompt does.
*
* Default: - No description provided.
*
* @return {@code this}
* @param description A description of what the prompt does. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder description(final java.lang.String description) {
this.props.description(description);
return this;
}
/**
* (experimental) The KMS key that the prompt is encrypted with.
*
* Default: - AWS owned and managed key.
*
* @return {@code this}
* @param encryptionKey The KMS key that the prompt is encrypted with. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder encryptionKey(final software.amazon.awscdk.services.kms.IKey encryptionKey) {
this.props.encryptionKey(encryptionKey);
return this;
}
/**
* (experimental) The variants of your prompt.
*
* Variants can use different messages, models,
* or configurations so that you can compare their outputs to decide the best
* variant for your use case. Maximum of 3 variants.
*
* @return {@code this}
* @param variants The variants of your prompt. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder variants(final java.util.List extends io.github.cdklabs.generative_ai_cdk_constructs.bedrock.PromptVariant> variants) {
this.props.variants(variants);
return this;
}
/**
* @return a newly built instance of {@link io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt build() {
return new io.github.cdklabs.generative_ai_cdk_constructs.bedrock.Prompt(
this.scope,
this.id,
this.props.build()
);
}
}
}