langchain_community.document_loaders.astradb.AstraDBLoader

class langchain_community.document_loaders.astradb.AstraDBLoader(collection_name: str, *, token: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[AstraDB] = None, async_astra_db_client: Optional[AsyncAstraDB] = None, namespace: Optional[str] = None, filter_criteria: Optional[Dict[str, Any]] = None, projection: Optional[Dict[str, Any]] = None, find_options: Optional[Dict[str, Any]] = None, nb_prefetched: int = 1000, extraction_function: Callable[[Dict], str] = <function dumps>)[source]

Load DataStax Astra DB documents.

Parameters
  • collection_name (str) – name of the Astra DB collection to 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. 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.

  • find_options (Optional[Dict[str, Any]]) – Additional options for the query.

  • nb_prefetched (int) – Max number of documents to pre-fetch. Defaults to 1000.

  • extraction_function (Callable[[Dict], str]) – Function applied to collection documents to create the page_content of the LangChain Document. Defaults to json.dumps.

Methods

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

Load DataStax Astra DB documents.

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

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: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[AstraDB] = None, async_astra_db_client: Optional[AsyncAstraDB] = None, namespace: Optional[str] = None, filter_criteria: Optional[Dict[str, Any]] = None, projection: Optional[Dict[str, Any]] = None, find_options: Optional[Dict[str, Any]] = None, nb_prefetched: int = 1000, extraction_function: Callable[[Dict], str] = <function dumps>) None[source]

Load DataStax Astra DB documents.

Parameters
  • collection_name (str) – name of the Astra DB collection to 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. 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.

  • find_options (Optional[Dict[str, Any]]) – Additional options for the query.

  • nb_prefetched (int) – Max number of documents to pre-fetch. Defaults to 1000.

  • extraction_function (Callable[[Dict], str]) – Function applied to collection documents to create the page_content of the LangChain Document. Defaults to json.dumps.

Return type

None

async alazy_load() AsyncIterator[Document][source]

A lazy loader for Documents.

Return type

AsyncIterator[Document]

async aload() List[Document][source]

Load data into Document objects.

Return type

List[Document]

lazy_load() Iterator[Document][source]

A lazy loader for Documents.

Return type

Iterator[Document]

load() List[Document]

Load data into Document objects.

Return type

List[Document]

load_and_split(text_splitter: Optional[TextSplitter] = 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]