AstraDBLoader#
- class langchain_astradb.document_loaders.AstraDBLoader(collection_name: str, *, token: str | ~astrapy.authentication.TokenProvider | None = None, api_endpoint: str | None = None, environment: str | None = None, astra_db_client: ~astrapy.core.db.AstraDB | None = None, async_astra_db_client: ~astrapy.core.db.AsyncAstraDB | None = None, namespace: str | None = None, filter_criteria: ~typing.Dict[str, ~typing.Any] | None = None, projection: ~typing.Dict[str, ~typing.Any] | None = <object object>, find_options: ~typing.Dict[str, ~typing.Any] | None = None, limit: int | None = None, nb_prefetched: int = <object object>, page_content_mapper: ~typing.Callable[[~typing.Dict], str] = <function dumps>, metadata_mapper: ~typing.Callable[[~typing.Dict], ~typing.Dict[str, ~typing.Any]] | None = None)[source]#
Load DataStax Astra DB documents.
- Parameters:
collection_name (str) â name of the Astra DB collection to use.
token (Optional[Union[str, TokenProvider]]) â API token for Astra DB usage, either in the form of a string or a subclass of astrapy.authentication.TokenProvider. If not provided, the environment variable ASTRA_DB_APPLICATION_TOKEN is inspected.
api_endpoint (Optional[str]) â full URL to the API endpoint, such as https://<DB-ID>-us-east1.apps.astra.datastax.com. If not provided, the environment variable ASTRA_DB_API_ENDPOINT is inspected.
environment (Optional[str]) â a string specifying the environment of the target Data API. If omitted, defaults to âprodâ (Astra DB production). Other values are in astrapy.constants.Environment enum class.
astra_db_client (Optional[AstraDB]) â DEPRECATED starting from version 0.3.5. Please use âtokenâ, âapi_endpointâ and optionally âenvironmentâ. you can pass an already-created âastrapy.db.AstraDBâ instance (alternatively to âtokenâ, âapi_endpointâ and âenvironmentâ).
async_astra_db_client (Optional[AsyncAstraDB]) â DEPRECATED starting from version 0.3.5. Please use âtokenâ, âapi_endpointâ and optionally âenvironmentâ. you can pass an already-created âastrapy.db.AsyncAstraDBâ instance (alternatively to âtokenâ, âapi_endpointâ and âenvironmentâ).
namespace (Optional[str]) â namespace (aka keyspace) where the collection resides. If not provided, the environment variable ASTRA_DB_KEYSPACE is inspected. Defaults to the databaseâs âdefault namespaceâ.
filter_criteria (Optional[Dict[str, Any]]) â Criteria to filter documents.
projection (Optional[Dict[str, Any]]) â Specifies the fields to return. If not provided, reads fall back to the Data API default projection.
find_options (Optional[Dict[str, Any]]) â Additional options for the query. DEPRECATED starting from version 0.3.5. For limiting, please use `limit`. Other options are ignored.
limit (Optional[int]) â a maximum number of documents to return in the read query.
nb_prefetched (int) â Max number of documents to pre-fetch. IGNORED starting from v. 0.3.5: astrapy v1.0+ does not support it.
page_content_mapper (Callable[[Dict], str]) â Function applied to collection documents to create the page_content of the LangChain Document. Defaults to json.dumps.
metadata_mapper (Optional[Callable[[Dict], Dict[str, Any]]])
Methods
__init__
(collection_name, *[, token, ...])Load DataStax Astra DB documents.
A lazy loader for Documents.
aload
()Load data into Document objects.
A lazy loader for Documents.
load
()Load data into Document objects.
load_and_split
([text_splitter])Load Documents and split into chunks.
- __init__(collection_name: str, *, token: str | ~astrapy.authentication.TokenProvider | None = None, api_endpoint: str | None = None, environment: str | None = None, astra_db_client: ~astrapy.core.db.AstraDB | None = None, async_astra_db_client: ~astrapy.core.db.AsyncAstraDB | None = None, namespace: str | None = None, filter_criteria: ~typing.Dict[str, ~typing.Any] | None = None, projection: ~typing.Dict[str, ~typing.Any] | None = <object object>, find_options: ~typing.Dict[str, ~typing.Any] | None = None, limit: int | None = None, nb_prefetched: int = <object object>, page_content_mapper: ~typing.Callable[[~typing.Dict], str] = <function dumps>, metadata_mapper: ~typing.Callable[[~typing.Dict], ~typing.Dict[str, ~typing.Any]] | None = None) None [source]#
Load DataStax Astra DB documents.
- Parameters:
collection_name (str) â name of the Astra DB collection to use.
token (str | TokenProvider | None) â API token for Astra DB usage, either in the form of a string or a subclass of astrapy.authentication.TokenProvider. If not provided, the environment variable ASTRA_DB_APPLICATION_TOKEN is inspected.
api_endpoint (str | None) â full URL to the API endpoint, such as https://<DB-ID>-us-east1.apps.astra.datastax.com. If not provided, the environment variable ASTRA_DB_API_ENDPOINT is inspected.
environment (str | None) â a string specifying the environment of the target Data API. If omitted, defaults to âprodâ (Astra DB production). Other values are in astrapy.constants.Environment enum class.
astra_db_client (AstraDB | None) â DEPRECATED starting from version 0.3.5. Please use âtokenâ, âapi_endpointâ and optionally âenvironmentâ. you can pass an already-created âastrapy.db.AstraDBâ instance (alternatively to âtokenâ, âapi_endpointâ and âenvironmentâ).
async_astra_db_client (AsyncAstraDB | None) â DEPRECATED starting from version 0.3.5. Please use âtokenâ, âapi_endpointâ and optionally âenvironmentâ. you can pass an already-created âastrapy.db.AsyncAstraDBâ instance (alternatively to âtokenâ, âapi_endpointâ and âenvironmentâ).
namespace (str | None) â namespace (aka keyspace) where the collection resides. If not provided, the environment variable ASTRA_DB_KEYSPACE is inspected. Defaults to the databaseâs âdefault namespaceâ.
filter_criteria (Dict[str, Any] | None) â Criteria to filter documents.
projection (Dict[str, Any] | None) â Specifies the fields to return. If not provided, reads fall back to the Data API default projection.
find_options (Dict[str, Any] | None) â Additional options for the query. DEPRECATED starting from version 0.3.5. For limiting, please use `limit`. Other options are ignored.
limit (int | None) â a maximum number of documents to return in the read query.
nb_prefetched (int) â Max number of documents to pre-fetch. IGNORED starting from v. 0.3.5: astrapy v1.0+ does not support it.
page_content_mapper (Callable[[Dict], str]) â Function applied to collection documents to create the page_content of the LangChain Document. Defaults to json.dumps.
metadata_mapper (Callable[[Dict], Dict[str, Any]] | None)
- Return type:
None
- async alazy_load() AsyncIterator[Document] [source]#
A lazy loader for Documents.
- Return type:
AsyncIterator[Document]
- lazy_load() Iterator[Document] [source]#
A lazy loader for Documents.
- Return type:
Iterator[Document]
- load_and_split(text_splitter: TextSplitter | None = None) List[Document] #
Load Documents and split into chunks. Chunks are returned as Documents.
Do not override this method. It should be considered to be deprecated!
- Parameters:
text_splitter (Optional[TextSplitter]) â TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.
- Returns:
List of Documents.
- Return type:
List[Document]