diff --git a/cdk/stacks/cdk_chatbot_api_stack.py b/cdk/stacks/cdk_chatbot_api_stack.py index 2737c91..f3ef722 100644 --- a/cdk/stacks/cdk_chatbot_api_stack.py +++ b/cdk/stacks/cdk_chatbot_api_stack.py @@ -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( @@ -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 ), ), ), diff --git a/custom_resources/create_oss_index.py b/custom_resources/create_oss_index.py index 133ca07..98c5e7c 100644 --- a/custom_resources/create_oss_index.py +++ b/custom_resources/create_oss_index.py @@ -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"}, } }, }