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 – Rockset client object.

  • query – Rockset query object.

  • content_keys – The collection columns to be written into the page_content of the Documents.

  • metadata_keys – 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 – 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.

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 – Rockset client object.

  • query – Rockset query object.

  • content_keys – The collection columns to be written into the page_content of the Documents.

  • metadata_keys – 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 – 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.

lazy_load() Iterator[Document][source]¶

A lazy loader for Documents.

load() List[Document][source]¶

Load data into Document objects.

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]¶

Load Documents and split into chunks. Chunks are returned as Documents.

Parameters

text_splitter – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Examples using RocksetLoader¶