Skip to main content

Parameters

ParameterTypeDefaultDescription
aws_access_key_idOptional[str]NoneAWS access key ID
aws_secret_access_keyOptional[str]NoneAWS secret access key
aws_session_tokenOptional[str]NoneAWS session token
region_namestr"us-east-1"AWS region
profile_nameOptional[str]NoneAWS profile name
model_namestr"amazon.titan-embed-text-v1"Bedrock embedding model
model_idOptional[str]NoneFull Bedrock model ID (overrides model_name)
inference_profileOptional[str]NoneBedrock inference profile
enable_guardrailsboolTrueEnable Bedrock guardrails
guardrail_idOptional[str]NoneCustom guardrail ID
enable_model_cachingboolTrueEnable model response caching
prefer_provisioned_throughputboolFalsePrefer provisioned throughput models
enable_cloudwatch_loggingboolTrueEnable CloudWatch logging
log_group_nameOptional[str]NoneCloudWatch log group name

Functions

__init__

Initialize the BedrockEmbedding provider. Parameters:
  • config (Optional[BedrockEmbeddingConfig]): Configuration object
  • **kwargs: Additional configuration options

_setup_aws_session

Setup AWS session with proper credentials.

_setup_bedrock_client

Setup Bedrock runtime client.

supported_modes

Get supported embedding modes. Returns:
  • List[EmbeddingMode]: List of supported embedding modes

pricing_info

Get AWS Bedrock embedding pricing. Returns:
  • Dict[str, float]: Pricing information

get_model_info

Get information about the current Bedrock model. Returns:
  • Dict[str, Any]: Model information

_prepare_titan_request

Prepare request body for Titan models. Parameters:
  • texts (List[str]): List of texts to embed
Returns:
  • Dict[str, Any]: Request body

_prepare_cohere_request

Prepare request body for Cohere models. Parameters:
  • texts (List[str]): List of texts to embed
Returns:
  • Dict[str, Any]: Request body

_prepare_request_body

Prepare request body based on the model provider. Parameters:
  • texts (List[str]): List of texts to embed
  • mode (EmbeddingMode): Embedding mode
Returns:
  • Dict[str, Any]: Request body

_extract_embeddings

Extract embeddings from response based on model type. Parameters:
  • response_body (Dict[str, Any]): API response body
  • num_texts (int): Number of texts
Returns:
  • List[List[float]]: List of embedding vectors

_embed_batch

Embed a batch of texts using AWS Bedrock. Parameters:
  • texts (List[str]): List of text strings to embed
  • mode (EmbeddingMode): Embedding mode for optimization
Returns:
  • List[List[float]]: List of embedding vectors

validate_connection

Validate Bedrock connection and model access. Returns:
  • bool: True if connection is valid

get_aws_info

Get AWS-specific configuration information. Returns:
  • Dict[str, Any]: AWS configuration information

get_cost_estimate

Get detailed cost estimation for current usage. Returns:
  • Dict[str, Any]: Cost estimation

list_available_models

List available embedding models in Bedrock. Returns:
  • List[Dict[str, Any]]: List of available models

close

Clean up AWS Bedrock connections and resources.

create_titan_embedding

Create AWS Titan embedding provider. Parameters:
  • region_name (str): AWS region
  • model_version (str): Model version
  • **kwargs: Additional configuration options
Returns:
  • BedrockEmbedding: Configured BedrockEmbedding instance

create_cohere_embedding

Create Cohere embedding provider. Parameters:
  • language (str): Language for embedding
  • region_name (str): AWS region
  • **kwargs: Additional configuration options
Returns:
  • BedrockEmbedding: Configured BedrockEmbedding instance
I