langchain_community.storage.astradb.AstraDBByteStore

class langchain_community.storage.astradb.AstraDBByteStore(collection_name: str, token: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[AstraDB] = None, namespace: Optional[str] = None, *, async_astra_db_client: Optional[AsyncAstraDB] = None, pre_delete_collection: bool = False, setup_mode: SetupMode = SetupMode.SYNC)[source]

[Deprecated]

Notes

Deprecated since version langchain-community==0.0.22.

ByteStore implementation using DataStax AstraDB as the underlying store.

The bytes values are converted to base64 encoded strings Documents in the AstraDB collection will have the format

{
  "_id": "<key>",
  "value": "<byte64 string value>"
}
Parameters
  • collection_name (str) – name of the Astra DB collection to create/use.

  • token (Optional[str]) – API token for Astra DB usage.

  • api_endpoint (Optional[str]) – full URL to the API endpoint, such as https://<DB-ID>-us-east1.apps.astra.datastax.com.

  • astra_db_client (Optional[AstraDB]) – alternative to token+api_endpoint, you can pass an already-created ‘astrapy.db.AstraDB’ instance.

  • async_astra_db_client (Optional[AsyncAstraDB]) – alternative to token+api_endpoint, you can pass an already-created ‘astrapy.db.AsyncAstraDB’ instance.

  • namespace (Optional[str]) – namespace (aka keyspace) where the collection is created. Defaults to the database’s “default namespace”.

  • setup_mode (SetupMode) – mode used to create the Astra DB collection (SYNC, ASYNC or OFF).

  • pre_delete_collection (bool) – whether to delete the collection before creating it. If False and the collection already exists, the collection will be used as is.

Methods

__init__(collection_name[, token, ...])

ByteStore implementation using DataStax AstraDB as the underlying store.

amdelete(keys)

Delete the given keys and their associated values.

amget(keys)

Get the values associated with the given keys.

amset(key_value_pairs)

Set the values for the given keys.

ayield_keys(*[, prefix])

Get an iterator over keys that match the given prefix.

decode_value(value)

Decodes value from Astra DB

encode_value(value)

Encodes value for Astra DB

mdelete(keys)

Delete the given keys and their associated values.

mget(keys)

Get the values associated with the given keys.

mset(key_value_pairs)

Set the values for the given keys.

yield_keys(*[, prefix])

Get an iterator over keys that match the given prefix.

__init__(collection_name: str, token: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[AstraDB] = None, namespace: Optional[str] = None, *, async_astra_db_client: Optional[AsyncAstraDB] = None, pre_delete_collection: bool = False, setup_mode: SetupMode = SetupMode.SYNC) None[source]

ByteStore implementation using DataStax AstraDB as the underlying store.

The bytes values are converted to base64 encoded strings Documents in the AstraDB collection will have the format

{
  "_id": "<key>",
  "value": "<byte64 string value>"
}
Parameters
  • collection_name (str) – name of the Astra DB collection to create/use.

  • token (Optional[str]) – API token for Astra DB usage.

  • api_endpoint (Optional[str]) – full URL to the API endpoint, such as https://<DB-ID>-us-east1.apps.astra.datastax.com.

  • astra_db_client (Optional[AstraDB]) – alternative to token+api_endpoint, you can pass an already-created ‘astrapy.db.AstraDB’ instance.

  • async_astra_db_client (Optional[AsyncAstraDB]) – alternative to token+api_endpoint, you can pass an already-created ‘astrapy.db.AsyncAstraDB’ instance.

  • namespace (Optional[str]) – namespace (aka keyspace) where the collection is created. Defaults to the database’s “default namespace”.

  • setup_mode (SetupMode) – mode used to create the Astra DB collection (SYNC, ASYNC or OFF).

  • pre_delete_collection (bool) – whether to delete the collection before creating it. If False and the collection already exists, the collection will be used as is.

Return type

None

async amdelete(keys: Sequence[str]) None

Delete the given keys and their associated values.

Parameters

keys (Sequence[K]) – A sequence of keys to delete.

Return type

None

async amget(keys: Sequence[str]) List[Optional[V]]

Get the values associated with the given keys.

Parameters

keys (Sequence[K]) – A sequence of keys.

Returns

A sequence of optional values associated with the keys. If a key is not found, the corresponding value will be None.

Return type

List[Optional[V]]

async amset(key_value_pairs: Sequence[Tuple[str, V]]) None

Set the values for the given keys.

Parameters

key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.

Return type

None

async ayield_keys(*, prefix: Optional[str] = None) AsyncIterator[str]

Get an iterator over keys that match the given prefix.

Parameters

prefix (str) – The prefix to match.

Returns

An iterator over keys that match the given prefix.

This method is allowed to return an iterator over either K or str depending on what makes more sense for the given store.

Return type

Iterator[K | str]

decode_value(value: Any) Optional[bytes][source]

Decodes value from Astra DB

Parameters

value (Any) –

Return type

Optional[bytes]

encode_value(value: Optional[bytes]) Any[source]

Encodes value for Astra DB

Parameters

value (Optional[bytes]) –

Return type

Any

mdelete(keys: Sequence[str]) None

Delete the given keys and their associated values.

Parameters

keys (Sequence[K]) – A sequence of keys to delete.

Return type

None

mget(keys: Sequence[str]) List[Optional[V]]

Get the values associated with the given keys.

Parameters

keys (Sequence[K]) – A sequence of keys.

Returns

A sequence of optional values associated with the keys. If a key is not found, the corresponding value will be None.

Return type

List[Optional[V]]

mset(key_value_pairs: Sequence[Tuple[str, V]]) None

Set the values for the given keys.

Parameters

key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.

Return type

None

yield_keys(*, prefix: Optional[str] = None) Iterator[str]

Get an iterator over keys that match the given prefix.

Parameters

prefix (str) – The prefix to match.

Returns

An iterator over keys that match the given prefix.

This method is allowed to return an iterator over either K or str depending on what makes more sense for the given store.

Return type

Iterator[K | str]