Home / File/ base.py — langchain Source File

base.py — langchain Source File

Architecture documentation for base.py, a python file in the langchain codebase. 10 imports, 0 dependents.

File python CoreAbstractions Serialization 10 imports 1 functions 9 classes

Entity Profile

Dependency Diagram

graph LR
  aa78d849_32e0_cbe3_8323_1a62fafa0824["base.py"]
  2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  30db3e5b_4549_fdf8_eed3_1cfd8cacbe56["tenacity"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 30db3e5b_4549_fdf8_eed3_1cfd8cacbe56
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 91721f45_4909_e489_8c1f_084f8bd87145
  80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> d758344f_537f_649e_f467_b9d7442e86df
  ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"]
  aa78d849_32e0_cbe3_8323_1a62fafa0824 --> ac2a9b92_4484_491e_1b48_ec85e71e1d58
  style aa78d849_32e0_cbe3_8323_1a62fafa0824 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Base callback handler for LangChain."""

from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
    from collections.abc import Sequence
    from uuid import UUID

    from tenacity import RetryCallState
    from typing_extensions import Self

    from langchain_core.agents import AgentAction, AgentFinish
    from langchain_core.documents import Document
    from langchain_core.messages import BaseMessage
    from langchain_core.outputs import ChatGenerationChunk, GenerationChunk, LLMResult

_LOGGER = logging.getLogger(__name__)


class RetrieverManagerMixin:
    """Mixin for `Retriever` callbacks."""

    def on_retriever_error(
        self,
        error: BaseException,
        *,
        run_id: UUID,
        parent_run_id: UUID | None = None,
        **kwargs: Any,
    ) -> Any:
        """Run when `Retriever` errors.

        Args:
            error: The error that occurred.
            run_id: The ID of the current run.
            parent_run_id: The ID of the parent run.
            **kwargs: Additional keyword arguments.
        """

    def on_retriever_end(
        self,
        documents: Sequence[Document],
        *,
        run_id: UUID,
        parent_run_id: UUID | None = None,
        **kwargs: Any,
    ) -> Any:
        """Run when `Retriever` ends running.

        Args:
            documents: The documents retrieved.
            run_id: The ID of the current run.
            parent_run_id: The ID of the parent run.
            **kwargs: Additional keyword arguments.
        """


// ... (1058 more lines)

Subdomains

Functions

Dependencies

  • collections.abc
  • langchain_core.agents
  • langchain_core.documents
  • langchain_core.messages
  • langchain_core.outputs
  • logging
  • tenacity
  • typing
  • typing_extensions
  • uuid

Frequently Asked Questions

What does base.py do?
base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in base.py?
base.py defines 1 function(s): collections.
What does base.py depend on?
base.py imports 10 module(s): collections.abc, langchain_core.agents, langchain_core.documents, langchain_core.messages, langchain_core.outputs, logging, tenacity, typing, and 2 more.
Where is base.py in the architecture?
base.py is located at libs/core/langchain_core/callbacks/base.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core/callbacks).

Analyze Your Own Codebase

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

Try Supermodel Free