RocksetLoader#
- class langchain_community.document_loaders.rocksetdb.RocksetLoader(client: ~typing.Any, query: ~typing.Any, content_keys: ~typing.List[str], metadata_keys: ~typing.List[str] | None = 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 (List[str] | None) β 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.
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__(client: ~typing.Any, query: ~typing.Any, content_keys: ~typing.List[str], metadata_keys: ~typing.List[str] | None = 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 (List[str] | None) β 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]
- 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]
Examples using RocksetLoader