Skip to content

Commit

Permalink
Add embeddings model configuration and fix typos
Browse files Browse the repository at this point in the history
1. Adds embeddings model configuration to the Bedrock knowledge base
2. Fixes typo in variable name
3. Adds tags to the ECR registry SSM parameter
4. Introduces a new variable for the embeddings model with a default value
  • Loading branch information
PetreVane committed Oct 17, 2024
1 parent f639551 commit b8a0829
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bedrock_knowledge_base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_bedrockagent_knowledge_base" "knowledge_base_with_pinecone" {
# Define the vector knowledge base configuration
vector_knowledge_base_configuration {
# Specify the ARN of the embedding model using the current partition and region
embedding_model_arn = "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}::foundation-model/${var.embedings_model}"
embedding_model_arn = "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}::foundation-model/${var.embeddings_model}"
}

}
Expand Down Expand Up @@ -95,7 +95,7 @@ resource "aws_bedrockagent_data_source" "kb_data_source" {
chunking_configuration {
chunking_strategy = "HIERARCHICAL"
hierarchical_chunking_configuration {
overlap_tokens = 200
overlap_tokens = 160
level_configuration {
max_tokens = 1600
}
Expand Down
2 changes: 1 addition & 1 deletion bedrock_knowledge_base/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Define an output variable for the ARN of the embedding model
output "embeddings_model_arn" {
# Constructs the ARN using the current AWS partition and region, along with the specified embedding model variable
value = "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}::foundation-model/${var.embedings_model}"
value = "arn:${data.aws_partition.current.partition}:bedrock:${data.aws_region.current.name}::foundation-model/${var.embeddings_model}"
}

# Define an output variable for the ARN of the knowledge base
Expand Down
3 changes: 1 addition & 2 deletions bedrock_knowledge_base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ variable "pinecone_connection_string" {
description = "The connection string to the Pinecone API."
}

variable "embedings_model" {
variable "embeddings_model" {
description = "The name of the embeddings model to use."
type = string
default = "amazon.titan-embed-text-v2:0"
}

variable "pinecone_credential_secret_arn" {
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module "pinecone" {

module "bedrock" {
source = "./bedrock_knowledge_base"

embeddings_model = var.embeddings_model
knowledge_base_role_arn = module.iam.bedrock_kb_role_arn
pinecone_connection_string = module.pinecone.pinecone_host
pinecone_credential_secret_arn = module.secrets_manager.pinecone_secret_arn
Expand Down
4 changes: 2 additions & 2 deletions ssm_parameter_store/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ resource "aws_ssm_parameter" "ecr_registry_id" {
name = "/github-actions/ecr_registry"
type = "String"
value = var.ecr_registry_id
tags = merge(var.tags, { Name = "terraform_project" })
tags = merge(var.tags, { Name = "/github-actions/ecr_registry" })
}

resource "aws_ssm_parameter" "ecr_repository_name" {
name = "/github-actions/ecr_repository_name"
type = "String"
value = var.ecr_repository_name
value = var.ecr_repository_name`
tags = merge(var.tags, { Name = "terraform_project" })
}

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ variable "aws_environment" {
default = "DEV"
}

variable "embeddings_model" {
description = "The name of the embeddings model to use."
type = string
default = "amazon.titan-embed-text-v2:0"
}

0 comments on commit b8a0829

Please sign in to comment.