base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 20 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0fdffdb8_b5ef_983c_15bf_420a6171b921["base.py"] f75eb023_c1ea_859a_7480_1e57f335d1de["builtins"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> f75eb023_c1ea_859a_7480_1e57f335d1de be45a0bb_0276_f8f1_f985_55cddb92c224["contextlib"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> be45a0bb_0276_f8f1_f985_55cddb92c224 589b2e2f_c593_ed0a_7906_df4ca371d542["inspect"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 589b2e2f_c593_ed0a_7906_df4ca371d542 9d14ea65_8b2e_6721_a947_acc89905651f["json"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 9d14ea65_8b2e_6721_a947_acc89905651f e27da29f_a1f7_49f3_84d5_6be4cb4125c8["logging"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> e27da29f_a1f7_49f3_84d5_6be4cb4125c8 f3365e3c_fb7a_bb9a_bc79_059b06cb7024["warnings"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> f3365e3c_fb7a_bb9a_bc79_059b06cb7024 50e20440_a135_6be3_a5a5_67791be5a2a6["abc"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 50e20440_a135_6be3_a5a5_67791be5a2a6 927570d8_11a6_5c17_0f0d_80baae0c733e["pathlib"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 927570d8_11a6_5c17_0f0d_80baae0c733e feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> feec1ec4_6917_867b_d228_b134d0ff8099 a869785a_d507_1688_0b32_0ec94043975a["yaml"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> a869785a_d507_1688_0b32_0ec94043975a 2485b66a_3839_d0b6_ad9c_a4ff40457dc6["langchain_core._api"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 2485b66a_3839_d0b6_ad9c_a4ff40457dc6 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 4382dc25_6fba_324a_49e2_e9742d579385["langchain_core.outputs"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 4382dc25_6fba_324a_49e2_e9742d579385 31eab4ab_7281_1e6c_b17d_12e6ad9de07a["langchain_core.runnables"] 0fdffdb8_b5ef_983c_15bf_420a6171b921 --> 31eab4ab_7281_1e6c_b17d_12e6ad9de07a style 0fdffdb8_b5ef_983c_15bf_420a6171b921 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Base interface that all chains should implement."""
import builtins
import contextlib
import inspect
import json
import logging
import warnings
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any, cast
import yaml
from langchain_core._api import deprecated
from langchain_core.callbacks import (
AsyncCallbackManager,
AsyncCallbackManagerForChainRun,
BaseCallbackManager,
CallbackManager,
CallbackManagerForChainRun,
Callbacks,
)
from langchain_core.outputs import RunInfo
from langchain_core.runnables import (
RunnableConfig,
RunnableSerializable,
ensure_config,
run_in_executor,
)
from langchain_core.utils.pydantic import create_model
from pydantic import (
BaseModel,
ConfigDict,
Field,
field_validator,
model_validator,
)
from typing_extensions import override
from langchain_classic.base_memory import BaseMemory
from langchain_classic.schema import RUN_KEY
logger = logging.getLogger(__name__)
def _get_verbosity() -> bool:
from langchain_classic.globals import get_verbose
return get_verbose()
class Chain(RunnableSerializable[dict[str, Any], dict[str, Any]], ABC):
"""Abstract base class for creating structured sequences of calls to components.
Chains should be used to encode a sequence of calls to components like
models, document retrievers, other chains, etc., and provide a simple interface
to this sequence.
The Chain interface makes it easy to create apps that are:
- Stateful: add Memory to any Chain to give it state,
// ... (747 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- abc
- builtins
- contextlib
- inspect
- json
- langchain_classic.base_memory
- langchain_classic.globals
- langchain_classic.schema
- langchain_core._api
- langchain_core.callbacks
- langchain_core.outputs
- langchain_core.runnables
- langchain_core.utils.pydantic
- logging
- pathlib
- pydantic
- typing
- typing_extensions
- warnings
- yaml
Source
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 AgentOrchestration domain, ClassicChains subdomain.
What functions are defined in base.py?
base.py defines 1 function(s): _get_verbosity.
What does base.py depend on?
base.py imports 20 module(s): abc, builtins, contextlib, inspect, json, langchain_classic.base_memory, langchain_classic.globals, langchain_classic.schema, and 12 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/base.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/chains).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free