Home / File/ _beta_functions.py — anthropic-sdk-python Source File

_beta_functions.py — anthropic-sdk-python Source File

Architecture documentation for _beta_functions.py, a python file in the anthropic-sdk-python codebase. 18 imports, 3 dependents.

File python ExtensibilityTools ToolRunner 18 imports 3 dependents 2 functions 6 classes

Entity Profile

Dependency Diagram

graph LR
  2f4a4b61_2541_5c7b_c70e_93f4b752f987["_beta_functions.py"]
  4f9e2f95_28e3_ba09_0d52_30049bacab26["4f9e2f95:28e3:ba09:0d52:30049bacab26"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 4f9e2f95_28e3_ba09_0d52_30049bacab26
  08dfe5f2_3d50_6472_c8d8_ddc0407d1229["_utils"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 08dfe5f2_3d50_6472_c8d8_ddc0407d1229
  debfbc0a_c9c6_5ffb_f51e_46c4f4845a05["_compat"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> debfbc0a_c9c6_5ffb_f51e_46c4f4845a05
  181147dc_44bb_d809_7c9c_46aedfe56891["_models"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 181147dc_44bb_d809_7c9c_46aedfe56891
  a7a22ac1_2fc9_eecb_0faf_2daedac42d29["types.beta"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> a7a22ac1_2fc9_eecb_0faf_2daedac42d29
  1f0c8d32_0836_c283_70fb_33f78ca9cc5c["_utils._utils"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 1f0c8d32_0836_c283_70fb_33f78ca9cc5c
  9571d71e_ea1f_7b6e_342f_941f1b36f5c5["types.tool_param"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 9571d71e_ea1f_7b6e_342f_941f1b36f5c5
  bf95f492_9e39_85c6_d89b_f710d0271de7["types.beta.beta_tool_result_block_param"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> bf95f492_9e39_85c6_d89b_f710d0271de7
  33e7b7bd_cc48_e59c_0e93_20dce57f27ca["logging"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 33e7b7bd_cc48_e59c_0e93_20dce57f27ca
  90b87fb1_b7c6_6103_fd94_a71d362551d6["abc"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 90b87fb1_b7c6_6103_fd94_a71d362551d6
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  506d0594_2a0d_4f14_1041_ed428dcfcac8["inspect"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 506d0594_2a0d_4f14_1041_ed428dcfcac8
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 37c05070_ca59_d596_7250_de9d1939227f
  21de8837_7dae_989e_fdbb_1415c0770d90["pydantic"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987 --> 21de8837_7dae_989e_fdbb_1415c0770d90
  style 2f4a4b61_2541_5c7b_c70e_93f4b752f987 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import logging
from abc import ABC, abstractmethod
from typing import Any, Union, Generic, TypeVar, Callable, Iterable, Coroutine, cast, overload
from inspect import iscoroutinefunction
from typing_extensions import TypeAlias, override

import pydantic
import docstring_parser
from pydantic import BaseModel

from ... import _compat
from ..._utils import is_dict
from ..._compat import cached_property
from ..._models import TypeAdapter
from ...types.beta import BetaToolParam, BetaToolUnionParam
from ..._utils._utils import CallableT
from ...types.tool_param import InputSchema
from ...types.beta.beta_tool_result_block_param import Content as BetaContent

log = logging.getLogger(__name__)

BetaFunctionToolResultType: TypeAlias = Union[str, Iterable[BetaContent]]

Function = Callable[..., BetaFunctionToolResultType]
FunctionT = TypeVar("FunctionT", bound=Function)

AsyncFunction = Callable[..., Coroutine[Any, Any, BetaFunctionToolResultType]]
AsyncFunctionT = TypeVar("AsyncFunctionT", bound=AsyncFunction)


class BetaBuiltinFunctionTool(ABC):
    @abstractmethod
    def to_dict(self) -> BetaToolUnionParam: ...

    @abstractmethod
    def call(self, input: object) -> BetaFunctionToolResultType: ...

    @property
    def name(self) -> str:
        raw = self.to_dict()
        if "mcp_server_name" in raw:
            return raw["mcp_server_name"]
        return raw["name"]


class BetaAsyncBuiltinFunctionTool(ABC):
    @abstractmethod
    def to_dict(self) -> BetaToolUnionParam: ...

    @abstractmethod
    async def call(self, input: object) -> BetaFunctionToolResultType: ...

    @property
    def name(self) -> str:
        raw = self.to_dict()
        if "mcp_server_name" in raw:
            return raw["mcp_server_name"]
        return raw["name"]
// ... (282 more lines)

Subdomains

Dependencies

  • 4f9e2f95:28e3:ba09:0d52:30049bacab26
  • _compat
  • _models
  • _utils
  • _utils._utils
  • abc
  • docstring_parser
  • inspect
  • logging
  • pydantic
  • pydantic.json_schema
  • pydantic_core
  • pydantic_core.core_schema
  • types.beta
  • types.beta.beta_tool_result_block_param
  • types.tool_param
  • typing
  • typing_extensions

Frequently Asked Questions

What does _beta_functions.py do?
_beta_functions.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the ExtensibilityTools domain, ToolRunner subdomain.
What functions are defined in _beta_functions.py?
_beta_functions.py defines 2 function(s): beta_async_tool, beta_tool.
What does _beta_functions.py depend on?
_beta_functions.py imports 18 module(s): 4f9e2f95:28e3:ba09:0d52:30049bacab26, _compat, _models, _utils, _utils._utils, abc, docstring_parser, inspect, and 10 more.
What files import _beta_functions.py?
_beta_functions.py is imported by 3 file(s): __init__.py, _beta_builtin_memory_tool.py, _beta_runner.py.
Where is _beta_functions.py in the architecture?
_beta_functions.py is located at src/anthropic/lib/tools/_beta_functions.py (domain: ExtensibilityTools, subdomain: ToolRunner, directory: src/anthropic/lib/tools).

Analyze Your Own Codebase

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

Try Supermodel Free