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, selected from the model id:
- Amazon Titan (amazon.titan-embed-*): one text per call, {"inputText": …}
- Cohere (cohere.embed-*): natively batched, {"texts": […], "input_type": …}
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 ¶
const DefaultInputType = "search_document"
DefaultInputType is Cohere's required input_type for indexing documents. Use "search_query" when embedding a query for retrieval.
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 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 ¶
func WithWiring(w providers.EmbeddingWiring) EmbeddingOption
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. 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 ¶
func (p *EmbeddingProvider) Embed( ctx context.Context, req providers.EmbeddingRequest, ) (providers.EmbeddingResponse, error)
Embed generates embeddings for the given texts.