Skip to content

Commit

Permalink
WIP: Progress on Bedrock KB. Pending fix on invalid storage_configura…
Browse files Browse the repository at this point in the history
…tion error
  • Loading branch information
san99tiago committed Oct 22, 2024
1 parent d36b025 commit e729b85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cdk/stacks/cdk_chatbot_api_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def create_bedrock_components(self) -> None:
knowledge_base_configuration=aws_bedrock.CfnKnowledgeBase.KnowledgeBaseConfigurationProperty(
type="VECTOR",
vector_knowledge_base_configuration=aws_bedrock.CfnKnowledgeBase.VectorKnowledgeBaseConfigurationProperty(
embedding_model_arn=f"arn:aws:bedrock:{self.region}::foundation-model/amazon.titan-embed-text-v2"
embedding_model_arn=f"arn:aws:bedrock:{self.region}::foundation-model/amazon.titan-embed-text-v1"
),
),
storage_configuration=aws_bedrock.CfnKnowledgeBase.StorageConfigurationProperty(
Expand All @@ -819,9 +819,9 @@ def create_bedrock_components(self) -> None:
collection_arn=opensearch_serverless_collection.attr_arn,
vector_index_name=index_name,
field_mapping=aws_bedrock.CfnKnowledgeBase.OpenSearchServerlessFieldMappingProperty(
metadata_field="metadataField",
text_field="textField",
vector_field="vectorField",
metadata_field="AMAZON_BEDROCK_METADATA", # Must match to Lambda Function
text_field="AMAZON_BEDROCK_TEXT_CHUNK", # Must match to Lambda Function
vector_field="bedrock-knowledge-base-default-vector", # Must match to Lambda Function
),
),
),
Expand Down
13 changes: 6 additions & 7 deletions custom_resources/create_oss_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,21 @@ def handler(event, context):
"settings": {"index": {"knn": "true"}},
"mappings": {
"properties": {
"vectorField": {
"bedrock-knowledge-base-default-vector": {
"type": "knn_vector",
"dimension": 1536,
"method": {
"space_type": "innerproduct",
"engine": "FAISS",
"name": "hnsw",
"engine": "faiss",
"space_type": "l2",
"parameters": {
"ef_construction": 1536,
"m": 16,
"ef_search": 1536,
"ef_construction": 512,
},
},
},
"metadataField": {"type": "text"},
"textField": {"type": "text"},
"AMAZON_BEDROCK_METADATA": {"type": "text", "index": False},
"AMAZON_BEDROCK_TEXT_CHUNK": {"type": "text"},
}
},
}
Expand Down

0 comments on commit e729b85

Please sign in to comment.