Class for interacting with Amazon Bedrock Knowledge Bases, a RAG workflow oriented service provided by AWS. Extends the BaseRetriever class.

const retriever = new AmazonKnowledgeBaseRetriever({
topK: 10,
knowledgeBaseId: "YOUR_KNOWLEDGE_BASE_ID",
region: "us-east-2",
clientOptions: {
credentials: {
accessKeyId: "YOUR_ACCESS_KEY_ID",
secretAccessKey: "YOUR_SECRET_ACCESS_KEY",
},
},
});

const docs = await retriever.getRelevantDocuments("How are clouds formed?");

Hierarchy (view full)

  • Toolkit
    • AmazonKnowledgeBaseRetriever

Constructors

Properties

bedrockAgentRuntimeClient: BedrockAgentRuntimeClient
knowledgeBaseId: string
topK: number

Methods