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

_transform.py — anthropic-sdk-python Source File

Architecture documentation for _transform.py, a python file in the anthropic-sdk-python codebase. 5 imports, 0 dependents.

File python AnthropicClient SyncAPI 5 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  69ef29cd_4eb8_35c9_a323_d7cf936be862["_transform.py"]
  03a8caae_8ccd_6ded_a4e0_ac627a444e7d["_utils"]
  69ef29cd_4eb8_35c9_a323_d7cf936be862 --> 03a8caae_8ccd_6ded_a4e0_ac627a444e7d
  506d0594_2a0d_4f14_1041_ed428dcfcac8["inspect"]
  69ef29cd_4eb8_35c9_a323_d7cf936be862 --> 506d0594_2a0d_4f14_1041_ed428dcfcac8
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  69ef29cd_4eb8_35c9_a323_d7cf936be862 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  69ef29cd_4eb8_35c9_a323_d7cf936be862 --> 37c05070_ca59_d596_7250_de9d1939227f
  21de8837_7dae_989e_fdbb_1415c0770d90["pydantic"]
  69ef29cd_4eb8_35c9_a323_d7cf936be862 --> 21de8837_7dae_989e_fdbb_1415c0770d90
  style 69ef29cd_4eb8_35c9_a323_d7cf936be862 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import inspect
from typing import Any, Literal, Optional, cast
from typing_extensions import assert_never

import pydantic

from ..._utils import is_list

SupportedTypes = Literal[
    "object",
    "array",
    "string",
    "integer",
    "number",
    "boolean",
    "null",
]

SupportedStringFormats = {
    "date-time",
    "time",
    "date",
    "duration",
    "email",
    "hostname",
    "uri",
    "ipv4",
    "ipv6",
    "uuid",
}


def get_transformed_string(
    schema: dict[str, Any],
) -> dict[str, Any]:
    """Transforms a JSON schema of type string to ensure it conforms to the API's expectations.

    Specifically, it ensures that if the schema is of type "string" and does not already
    specify a "format", it sets the format to "text".

    Args:
        schema: The original JSON schema.

    Returns:
        The transformed JSON schema.
    """
    if schema.get("type") == "string" and "format" not in schema:
        schema["format"] = "text"
    return schema


def transform_schema(
    json_schema: type[pydantic.BaseModel] | dict[str, Any],
) -> dict[str, Any]:
    """
    Transforms a JSON schema to ensure it conforms to the API's expectations.

    Args:
// ... (108 more lines)

Subdomains

Dependencies

  • _utils
  • inspect
  • pydantic
  • typing
  • typing_extensions

Frequently Asked Questions

What does _transform.py do?
_transform.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in _transform.py?
_transform.py defines 2 function(s): get_transformed_string, transform_schema.
What does _transform.py depend on?
_transform.py imports 5 module(s): _utils, inspect, pydantic, typing, typing_extensions.
Where is _transform.py in the architecture?
_transform.py is located at src/anthropic/lib/_parse/_transform.py (domain: AnthropicClient, subdomain: SyncAPI, directory: src/anthropic/lib/_parse).

Analyze Your Own Codebase

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

Try Supermodel Free