From d0e0e36dc4633ea09585854bc0e8a7bd3480daf3 Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Mon, 24 Aug 2026 11:21:28 +0200 Subject: [PATCH] adding sample --- integrations/amazon-bedrock.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/integrations/amazon-bedrock.md b/integrations/amazon-bedrock.md index 683fca2d..af01dbcd 100644 --- a/integrations/amazon-bedrock.md +++ b/integrations/amazon-bedrock.md @@ -38,7 +38,7 @@ pip install amazon-bedrock-haystack Once installed, you will have access to [AmazonBedrockChatGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockchatgenerator) and [AmazonBedrockGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockgenerator) components that support generative language models on Amazon Bedrock. You will also have access to the [AmazonBedrockTextEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrocktextembedder) and [AmazonBedrockDocumentEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrockdocumentembedder), which can be used to compute embeddings. -The integration also includes [S3Downloader](https://docs.haystack.deepset.ai/docs/s3downloader) that allows downloading files from AWS S3 buckets to the local filesystem. +The integration also includes [S3Downloader](https://docs.haystack.deepset.ai/docs/s3downloader) that allows downloading files from AWS S3 buckets to the local filesystem, and [BedrockKnowledgeBaseRetriever](https://docs.haystack.deepset.ai/docs/bedrockknowledgebaseretriever) that retrieves documents from an Amazon Bedrock Managed Knowledge Base. To use this integration, set the AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`) as environment variables or passed as [Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments. @@ -238,3 +238,23 @@ documents = [ # Run the pipeline result = pipe.run({"downloader": {"documents": documents}}) ``` + +### BedrockKnowledgeBaseRetriever + +Before using this component, you need to set up an [Amazon Bedrock Knowledge Base](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html) and note its ID. + +```python +from haystack.utils import Secret +from haystack_integrations.components.retrievers.amazon_bedrock import BedrockKnowledgeBaseRetriever + +retriever = BedrockKnowledgeBaseRetriever( + knowledge_base_id="ABCDEFGHIJ", + aws_region_name=Secret.from_token("eu-central-1"), +) + +result = retriever.run(query="What are the benefits of managed knowledge bases?") +for doc in result["documents"]: + print(doc.content) + print(doc.meta["source"]) + print(doc.score) +```