base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03["base.py"] cccbe73e_4644_7211_4d55_e8fb133a8014["abc"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> cccbe73e_4644_7211_4d55_e8fb133a8014 cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> f3bc7443_c889_119d_0744_aacc3620d8d2 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> 91721f45_4909_e489_8c1f_084f8bd87145 01158a5b_b299_f45d_92e9_2a7433a1a91a["langchain_classic.chains.base"] ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 --> 01158a5b_b299_f45d_92e9_2a7433a1a91a style ac9cbcbf_5ba6_ac3a_e731_cb08b122ac03 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Base classes for chain routing."""
from __future__ import annotations
from abc import ABC
from collections.abc import Mapping
from typing import Any, NamedTuple
from langchain_core.callbacks import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
Callbacks,
)
from pydantic import ConfigDict
from typing_extensions import override
from langchain_classic.chains.base import Chain
class Route(NamedTuple):
"""A route to a destination chain."""
destination: str | None
next_inputs: dict[str, Any]
class RouterChain(Chain, ABC):
"""Chain that outputs the name of a destination chain and the inputs to it."""
@property
@override
def output_keys(self) -> list[str]:
return ["destination", "next_inputs"]
def route(self, inputs: dict[str, Any], callbacks: Callbacks = None) -> Route:
"""Route inputs to a destination chain.
Args:
inputs: inputs to the chain
callbacks: callbacks to use for the chain
Returns:
a Route object
"""
result = self(inputs, callbacks=callbacks)
return Route(result["destination"], result["next_inputs"])
async def aroute(
self,
inputs: dict[str, Any],
callbacks: Callbacks = None,
) -> Route:
"""Route inputs to a destination chain.
Args:
inputs: inputs to the chain
callbacks: callbacks to use for the chain
Returns:
a Route object
// ... (88 more lines)
Domain
Subdomains
Classes
Dependencies
- abc
- collections.abc
- langchain_classic.chains.base
- langchain_core.callbacks
- pydantic
- typing
- typing_extensions
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 CoreAbstractions domain, RunnableInterface subdomain.
What does base.py depend on?
base.py imports 7 module(s): abc, collections.abc, langchain_classic.chains.base, langchain_core.callbacks, pydantic, typing, typing_extensions.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/router/base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/chains/router).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free