Home / Class/ CustomGenerateJsonSchema Class — anthropic-sdk-python Architecture

CustomGenerateJsonSchema Class — anthropic-sdk-python Architecture

Architecture documentation for the CustomGenerateJsonSchema class in _beta_functions.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  22620cc2_c27b_9b73_6ad4_3b2887ce2a27["CustomGenerateJsonSchema"]
  2f4a4b61_2541_5c7b_c70e_93f4b752f987["_beta_functions.py"]
  22620cc2_c27b_9b73_6ad4_3b2887ce2a27 -->|defined in| 2f4a4b61_2541_5c7b_c70e_93f4b752f987
  1c6fe472_4b7b_5012_c462_edce183a6931["__init__()"]
  22620cc2_c27b_9b73_6ad4_3b2887ce2a27 -->|method| 1c6fe472_4b7b_5012_c462_edce183a6931
  b029e0aa_29cd_b3cc_b391_c36f72aea53b["__call__()"]
  22620cc2_c27b_9b73_6ad4_3b2887ce2a27 -->|method| b029e0aa_29cd_b3cc_b391_c36f72aea53b
  a4ecbe26_788b_b335_0183_047d4c54bf71["kw_arguments_schema()"]
  22620cc2_c27b_9b73_6ad4_3b2887ce2a27 -->|method| a4ecbe26_788b_b335_0183_047d4c54bf71

Relationship Graph

Source Code

src/anthropic/lib/tools/_beta_functions.py lines 135–167

        class CustomGenerateJsonSchema(GenerateJsonSchema):
            def __init__(self, *, func: Callable[..., Any], parsed_docstring: Any) -> None:
                super().__init__()
                self._func = func
                self._parsed_docstring = parsed_docstring

            def __call__(self, *_args: Any, **_kwds: Any) -> "CustomGenerateJsonSchema":  # noqa: ARG002
                return self

            @override
            def kw_arguments_schema(
                self,
                arguments: "list[ArgumentsParameter]",
                var_kwargs_schema: CoreSchema | None,
            ) -> JsonSchemaValue:
                schema = super().kw_arguments_schema(arguments, var_kwargs_schema)
                if schema.get("type") != "object":
                    return schema

                properties = schema.get("properties")
                if not properties or not is_dict(properties):
                    return schema

                # Add parameter descriptions from docstring
                for param in self._parsed_docstring.params:
                    prop_schema = properties.get(param.arg_name)
                    if not prop_schema or not is_dict(prop_schema):
                        continue

                    if param.description and "description" not in prop_schema:
                        prop_schema["description"] = param.description

                return schema

Frequently Asked Questions

What is the CustomGenerateJsonSchema class?
CustomGenerateJsonSchema is a class in the anthropic-sdk-python codebase, defined in src/anthropic/lib/tools/_beta_functions.py.
Where is CustomGenerateJsonSchema defined?
CustomGenerateJsonSchema is defined in src/anthropic/lib/tools/_beta_functions.py at line 135.

Analyze Your Own Codebase

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

Try Supermodel Free