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

Example

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

  • BaseRetriever
    • AmazonKnowledgeBaseRetriever

Constructors

Properties

bedrockAgentRuntimeClient: BedrockAgentRuntimeClient
knowledgeBaseId: string
topK: number

Methods

  • Parameters

    • query: string
    • topK: number

    Returns Promise<Document<Record<string, any>>[] | {
        metadata: {
            score: undefined | number;
            source: undefined | string;
        };
        pageContent: string;
    }[]>

Generated using TypeDoc