bedrock

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bedrock provides embedding generation via AWS Bedrock's platform-native models. Unlike the OpenAI-compatible providers, Bedrock embeddings use per-family request and response bodies posted to /model/{modelId}/invoke, so they need their own provider type rather than a transport-level rewrite of the OpenAI wire format.

Two families are supported:

  • Amazon Titan (amazon.titan-embed-*): one text per call, {"inputText": …}
  • Cohere (cohere.embed-*): natively batched, {"texts": […], "input_type": …}

The family is the declared format (WithEmbeddingFormat, or additional_config.embedding_format) when there is one, so an inference profile, an ARN or any other model id works. Without one it is read from the model id's prefix, and a model id outside both prefixes is refused.

Authentication is AWS SigV4, applied by the HTTP client's transport (see providers.ResolveEmbeddingTransport with platform "bedrock"), so this package never handles credentials directly.

Index

Constants

View Source
const (
	FormatTitan  = "titan"
	FormatCohere = "cohere"
)

The declarable request formats (additional_config.embedding_format).

View Source
const DefaultInputType = "search_document"

DefaultInputType is Cohere's required input_type for indexing documents. Use "search_query" when embedding a query for retrieval.

View Source
const DefaultModel = "amazon.titan-embed-text-v2:0"

DefaultModel is Amazon's current general-purpose embedding model.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingOption

type EmbeddingOption func(*EmbeddingProvider)

EmbeddingOption configures the EmbeddingProvider.

func WithBatchSize added in v2.22.0

func WithBatchSize(n int) EmbeddingOption

WithBatchSize declares the most texts one request may carry, replacing the family default that MaxBatchSize reports. A size above the family's API limit is clamped to the limit, with a warning. Values below 1 are ignored.

func WithEmbeddingFormat added in v2.22.0

func WithEmbeddingFormat(format string) EmbeddingOption

WithEmbeddingFormat declares the request format, FormatTitan or FormatCohere. It wins over the model id, so a model id that does not start with a family prefix (an inference profile such as us.cohere.embed-v4:0, or an ARN) can be used. NewEmbeddingProvider rejects any other value.

func WithInputType

func WithInputType(inputType string) EmbeddingOption

WithInputType sets Cohere's input_type ("search_document" or "search_query"). Ignored by Titan, which has no equivalent.

func WithPlatformAuth

func WithPlatformAuth() EmbeddingOption

WithPlatformAuth marks the provider as authenticated by its HTTP client's transport. Bedrock has no API-key mode, so this is always the case in real use; the flag exists for symmetry with the other embedding providers.

func WithWiring

WithWiring applies the transport-derived settings the factory resolved.

type EmbeddingProvider

type EmbeddingProvider struct {
	*providers.BaseEmbeddingProvider
	// contains filtered or unexported fields
}

EmbeddingProvider implements embedding generation via AWS Bedrock.

func NewEmbeddingProvider

func NewEmbeddingProvider(opts ...EmbeddingOption) (*EmbeddingProvider, error)

NewEmbeddingProvider creates a Bedrock embedding provider. Without a declared format it fails when the model is not a recognized embedding family, rather than guessing a wire format that the endpoint would reject at request time.

func (*EmbeddingProvider) Embed

Embed generates embeddings for the given texts.

Jump to

Keyboard shortcuts

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