bedrockkb

package module
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package bedrockkb wraps AWS Bedrock Knowledge Bases as a semantic and hybrid searcher. Bedrock Knowledge Base is a managed RAG service — embedding, chunking, and persistence are all handled behind the API; scope only consumes the runtime Retrieve surface.

Requirements: an AWS account with Bedrock Knowledge Bases enabled, a provisioned knowledge base wired to a data source (S3, Confluence, SharePoint, Salesforce, etc.), and an aws-sdk-go-v2 bedrockagentruntime client.

Construction performs no I/O, unlike its siblings in this family. The only Bedrock surface this store depends on is Retrieve, which cannot describe a knowledge base without running a paid query, and confirming one exists would mean taking a second control-plane client the store has no other use for. A wrong StoreConfig.KnowledgeBaseID therefore surfaces as Bedrock's own error on the first search. NewStore still takes a context, because every vector store here is constructed the same way.

Document lifecycle. Bedrock ingests via the configured data source + StartIngestionJob — there's no runtime upsert / delete. The store exposes no fake mutation methods. Manage documents via the data source instead (StartIngestionJob through the bedrockagent control plane).

Retrieve uses Bedrock's runtime Retrieve API with the configured types.KnowledgeBaseVectorSearchConfiguration — NumberOfResults is populated from vectorstore.SearchOptions.TopK, and vectorstore.SearchOptions.Mode maps directly to Bedrock's semantic or hybrid search type. Provider-specific reranking and implicit filtering stay in StoreConfig.

Result completeness. NumberOfResults caps at 100 and Bedrock answers with a continuation token whenever more results exist than fit in one response, so a single call is not the whole answer even when it asks for fewer than the cap. Search follows the token until TopK results are collected or the knowledge base is exhausted; TopK above 100 is served by paging rather than rejected.

Filter visitor produces types.RetrievalFilter — Bedrock's typed filter shape (Equals / NotEquals / GreaterThan / LessThan / GreaterThanOrEquals / LessThanOrEquals / StringContains / In / NotIn / AndAll / OrAll / etc.).

Identifiers. Bedrock retrieval results don't expose stable per-row ids; the store uses `DocumentId` or the result's `Location` (e.g. the S3 URI of the source object). A result without either stable identity is rejected.

Null tests are refused. Bedrock's RetrievalFilter offers equals, notEquals, the four ordering members, in, notIn, startsWith, listContains and stringContains, none of which asks whether a key is present, so an IS NULL filter fails rather than being approximated.

Scores. The Retrieve API documents the result score only as "the level of relevance of the result to the query" with type Double, and gives no range, so the store takes the value as a relevance score already on Core's scale and clamps it. That is an assumption about an undocumented property rather than a mapping: the knowledge base owns the vector store, the embedding model and the search type, and none of them is visible here to derive a scale from.

See https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html.

Index

Constants

View Source
const Provider = "BedrockKnowledgeBase"

Provider is the stable backend name for host-side attribution.

Variables

This section is empty.

Functions

This section is empty.

Types

type RetrieveClient added in v0.16.0

type RetrieveClient interface {
	Retrieve(
		ctx context.Context,
		input *bedrockagentruntime.RetrieveInput,
		optFns ...func(*bedrockagentruntime.Options),
	) (*bedrockagentruntime.RetrieveOutput, error)
}

RetrieveClient is the Bedrock runtime surface the store uses. A bedrockagentruntime.Client satisfies it. Naming the single operation keeps the store's pagination observable without a live knowledge base.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a searchable Bedrock Knowledge Base. Ingestion and deletion are intentionally absent because the runtime API cannot perform them.

func NewStore

func NewStore(_ context.Context, config StoreConfig) (*Store, error)

NewStore performs no I/O: the knowledge base is provisioned out of band and the only surface this store depends on is Retrieve, which cannot describe a knowledge base without running a paid query. Confirming one exists would mean taking a second, control-plane client the store has no other use for, so a wrong KnowledgeBaseID surfaces as Bedrock's own error on the first search.

The context is still taken, because every store in this family is constructed the same way and a caller should not have to remember which backend happens to be checkable.

func (*Store) Search

func (s *Store) Search(ctx context.Context, req *vectorstore.SearchRequest) (response *vectorstore.SearchResponse, err error)

Search runs the Bedrock Knowledge Base Retrieve API.

type StoreConfig

type StoreConfig struct {
	// Client is the bedrockagentruntime client. Required.
	Client RetrieveClient

	// KnowledgeBaseID identifies the knowledge base to query.
	// Required.
	KnowledgeBaseID string

	// RerankingConfiguration and ImplicitFilterConfiguration expose Bedrock's
	// provider-specific retrieval features without allowing them to override
	// SearchOptions.TopK or SearchOptions.Filter.
	RerankingConfiguration      *types.VectorSearchRerankingConfiguration
	ImplicitFilterConfiguration *types.ImplicitFilterConfiguration
}

StoreConfig contains configuration options for the AWS Bedrock Knowledge Base vector store. Bedrock manages document ingestion out of band (S3 data source + StartIngestionJob), so this store exposes only retrieval.

func (StoreConfig) Validate

func (s StoreConfig) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL