Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
KnowledgeBaseEmbeddingsModel Mixin Added in v2.274.0-alpha.0
Configures the embeddings model of a vector knowledge base.
Sets EmbeddingModelArn, Dimensions (only for models with a configurable dimension; CloudFormation rejects it otherwise) and EmbeddingDataType. Grants the role referenced by the knowledge base's roleArn bedrock:InvokeModel* and bedrock:GetFoundationModel on the model and makes the knowledge base depend on that policy.
Example
ts
declare const role: iam.Role;
new aws_bedrock_cfn.CfnKnowledgeBase(this, 'KnowledgeBase', {
name: 'product-documentation',
roleArn: role.roleArn,
knowledgeBaseConfiguration: { type: 'VECTOR' },
}).with(new bedrock.mixins.KnowledgeBaseEmbeddingsModel({
embeddingsModel: bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V2_1024,
}));
python
# role: iam.Role
aws_bedrock_cfn.CfnKnowledgeBase(self, "KnowledgeBase",
name="product-documentation",
role_arn=role.role_arn,
knowledge_base_configuration=aws_bedrock_cfn.CfnKnowledgeBase.KnowledgeBaseConfigurationProperty(type="VECTOR")
).with(bedrock.mixins.KnowledgeBaseEmbeddingsModel(
embeddings_model=bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V2_1024
))
java
Role role;
CfnKnowledgeBase.Builder.create(this, "KnowledgeBase")
.name("product-documentation")
.roleArn(role.roleArn)
.knowledgeBaseConfiguration(KnowledgeBaseConfigurationProperty.builder().type("VECTOR").build())
.build().with(KnowledgeBaseEmbeddingsModel.Builder.create()
.embeddingsModel(BedrockFoundationModel.TITAN_EMBED_TEXT_V2_1024)
.build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
Role role;
new CfnKnowledgeBase(this, "KnowledgeBase", new CfnKnowledgeBaseProps {
Name = "product-documentation",
RoleArn = role.RoleArn,
KnowledgeBaseConfiguration = new KnowledgeBaseConfigurationProperty { Type = "VECTOR" }
}).With(new Mixins.KnowledgeBaseEmbeddingsModel(new KnowledgeBaseEmbeddingsModelProps {
EmbeddingsModel = BedrockFoundationModel.TITAN_EMBED_TEXT_V2_1024
}));
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
var role Role
awscdk.Aws_bedrock.NewCfnKnowledgeBase(this, jsii.String("KnowledgeBase"), &CfnKnowledgeBaseProps{
Name: jsii.String("product-documentation"),
RoleArn: role.roleArn,
KnowledgeBaseConfiguration: &KnowledgeBaseConfigurationProperty{
Type: jsii.String("VECTOR"),
},
}).With(mixins.NewKnowledgeBaseEmbeddingsModel(&KnowledgeBaseEmbeddingsModelProps{
EmbeddingsModel: bedrock.BedrockFoundationModel_TITAN_EMBED_TEXT_V2_1024(),
}))
Initializer
ts
new KnowledgeBaseEmbeddingsModel(props: KnowledgeBaseEmbeddingsModelProps)
python
KnowledgeBaseEmbeddingsModel(props: KnowledgeBaseEmbeddingsModelProps)
java
new KnowledgeBaseEmbeddingsModel(KnowledgeBaseEmbeddingsModelProps props)
csharp
new KnowledgeBaseEmbeddingsModel(KnowledgeBaseEmbeddingsModelProps props)
go
NewKnowledgeBaseEmbeddingsModel(Props KnowledgeBaseEmbeddingsModelProps)
Methods
applyTo(construct: IConstruct): voiddef apply_to(self, construct: IConstruct) -> Nonepublic void applyTo(IConstruct construct)public void ApplyTo(IConstruct construct)func ApplyTo(Construct IConstruct)#Applies the mixin functionality to the target construct.
isMixin(x: any): boolean@staticmethod def is_mixin(x: Any) -> boolpublic static Boolean isMixin(Object x)public static bool IsMixin(object x)func IsMixin(X interface{}) *boolstatic#Checks if `x` is a Mixin.
1 parameter · returns
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Mixin.
supports(construct: IConstruct): booleandef supports(self, construct: IConstruct) -> boolpublic Boolean supports(IConstruct construct)public bool Supports(IConstruct construct)func Supports(Construct IConstruct) *bool#Determines whether this mixin can be applied to the given construct.