Home / File/ base.py — langchain Source File

base.py — langchain Source File

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

Entity Profile

Dependency Diagram

graph LR
  a40b54b2_e125_6f7e_8695_d0b2586d45b2["base.py"]
  2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 2bf6d401_816d_d011_3b05_a6114f55ff58
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> feec1ec4_6917_867b_d228_b134d0ff8099
  2485b66a_3839_d0b6_ad9c_a4ff40457dc6["langchain_core._api"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 2485b66a_3839_d0b6_ad9c_a4ff40457dc6
  17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 17a62cb3_fefd_6320_b757_b53bb4a1c661
  e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> e929cf21_6ab8_6ff3_3765_0d35a099a053
  435e49bf_bb2e_2016_ead7_0afb9d57ad71["langchain_core.prompts"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 435e49bf_bb2e_2016_ead7_0afb9d57ad71
  121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4
  255236bb_6d88_54a6_3d01_c4f086541fd2["langchain_core.tools.render"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 255236bb_6d88_54a6_3d01_c4f086541fd2
  dd5e7909_a646_84f1_497b_cae69735550e["pydantic"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> dd5e7909_a646_84f1_497b_cae69735550e
  f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> f85fae70_1011_eaec_151c_4083140ae9e5
  a1cf359b_dc20_be00_cf73_e72d60eab3d2["langchain_classic._api.deprecation"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> a1cf359b_dc20_be00_cf73_e72d60eab3d2
  496466eb_d5c8_fece_1b1f_31541c641cdd["langchain_classic.agents.agent"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 496466eb_d5c8_fece_1b1f_31541c641cdd
  a6130799_fe22_58f5_4f6a_97737e38ea44["langchain_classic.agents.agent_types"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> a6130799_fe22_58f5_4f6a_97737e38ea44
  3cbae591_c460_0811_c3a9_e4e178e9e772["langchain_classic.agents.mrkl.output_parser"]
  a40b54b2_e125_6f7e_8695_d0b2586d45b2 --> 3cbae591_c460_0811_c3a9_e4e178e9e772
  style a40b54b2_e125_6f7e_8695_d0b2586d45b2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Attempt to implement MRKL systems as described in arxiv.org/pdf/2205.00445.pdf."""

from __future__ import annotations

from collections.abc import Callable, Sequence
from typing import Any, NamedTuple

from langchain_core._api import deprecated
from langchain_core.callbacks import BaseCallbackManager
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import PromptTemplate
from langchain_core.tools import BaseTool, Tool
from langchain_core.tools.render import render_text_description
from pydantic import Field
from typing_extensions import override

from langchain_classic._api.deprecation import AGENT_DEPRECATION_WARNING
from langchain_classic.agents.agent import Agent, AgentExecutor, AgentOutputParser
from langchain_classic.agents.agent_types import AgentType
from langchain_classic.agents.mrkl.output_parser import MRKLOutputParser
from langchain_classic.agents.mrkl.prompt import FORMAT_INSTRUCTIONS, PREFIX, SUFFIX
from langchain_classic.agents.utils import validate_tools_single_input
from langchain_classic.chains import LLMChain


class ChainConfig(NamedTuple):
    """Configuration for a chain to use in MRKL system.

    Args:
        action_name: Name of the action.
        action: Action function to call.
        action_description: Description of the action.
    """

    action_name: str
    action: Callable
    action_description: str


@deprecated(
    "0.1.0",
    message=AGENT_DEPRECATION_WARNING,
    removal="1.0",
)
class ZeroShotAgent(Agent):
    """Agent for the MRKL chain.

    Args:
        output_parser: Output parser for the agent.
    """

    output_parser: AgentOutputParser = Field(default_factory=MRKLOutputParser)

    @classmethod
    @override
    def _get_default_output_parser(cls, **kwargs: Any) -> AgentOutputParser:
        return MRKLOutputParser()

    @property
    def _agent_type(self) -> str:
// ... (157 more lines)

Subdomains

Dependencies

  • collections.abc
  • langchain_classic._api.deprecation
  • langchain_classic.agents.agent
  • langchain_classic.agents.agent_types
  • langchain_classic.agents.mrkl.output_parser
  • langchain_classic.agents.mrkl.prompt
  • langchain_classic.agents.utils
  • langchain_classic.chains
  • langchain_core._api
  • langchain_core.callbacks
  • langchain_core.language_models
  • langchain_core.prompts
  • langchain_core.tools
  • langchain_core.tools.render
  • pydantic
  • typing
  • typing_extensions

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 does base.py depend on?
base.py imports 17 module(s): collections.abc, langchain_classic._api.deprecation, langchain_classic.agents.agent, langchain_classic.agents.agent_types, langchain_classic.agents.mrkl.output_parser, langchain_classic.agents.mrkl.prompt, langchain_classic.agents.utils, langchain_classic.chains, and 9 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/agents/mrkl/base.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/agents/mrkl).

Analyze Your Own Codebase

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

Try Supermodel Free