Home / Class/ LangSmithLoader Class — langchain Architecture

LangSmithLoader Class — langchain Architecture

Architecture documentation for the LangSmithLoader class in langsmith.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e0eb9f17_a78c_506d_094b_7f87b2c3d423["LangSmithLoader"]
  a03328f5_8313_3e81_e0e5_6b8aa55a53b8["BaseLoader"]
  e0eb9f17_a78c_506d_094b_7f87b2c3d423 -->|extends| a03328f5_8313_3e81_e0e5_6b8aa55a53b8
  f888f620_588b_5cc9_1ac1_98ec52f4a0cd["langsmith.py"]
  e0eb9f17_a78c_506d_094b_7f87b2c3d423 -->|defined in| f888f620_588b_5cc9_1ac1_98ec52f4a0cd
  31d1cd3e_7383_3abf_9124_6b59ac571e99["__init__()"]
  e0eb9f17_a78c_506d_094b_7f87b2c3d423 -->|method| 31d1cd3e_7383_3abf_9124_6b59ac571e99
  a16fdc73_2b38_0ffb_5cec_1e44162130bb["lazy_load()"]
  e0eb9f17_a78c_506d_094b_7f87b2c3d423 -->|method| a16fdc73_2b38_0ffb_5cec_1e44162130bb

Relationship Graph

Source Code

libs/core/langchain_core/document_loaders/langsmith.py lines 17–134

class LangSmithLoader(BaseLoader):
    """Load LangSmith Dataset examples as `Document` objects.

    Loads the example inputs as the `Document` page content and places the entire
    example into the `Document` metadata. This allows you to easily create few-shot
    example retrievers from the loaded documents.

    ??? example "Lazy loading"

        ```python
        from langchain_core.document_loaders import LangSmithLoader

        loader = LangSmithLoader(dataset_id="...", limit=100)
        docs = []
        for doc in loader.lazy_load():
            docs.append(doc)
        ```

        ```python
        # -> [Document("...", metadata={"inputs": {...}, "outputs": {...}, ...}), ...]
        ```
    """

    def __init__(
        self,
        *,
        dataset_id: uuid.UUID | str | None = None,
        dataset_name: str | None = None,
        example_ids: Sequence[uuid.UUID | str] | None = None,
        as_of: datetime.datetime | str | None = None,
        splits: Sequence[str] | None = None,
        inline_s3_urls: bool = True,
        offset: int = 0,
        limit: int | None = None,
        metadata: dict | None = None,
        filter: str | None = None,  # noqa: A002
        content_key: str = "",
        format_content: Callable[..., str] | None = None,
        client: LangSmithClient | None = None,
        **client_kwargs: Any,
    ) -> None:
        """Create a LangSmith loader.

        Args:
            dataset_id: The ID of the dataset to filter by.
            dataset_name: The name of the dataset to filter by.
            content_key: The inputs key to set as `Document` page content.

                `'.'` characters are interpreted as nested keys, e.g.
                `content_key="first.second"` will result in
                `Document(page_content=format_content(example.inputs["first"]["second"]))`
            format_content: Function for converting the content extracted from the example
                inputs into a string.

                Defaults to JSON-encoding the contents.
            example_ids: The IDs of the examples to filter by.
            as_of: The dataset version tag or timestamp to retrieve the examples as of.

                Response examples will only be those that were present at the time of
                the tagged (or timestamped) version.
            splits: A list of dataset splits, which are divisions of your dataset such
                as `train`, `test`, or `validation`.

                Returns examples only from the specified splits.
            inline_s3_urls: Whether to inline S3 URLs.
            offset: The offset to start from.
            limit: The maximum number of examples to return.
            metadata: Metadata to filter by.
            filter: A structured filter string to apply to the examples.
            client: LangSmith Client.

                If not provided will be initialized from below args.
            client_kwargs: Keyword args to pass to LangSmith client init.

                Should only be specified if `client` isn't.

        Raises:
            ValueError: If both `client` and `client_kwargs` are provided.
        """  # noqa: E501
        if client and client_kwargs:
            raise ValueError

Extends

Frequently Asked Questions

What is the LangSmithLoader class?
LangSmithLoader is a class in the langchain codebase, defined in libs/core/langchain_core/document_loaders/langsmith.py.
Where is LangSmithLoader defined?
LangSmithLoader is defined in libs/core/langchain_core/document_loaders/langsmith.py at line 17.
What does LangSmithLoader extend?
LangSmithLoader extends BaseLoader.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free