Return AmazonS3Vectors initialized from texts and embeddings.
from_texts(
cls: type[AmazonS3Vectors],
texts: list[str],
embedding: Embeddings,
metadatas: Optional[list[dict]] = None,
*,
ids: Optional[list[str]] = None,
vector_bucket_name: str,
index_name: str,
data_type: Literal['float32'] = 'float32',
distance_metric: Literal['euclidean', 'cosine'] = 'cosine',
non_filterable_metadata_keys: list[str] | None = None,
page_content_metadata_key: Optional[str] = '_page_content',
create_index_if_not_exist: bool = True,
relevance_score_fn: Optional[Callable[[float], float]] = None,
region_name: Optional[str] = None,
credentials_profile_name: Optional[str] = None,
aws_access_key_id: Optional[str] = None,
aws_secret_access_key: Optional[str] = None,
aws_session_token: Optional[str] = None,
endpoint_url: Optional[str] = None,
config: Any = None,
client: Any = None,
**kwargs: Any = {}
) -> AmazonS3Vectors| Name | Type | Description |
|---|---|---|
texts* | list[str] | Texts to add to the |
embedding* | Embeddings | Embedding function to use. |
metadatas | Optional[list[dict]] | Default: NoneOptional list of metadatas associated with the texts. Default is None. |
ids | Optional[list[str]] | Default: NoneOptional list of IDs associated with the texts. |
vector_bucket_name* | str | The name of an existing S3 vector bucket |
index_name* | str | The name of the S3 vector index. The index names must be 3 to 63 characters long, start and end with a letter or number, and contain only lowercase letters, numbers, hyphens and dots. |
data_type | Literal['float32'] | Default: 'float32'The data type of the vectors to be inserted into the vector index. Default is "float32". |
distance_metric | Literal['euclidean', 'cosine'] | Default: 'cosine'The distance metric to be used for similarity search. Default is "cosine". |
non_filterable_metadata_keys | list[str] | None | Default: NoneNon-filterable metadata keys |
page_content_metadata_key | Optional[str] | Default: '_page_content'Key of metadata to store page_content in Document. If None, embedding page_content but stored as an empty string. Default is "_page_content". |
create_index_if_not_exist | bool | Default: TrueAutomatically create vector index if it does not exist. Default is True. |
relevance_score_fn | Optional[Callable[[float], float]] | Default: NoneThe 'correct' relevance function. |
region_name | Optional[str] | Default: NoneThe aws region where the Sagemaker model is
deployed, eg. |
credentials_profile_name | Optional[str] | Default: NoneThe name of the profile in the ~/.aws/credentials or ~/.aws/config files, which has either access keys or role information specified. If not specified, the default credential profile or, if on an EC2 instance, credentials from IMDS will be used. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html |
aws_access_key_id | Optional[str] | Default: NoneAWS access key id.
If provided, aws_secret_access_key must also be provided.
If not specified, the default credential profile or,
if on an EC2 instance, credentials from IMDS will be used.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
If not provided, will be read from |
aws_secret_access_key | Optional[str] | Default: NoneAWS secret_access_key.
If provided, aws_access_key_id must also be provided.
If not specified, the default credential profile or,
if on an EC2 instance, credentials from IMDS will be used.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
If not provided, will be read from |
aws_session_token | Optional[str] | Default: NoneAWS session token.
If provided, aws_access_key_id and
aws_secret_access_key must also be provided.
Not required unless using temporary credentials.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
If not provided, will be read from |
endpoint_url | Optional[str] | Default: NoneNeeded if you don't want to default to us-east-1 endpoint |
config | Any | Default: NoneAn optional |
client | Any | Default: NoneBoto3 client for s3vectors |
kwargs | Any | Default: {}Arguments to pass to AmazonS3Vectors. |