Home / Function/ __init__() — anthropic-sdk-python Function Reference

__init__() — anthropic-sdk-python Function Reference

Architecture documentation for the __init__() function in _beta_functions.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  d9fcf820_8cac_9db2_dcbc_d9b37c4e6ce0["__init__()"]
  001b1f9e_045c_b009_1c1f_58964c925505["BaseFunctionTool"]
  d9fcf820_8cac_9db2_dcbc_d9b37c4e6ce0 -->|defined in| 001b1f9e_045c_b009_1c1f_58964c925505
  e4ad5562_f752_5b4b_a011_4481b765ea4c["_get_description_from_docstring()"]
  d9fcf820_8cac_9db2_dcbc_d9b37c4e6ce0 -->|calls| e4ad5562_f752_5b4b_a011_4481b765ea4c
  3bf0e655_8383_b5ca_7c90_6b1d977bf9c8["_create_schema_from_function()"]
  d9fcf820_8cac_9db2_dcbc_d9b37c4e6ce0 -->|calls| 3bf0e655_8383_b5ca_7c90_6b1d977bf9c8
  style d9fcf820_8cac_9db2_dcbc_d9b37c4e6ce0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/lib/tools/_beta_functions.py lines 74–99

    def __init__(
        self,
        func: CallableT,
        *,
        name: str | None = None,
        description: str | None = None,
        input_schema: InputSchema | type[BaseModel] | None = None,
        defer_loading: bool | None = None,
    ) -> None:
        if _compat.PYDANTIC_V1:
            raise RuntimeError("Tool functions are only supported with Pydantic v2")

        self.func = func
        self._func_with_validate = pydantic.validate_call(func)
        self.name = name or func.__name__
        self._defer_loading = defer_loading

        self.description = description or self._get_description_from_docstring()

        if input_schema is not None:
            if isinstance(input_schema, type):
                self.input_schema: InputSchema = input_schema.model_json_schema()
            else:
                self.input_schema = input_schema
        else:
            self.input_schema = self._create_schema_from_function()

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/tools/_beta_functions.py.
Where is __init__() defined?
__init__() is defined in src/anthropic/lib/tools/_beta_functions.py at line 74.
What does __init__() call?
__init__() calls 2 function(s): _create_schema_from_function, _get_description_from_docstring.

Analyze Your Own Codebase

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

Try Supermodel Free