langchain_community.document_loaders.rocksetdb.RocksetLoader¶

class langchain_community.document_loaders.rocksetdb.RocksetLoader(client: ~typing.Any, query: ~typing.Any, content_keys: ~typing.List[str], metadata_keys: ~typing.Optional[~typing.List[str]] = None, content_columns_joiner: ~typing.Callable[[~typing.List[~typing.Tuple[str, ~typing.Any]]], str] = <function default_joiner>)[source]¶

Load from a Rockset database.

To use, you should have the rockset python package installed.

Example

# This code will load 3 records from the "langchain_demo"
# collection as Documents, with the `text` column used as
# the content

from langchain_community.document_loaders import RocksetLoader
from rockset import RocksetClient, Regions, models

loader = RocksetLoader(
    RocksetClient(Regions.usw2a1, "<api key>"),
    models.QueryRequestSql(
        query="select * from langchain_demo limit 3"
    ),
    ["text"]
)

)

Initialize with Rockset client.

Parameters
  • client (Any) – Rockset client object.

  • query (Any) – Rockset query object.

  • content_keys (List[str]) – The collection columns to be written into the page_content of the Documents.

  • metadata_keys (Optional[List[str]]) – The collection columns to be written into the metadata of the Documents. By default, this is all the keys in the document.

  • content_columns_joiner (Callable[[List[Tuple[str, Any]]], str]) – Method that joins content_keys and its values into a string. It’s method that takes in a List[Tuple[str, Any]]], representing a list of tuples of (column name, column value). By default, this is a method that joins each column value with a new line. This method is only relevant if there are multiple content_keys.

Methods

__init__(client, query, content_keys[, ...])

Initialize with Rockset client.

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__(client: ~typing.Any, query: ~typing.Any, content_keys: ~typing.List[str], metadata_keys: ~typing.Optional[~typing.List[str]] = None, content_columns_joiner: ~typing.Callable[[~typing.List[~typing.Tuple[str, ~typing.Any]]], str] = <function default_joiner>)[source]¶

Initialize with Rockset client.

Parameters
  • client (Any) – Rockset client object.

  • query (Any) – Rockset query object.

  • content_keys (List[str]) – The collection columns to be written into the page_content of the Documents.

  • metadata_keys (Optional[List[str]]) – The collection columns to be written into the metadata of the Documents. By default, this is all the keys in the document.

  • content_columns_joiner (Callable[[List[Tuple[str, Any]]], str]) – Method that joins content_keys and its values into a string. It’s method that takes in a List[Tuple[str, Any]]], representing a list of tuples of (column name, column value). By default, this is a method that joins each column value with a new line. This method is only relevant if there are multiple content_keys.

async alazy_load() AsyncIterator[Document]¶

A lazy loader for Documents.

Return type

AsyncIterator[Document]

async aload() List[Document]¶

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]

Examples using RocksetLoader¶