diff --git a/README.md b/README.md index 43a316a4..431b6c21 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ The official samples repository https://github.com/aws-samples/generative-ai-cdk | [amazon-bedrock-rag](https://github.com/aws-samples/amazon-bedrock-rag) | Fully managed RAG solution using Knowledge Bases for Amazon Bedrock. | | [Amazon Bedrock Knowledge Bases with Private Data](https://blog.serverlessadvocate.com/amazon-bedrock-knowledge-bases-with-private-data-7685d04ef396) | Blog post and associated code sample demonstrating how to integrate Knowledge Bases into Amazon Bedrock to provide foundational models with contextual data from private data sources. | | [Automating tasks using Amazon Bedrock Agents and AI](https://blog.serverlessadvocate.com/automating-tasks-using-amazon-bedrock-agents-and-ai-4b6fb8856589) | Blog post and associated code sample demonstrating how to deploy an Amazon Bedrock Agent and a Knowledge Base through a hotel and spa use case. | +| [Agents for Amazon Bedrock - Powertools for AWS Lambda (Python)](https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/bedrock_agents/#using-aws-cloud-developer-kit-cdk) | Create Agents for Amazon Bedrock using event handlers and auto generation of OpenAPI schemas. | # Contributors diff --git a/apidocs/interfaces/amazonaurora.AmazonAuroraDefaultVectorStoreProps.md b/apidocs/interfaces/amazonaurora.AmazonAuroraDefaultVectorStoreProps.md index b80eba3a..00dd6bb8 100644 --- a/apidocs/interfaces/amazonaurora.AmazonAuroraDefaultVectorStoreProps.md +++ b/apidocs/interfaces/amazonaurora.AmazonAuroraDefaultVectorStoreProps.md @@ -16,8 +16,8 @@ • `Readonly` **embeddingsModelVectorDimension**: `number` -The embeddings model for the knowledge base. -Must be identical as in the KnowledgeBaseV2 construct. +The embeddings model vector dimension for the knowledge base. +Must be identical as in the KnowledgeBase construct. This is due to the factor that the embeddings models have different vector dimensions and this construct needs to know the vector dimensions to create the vector diff --git a/src/cdk-lib/amazonaurora/README.md b/src/cdk-lib/amazonaurora/README.md index 98827685..6f0c4b14 100644 --- a/src/cdk-lib/amazonaurora/README.md +++ b/src/cdk-lib/amazonaurora/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| This construct library provides a class that defines a `AmazonAuroraVectorStore` class for an existing Amazon Aurora to be used for a vector store for a Knowledge Base. Additionally, it provides an `AmazonAuroraDefaultVectorStore` L3 resource that creates a VPC with 3 subnets (public private with NAT Gateway, private without NAT Gateway), with the Amazon Aurora Serverless V2 Cluster. The cluster has 1 writer/reader instance with PostgreSQL 15.5 version (min capacity 0.5, max capacity 4). Lambda custom resource executes required pgvector and Amazon Bedrock Knowledge Base SQL queries (see more [here](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.VectorDB.html)) against Aurora cluster during deployment. The secret containing databases credentials is being deployed and securely stored in AWS Secrets Manager. You must specify the same embeddings model that you are going to use in KnowledgeBase construct. @@ -31,6 +32,8 @@ See the [API documentation](../../../apidocs/modules/amazonaurora.md). ## Amazon Aurora Vector Store +TypeScript + ```ts import { amazonaurora } from '@cdklabs/generative-ai-cdk-constructs'; @@ -47,8 +50,30 @@ new amazonaurora.AmazonAuroraVectoStore( }); ``` +Python + +```python + +from cdklabs.generative_ai_cdk_constructs import ( + amazonaurora +) + +aurora = amazonaurora.AmazonAuroraVectorStore( + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + database_name='bedrock_vector_db', + metadata_field='metadata', + primary_key_field='id', + resource_arn='arn:aws:rds:your-region:123456789876:cluster:aurora-cluster-manual', + table_name='bedrock_integration.bedrock_kb', + text_field='chunks', + vector_field='embedding', + ) +``` + ## Amazon Aurora Default Vector Store +TypeScript + ```ts import { amazonaurora } from '@cdklabs/generative-ai-cdk-constructs'; @@ -56,3 +81,17 @@ new amazonaurora.AmazonAuroraDefaultVectorStore(stack, 'AuroraDefaultVectorStore embeddingsModel: BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3.vectorDimensions!, }); ``` + +Python +```python +from cdklabs.generative_ai_cdk_constructs import ( + amazonaurora, + bedrock +) + +dimension = bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3.vector_dimensions + +aurora = amazonaurora.AmazonAuroraDefaultVectorStore(self, 'AuroraDefaultVectorStore', + embeddings_model_vector_dimension=dimension +) +``` diff --git a/src/cdk-lib/amazonaurora/aurora-default-vector-store.ts b/src/cdk-lib/amazonaurora/aurora-default-vector-store.ts index a9dfaafd..09568cf1 100644 --- a/src/cdk-lib/amazonaurora/aurora-default-vector-store.ts +++ b/src/cdk-lib/amazonaurora/aurora-default-vector-store.ts @@ -25,8 +25,8 @@ import { buildVpc, DefaultVpcProps } from '../../common/helpers/vpc-helper'; export interface AmazonAuroraDefaultVectorStoreProps { /** - * The embeddings model for the knowledge base. - * Must be identical as in the KnowledgeBaseV2 construct. + * The embeddings model vector dimension for the knowledge base. + * Must be identical as in the KnowledgeBase construct. * This is due to the factor that the embeddings models * have different vector dimensions and this construct * needs to know the vector dimensions to create the vector diff --git a/src/cdk-lib/bedrock/README.md b/src/cdk-lib/bedrock/README.md index 94cb6049..3532cdf3 100644 --- a/src/cdk-lib/bedrock/README.md +++ b/src/cdk-lib/bedrock/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| [Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of foundation models (FMs) along with a broad set of capabilities for building generative AI applications. @@ -40,6 +41,9 @@ The resource accepts an `instruction` prop that is provided to any Bedrock Agent Amazon Bedrock Knowledge Bases currently only supports S3 as a data source. The `S3DataSource` resource is used to configure how the Knowledge Base handles the data source. Example of ``OpenSearch Serverless``: + +TypeScript + ```ts import * as s3 from 'aws-cdk-lib/aws-s3'; import { bedrock } from '@cdklabs/generative-ai-cdk-constructs'; @@ -62,12 +66,44 @@ new bedrock.S3DataSource(this, 'DataSource', { }); ``` +Python +```python + +from aws_cdk import ( + aws_s3 as s3, +) +from cdklabs.generative_ai_cdk_constructs import ( + bedrock +) + +kb = bedrock.KnowledgeBase(self, 'KnowledgeBase', + embeddings_model= bedrock.BedrockFoundationModel.TITAN_EMBED_TEXT_V1, + instruction= 'Use this knowledge base to answer questions about books. ' + + 'It contains the full text of novels.' + ) + +docBucket = s3.Bucket(self, 'DockBucket') + +bedrock.S3DataSource(self, 'DataSource', + bucket= docBucket, + knowledge_base=kb, + data_source_name='books', + chunking_strategy= bedrock.ChunkingStrategy.FIXED_SIZE, + max_tokens=500, + overlap_percentage=20 +) + +``` + Example of ``Amazon RDS Aurora PostgreSQL`` (manual, you must have Amazon RDS Aurora PostgreSQL already created): + +TypeScript + ```ts import * as s3 from 'aws-cdk-lib/aws-s3'; import { amazonaurora, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; -const auroraDbManual = new amazonaurora.AmazonAuroraVectorDatabase( +const auroraDbManual = new amazonaurora.AmazonAuroraVectorStore( { resourceArn: 'arn:aws:rds:your-region:123456789876:cluster:aurora-cluster-manual', databaseName: 'bedrock_vector_db', @@ -98,7 +134,52 @@ new bedrock.S3DataSource(this, 'DataSource', { }); ``` +Python +```python + +from aws_cdk import ( + aws_s3 as s3, +) +from cdklabs.generative_ai_cdk_constructs import ( + bedrock, + amazonaurora +) + +aurora = amazonaurora.AmazonAuroraVectorStore( + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + database_name='bedrock_vector_db', + metadata_field='metadata', + primary_key_field='id', + resource_arn='arn:aws:rds:your-region:123456789876:cluster:aurora-cluster-manual', + table_name='bedrock_integration.bedrock_kb', + text_field='chunks', + vector_field='embedding', +) + +kb = bedrock.KnowledgeBase(self, 'KnowledgeBase', + vector_store= aurora, + embeddings_model= bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3, + instruction= 'Use this knowledge base to answer questions about books. ' + + 'It contains the full text of novels.' + ) + +docBucket = s3.Bucket(self, 'DockBucket') + +bedrock.S3DataSource(self, 'DataSource', + bucket= docBucket, + knowledge_base=kb, + data_source_name='books', + chunking_strategy= bedrock.ChunkingStrategy.FIXED_SIZE, + max_tokens=500, + overlap_percentage=20 +) + +``` + Example of ``Amazon RDS Aurora PostgreSQL`` (default): + +TypeScript + ```ts import * as s3 from 'aws-cdk-lib/aws-s3'; import { amazonaurora, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; @@ -126,7 +207,47 @@ new bedrock.S3DataSource(this, 'DataSource', { }); ``` +Python + +```python + +from aws_cdk import ( + aws_s3 as s3, +) +from cdklabs.generative_ai_cdk_constructs import ( + bedrock, + amazonaurora +) + +dimension = bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3.vector_dimensions + +aurora = amazonaurora.AmazonAuroraDefaultVectorStore(self, 'AuroraDefaultVectorStore', + embeddings_model_vector_dimension=dimension +) + +kb = bedrock.KnowledgeBase(self, 'KnowledgeBase', + vector_store= aurora, + embeddings_model= bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3, + instruction= 'Use this knowledge base to answer questions about books. ' + + 'It contains the full text of novels.' + ) + +docBucket = s3.Bucket(self, 'DockBucket') + +bedrock.S3DataSource(self, 'DataSource', + bucket= docBucket, + knowledge_base=kb, + data_source_name='books', + chunking_strategy= bedrock.ChunkingStrategy.FIXED_SIZE, + max_tokens=500, + overlap_percentage=20 +) +``` + Example of ``Pinecone`` (manual, you must have Pinecone vector store created): + +TypeScript + ```ts import * as s3 from 'aws-cdk-lib/aws-s3'; import { pinecone, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; @@ -155,7 +276,45 @@ new bedrock.S3DataSource(this, 'DataSource', { }); ``` +Python +```python + +from aws_cdk import ( + aws_s3 as s3, +) +from cdklabs.generative_ai_cdk_constructs import ( + bedrock, + pinecone +) + +pineconevs = pinecone.PineconeVectorStore( + connection_string='https://your-index-1234567.svc.gcp-starter.pinecone.io', + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + ) + +kb = bedrock.KnowledgeBase(self, 'KnowledgeBase', + vector_store= pineconevs, + embeddings_model= bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3, + instruction= 'Use this knowledge base to answer questions about books. ' + + 'It contains the full text of novels.' + ) + +docBucket = s3.Bucket(self, 'DockBucket') + +bedrock.S3DataSource(self, 'DataSource', + bucket= docBucket, + knowledge_base=kb, + data_source_name='books', + chunking_strategy= bedrock.ChunkingStrategy.FIXED_SIZE, + max_tokens=500, + overlap_percentage=20 +) +``` + Example of ``Redis Enterprise Cloud`` (manual, you must have Redis Enterprise Cloud vector store created): + +TypeScript + ```ts import * as s3 from 'aws-cdk-lib/aws-s3'; import { redisenterprisecloud, bedrock } from '@cdklabs/generative-ai-cdk-constructs'; @@ -185,12 +344,50 @@ new bedrock.S3DataSource(this, 'DataSource', { }); ``` +Python +```python + +from aws_cdk import ( + aws_s3 as s3, +) +from cdklabs.generative_ai_cdk_constructs import ( + bedrock, + redisenterprisecloud +) + +redisds = redisenterprisecloud.RedisEnterpriseVectorStoreProps( + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + endpoint='redis-endpoint', + vector_index_name='your-index-name', + ) + +kb = bedrock.KnowledgeBase(self, 'KnowledgeBase', + vector_store= redisds, + embeddings_model= bedrock.BedrockFoundationModel.COHERE_EMBED_ENGLISH_V3, + instruction= 'Use this knowledge base to answer questions about books. ' + + 'It contains the full text of novels.' + ) + +docBucket = s3.Bucket(self, 'DockBucket') + +bedrock.S3DataSource(self, 'DataSource', + bucket= docBucket, + knowledge_base=kb, + data_source_name='books', + chunking_strategy= bedrock.ChunkingStrategy.FIXED_SIZE, + max_tokens=500, + overlap_percentage=20 +) +``` + ## Agents Enable generative AI applications to execute multistep tasks across company systems and data sources. ### Create an Agent The following example creates an Agent with a simple instruction and default prompts that consults a Knowledge Base. +TypeScript + ```ts const agent = new bedrock.Agent(this, 'Agent', { foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, @@ -199,6 +396,17 @@ const agent = new bedrock.Agent(this, 'Agent', { }); ``` +Python +```python +agent = bedrock.Agent( + self, + "Agent", + foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, + instruction="You are a helpful and friendly agent that answers questions about insurance claims.", + knowledge_bases= [kb] +) +``` + ### Action Groups An action group defines functions your agent can call. The functions are Lambda functions. The action group uses an OpenAPI schema to tell the agent what your functions do and how to call them. @@ -217,6 +425,28 @@ agent.addActionGroup({ }); ``` +Python + +```python + +action_group_function = PythonFunction( + self, + "LambdaFunction", + runtime=Runtime.PYTHON_3_12, + entry="./lambda", + index="app.py", + handler="lambda_handler", + ) + +agent.add_action_group( + action_group_name="query-library", + description="Use these functions to get information about the books in the library.", + action_group_executor=action_group_function, + action_group_state="ENABLED", + api_schema=bedrock.ApiSchema.from_asset("action-group.yaml"), + ) +``` + ### Prepare the Agent The `Agent` and `AgentActionGroup` constructs take an optional parameter `shouldPrepareAgent` to indicate that the Agent should be prepared after any updates to an agent, Knowledge Base association, or action group. This may increase the time to create and update those resources. @@ -225,6 +455,8 @@ Creating an agent alias will also prepare the agent, so if you create an alias w #### Prompt Overrides Bedrock Agents allows you to customize the prompts and LLM configuration for its different steps. You can disable steps or create a new prompt template. Prompt templates can be inserted from plain text files. +TypeScript + ```ts import { readFileSync } from 'fs'; @@ -266,6 +498,46 @@ const agent = new bedrock.Agent(this, 'Agent', { }); ``` +Python +```python +orchestration = open('prompts/orchestration.txt', encoding="utf-8").read() +agent = bedrock.Agent(self, "Agent", + foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, + instruction="You are a helpful and friendly agent that answers questions about insurance claims.", + knowledge_bases= [kb], + prompt_override_configuration= bedrock.PromptOverrideConfiguration( + prompt_configurations=[ + bedrock.PromptConfiguration( + prompt_type=bedrock.PromptType.PRE_PROCESSING, + prompt_state=bedrock.PromptState.DISABLED, + prompt_creation_mode=bedrock.PromptCreationMode.OVERRIDDEN, + base_prompt_template="disabled", + inference_configuration=bedrock.InferenceConfiguration( + temperature=0.0, + top_k=250, + top_p=1, + maximum_length=1, + stop_sequences=['\n\nHuman:'], + ) + ), + bedrock.PromptConfiguration( + prompt_type=bedrock.PromptType.ORCHESTRATION, + prompt_state=bedrock.PromptState.ENABLED, + prompt_creation_mode=bedrock.PromptCreationMode.OVERRIDDEN, + base_prompt_template=orchestration, + inference_configuration=bedrock.InferenceConfiguration( + temperature=0.0, + top_k=250, + top_p=1, + maximum_length=2048, + stop_sequences=['', '', ''], + ) + ) + ] + ), + ) +``` + ### Agent Alias After you have sufficiently iterated on your working draft and are satisfied with the behavior of your agent, you can set it up for deployment and integration into your application by creating aliases of your agent. @@ -276,6 +548,8 @@ By default, the `Agent` resource does not create any aliases, and you can use th #### Tracking the latest version The `Agent` resource optionally takes an `aliasName` property that, if defined, will create an Alias that creates a new version on every change. +TypeScript + ```ts const agent = new bedrock.Agent(this, 'Agent', { foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, @@ -285,9 +559,23 @@ const agent = new bedrock.Agent(this, 'Agent', { }); ``` +Python +```python +agent = bedrock.Agent( + self, + "Agent", + foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2_1, + instruction="You are a helpful and friendly agent that answers questions about insurance claims.", + knowledge_bases= [kb], + alias_name='latest' +) +``` + #### Specific version Using the `addAlias` method you can create aliases with a specific agent version. +TypeScript + ```ts agent.addAlias({ aliasName: 'prod', @@ -295,8 +583,19 @@ agent.addAlias({ }); ``` +Python + +```python +agent.add_alias(self, 'ProdAlias', + alias_name='prod', + agent_version='12' +) +``` + Alternatively, you can use the `AgentAlias` resource if you want to create an Alias for an existing Agent. +TypeScript + ```ts const alias = new bedrock.AgentAlias(this, 'ProdAlias', { agentId: 'ABCDE12345', @@ -304,3 +603,12 @@ const alias = new bedrock.AgentAlias(this, 'ProdAlias', { agentVersion: '12', }); ``` + +Python +```python +alias = bedrock.AgentAlias(self, 'ProdAlias', + agent_id='ABCDE12345', + alias_name='prod', + agent_version='12' +) +``` diff --git a/src/cdk-lib/opensearch-vectorindex/README.md b/src/cdk-lib/opensearch-vectorindex/README.md index 743f2108..b7ce0c7b 100644 --- a/src/cdk-lib/opensearch-vectorindex/README.md +++ b/src/cdk-lib/opensearch-vectorindex/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| This construct library provides a resource that creates a vector index on an Amazon OpenSearch Domain. It currently only supports Amazon OpenSearch Serverless. @@ -30,6 +31,8 @@ See the [API documentation](../../../apidocs/modules/opensearchserverless.md). ## Vector Index The `VectorIndex` resource connects to OpenSearch and creates an index suitable for use with Amazon Bedrock Knowledge Bases. +TypeScript + ```ts import { opensearchserverless, opensearch_vectorindex } from '@cdklabs/generative-ai-cdk-constructs'; @@ -54,3 +57,32 @@ mappings: [ ], }); ``` + +Python +```python +from cdklabs.generative_ai_cdk_constructs import ( + opensearchserverless, + opensearch_vectorindex, +) + +vectorCollection = opensearchserverless.VectorCollection(self, "VectorCollection") + +vectorIndex = opensearch_vectorindex.VectorIndex(self, "VectorIndex", + vector_dimensions= 1536, + collection=vectorCollection, + index_name='myindex', + vector_field='vectorfieldname', + mappings= [ + opensearch_vectorindex.MetadataManagementFieldProps( + mapping_field='AMAZON_BEDROCK_TEXT_CHUNK', + data_type='text', + filterable=True + ), + opensearch_vectorindex.MetadataManagementFieldProps( + mapping_field='AMAZON_BEDROCK_METADATA', + data_type='text', + filterable=False + ) + ], +) +``` \ No newline at end of file diff --git a/src/cdk-lib/opensearchserverless/README.md b/src/cdk-lib/opensearchserverless/README.md index 95341ce5..d4e3a7cd 100644 --- a/src/cdk-lib/opensearchserverless/README.md +++ b/src/cdk-lib/opensearchserverless/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| This construct library extends the [automatically generated L1 constructs](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchserverless-readme.html) to provide an L2 construct for a vector collection. diff --git a/src/cdk-lib/pinecone/README.md b/src/cdk-lib/pinecone/README.md index d841aa0b..87d9f192 100644 --- a/src/cdk-lib/pinecone/README.md +++ b/src/cdk-lib/pinecone/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| This construct library provides a class that defines an existing Pinecone database to be used for a vector store for a Knowledge Base. @@ -28,11 +29,26 @@ See the [API documentation](../../../apidocs/modules/pinecone.md). ## Pinecone Vector Store +TypeScript + ```ts import { pinecone } from '@cdklabs/generative-ai-cdk-constructs'; -new pinecone.PineconVectorStore({ +new pinecone.PineconeVectorStore({ connectionString: 'https://your-index-1234567.svc.gcp-starter.pinecone.io', credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name' }); ``` + +Python + +```python +from cdklabs.generative_ai_cdk_constructs import ( + pinecone +) + +pineconevs = pinecone.PineconeVectorStore( + connection_string='https://your-index-1234567.svc.gcp-starter.pinecone.io', + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + ) +``` \ No newline at end of file diff --git a/src/cdk-lib/redisenterprisecloud/README.md b/src/cdk-lib/redisenterprisecloud/README.md index b86ee8b1..b9124f03 100644 --- a/src/cdk-lib/redisenterprisecloud/README.md +++ b/src/cdk-lib/redisenterprisecloud/README.md @@ -16,6 +16,7 @@ | **Language** | **Package** | |:-------------|-----------------| |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript|`@cdklabs/generative-ai-cdk-constructs`| +|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`cdklabs.generative_ai_cdk_constructs`| This construct library provides a class that defines an existing Redis Enterprise Cloud database to be used for a vector store for a Knowledge Base. @@ -28,12 +29,28 @@ See the [API documentation](../../../apidocs/modules/redisenterprisecloud.md). ## Redis Enterprise Cloud Vector Store +TypeScript + ```ts import { redisenterprisecloud } from '@cdklabs/generative-ai-cdk-constructs'; -new redisenterprisecloud.PineconVectorStore({ +new redisenterprisecloud.RedisEnterpriseVectorStore({ endpoint: 'redis-endpoint', vectorIndexName: 'your-index-name', credentialsSecretArn: 'arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name' }); ``` + +Python +```python +from cdklabs.generative_ai_cdk_constructs import ( + redisenterprisecloud +) + +redisds = redisenterprisecloud.RedisEnterpriseVectorStoreProps( + credentials_secret_arn='arn:aws:secretsmanager:your-region:123456789876:secret:your-key-name', + endpoint='redis-endpoint', + vector_index_name='your-index-name', + ) + +```