Home / File/ base.py — langchain Source File

base.py — langchain Source File

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

File python AgentOrchestration ToolInterface 20 imports 24 functions 8 classes

Entity Profile

Dependency Diagram

graph LR
  80cebff4_efbd_4311_85e9_de0dc81a7eee["base.py"]
  c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6
  614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 614e7b9f_ed51_0780_749c_ff40b74963fc
  7025b240_fdc3_cf68_b72f_f41dac94566b["json"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 7025b240_fdc3_cf68_b72f_f41dac94566b
  2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  0c635125_6987_b8b3_7ff7_d60249aecde7["warnings"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 0c635125_6987_b8b3_7ff7_d60249aecde7
  cccbe73e_4644_7211_4d55_e8fb133a8014["abc"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> cccbe73e_4644_7211_4d55_e8fb133a8014
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 91721f45_4909_e489_8c1f_084f8bd87145
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  d37712e8_0aaa_0e67_fe9c_15ba87012437["pydantic.fields"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> d37712e8_0aaa_0e67_fe9c_15ba87012437
  63ae09a2_4a67_3eaf_7888_b0fd11776a0e["pydantic.v1"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 63ae09a2_4a67_3eaf_7888_b0fd11776a0e
  f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> f3bc7443_c889_119d_0744_aacc3620d8d2
  552bc7bf_c1ac_965d_e157_ee750ab1993c["langchain_core.messages.tool"]
  80cebff4_efbd_4311_85e9_de0dc81a7eee --> 552bc7bf_c1ac_965d_e157_ee750ab1993c
  style 80cebff4_efbd_4311_85e9_de0dc81a7eee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Base classes and utilities for LangChain tools."""

from __future__ import annotations

import functools
import inspect
import json
import logging
import typing
import warnings
from abc import ABC, abstractmethod
from collections.abc import Callable  # noqa: TC003
from inspect import signature
from typing import (
    TYPE_CHECKING,
    Annotated,
    Any,
    Literal,
    TypeVar,
    cast,
    get_args,
    get_origin,
    get_type_hints,
)

import typing_extensions
from pydantic import (
    BaseModel,
    ConfigDict,
    Field,
    PydanticDeprecationWarning,
    SkipValidation,
    ValidationError,
    validate_arguments,
)
from pydantic.fields import FieldInfo
from pydantic.v1 import BaseModel as BaseModelV1
from pydantic.v1 import ValidationError as ValidationErrorV1
from pydantic.v1 import validate_arguments as validate_arguments_v1
from typing_extensions import override

from langchain_core.callbacks import (
    AsyncCallbackManager,
    CallbackManager,
    Callbacks,
)
from langchain_core.messages.tool import ToolCall, ToolMessage, ToolOutputMixin
from langchain_core.runnables import (
    RunnableConfig,
    RunnableSerializable,
    ensure_config,
    patch_config,
    run_in_executor,
)
from langchain_core.runnables.config import set_config_context
from langchain_core.runnables.utils import coro_with_context
from langchain_core.utils.function_calling import (
    _parse_google_docstring,
    _py_38_safe_origin,
)
// ... (1526 more lines)

Subdomains

Dependencies

  • abc
  • collections.abc
  • functools
  • inspect
  • json
  • langchain_core.callbacks
  • langchain_core.messages.tool
  • langchain_core.runnables
  • langchain_core.runnables.config
  • langchain_core.runnables.utils
  • langchain_core.utils.function_calling
  • langchain_core.utils.pydantic
  • logging
  • pydantic
  • pydantic.fields
  • pydantic.v1
  • typing
  • typing_extensions
  • uuid
  • warnings

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, ToolInterface subdomain.
What functions are defined in base.py?
base.py defines 24 function(s): _format_output, _function_annotations_are_pydantic_v1, _get_annotation_description, _get_filtered_args, _get_runnable_config_param, _get_type_hints, _handle_tool_error, _handle_validation_error, _infer_arg_descriptions, _is_annotated_type, and 14 more.
What does base.py depend on?
base.py imports 20 module(s): abc, collections.abc, functools, inspect, json, langchain_core.callbacks, langchain_core.messages.tool, langchain_core.runnables, and 12 more.
Where is base.py in the architecture?
base.py is located at libs/core/langchain_core/tools/base.py (domain: AgentOrchestration, subdomain: ToolInterface, directory: libs/core/langchain_core/tools).

Analyze Your Own Codebase

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

Try Supermodel Free