pyseekdb.utils.embedding_functions.AmazonBedrockEmbeddingFunction
- class pyseekdb.utils.embedding_functions.AmazonBedrockEmbeddingFunction(session: Any, model_name: str = 'amazon.titan-embed-text-v2', **kwargs: Any)[source]
Bases:
EmbeddingFunction[str|list[str]]A convenient embedding function for Amazon Bedrock embedding models using boto3.
For more information about Amazon Bedrock models, see https://docs.aws.amazon.com/bedrock/
This embedding function runs remotely on Amazon Bedrock’s servers, and requires AWS credentials configured via boto3.
Example
pip install pyseekdb boto3
- __init__(session: Any, model_name: str = 'amazon.titan-embed-text-v2', **kwargs: Any)[source]
Initialize AmazonBedrockEmbeddingFunction.
- Parameters:
session (boto3.Session) – A boto3 Session object to use. The session should be configured with appropriate credentials and region. region_name and profile_name will be extracted from the session for config storage.
model_name (str, optional) – Name of the Amazon Bedrock embedding model. Defaults to “amazon.titan-embed-text-v2”. See Amazon Bedrock documentation for all available models
**kwargs – Additional arguments passed to boto3.client(). Common options include: - endpoint_url: Custom endpoint URL (for testing or custom deployments) - config: boto3 Config object for advanced configuration - See boto3 documentation for more options
Methods
__init__(session[, model_name])Initialize AmazonBedrockEmbeddingFunction.
build_from_config(config)Build an AmazonBedrockEmbeddingFunction from its configuration dictionary.
Get the configuration dictionary for the AmazonBedrockEmbeddingFunction.
name()support_persistence(embedding_function)Check if the embedding function supports persistence.
Attributes
Get the dimension of embeddings produced by this function.
- static build_from_config(config: dict[str, Any]) AmazonBedrockEmbeddingFunction[source]
Build an AmazonBedrockEmbeddingFunction from its configuration dictionary.
- Parameters:
config – Dictionary containing the embedding function’s configuration. Note: AWS credentials are NOT stored in config for security reasons. Credentials should be provided via environment variables, IAM roles, or passed as additional parameters.
- Returns:
Restored AmazonBedrockEmbeddingFunction instance
- Raises:
ValueError – If the configuration is invalid or missing required fields
- property dimension: int
Get the dimension of embeddings produced by this function.
Returns the known dimension for models without making an API call. If the model is in the known dimensions list, that value is returned.
If the model is not in the known dimensions list, falls back to making an API call to get the embedding and infer the dimension.
- Returns:
The dimension of embeddings for this model.
- Return type:
int
- get_config() dict[str, Any][source]
Get the configuration dictionary for the AmazonBedrockEmbeddingFunction.
- Returns:
Dictionary containing configuration needed to restore this embedding function. Note: AWS credentials are NOT stored in the config for security reasons. Credentials should be provided via environment variables, IAM roles, or passed as parameters when restoring.