跳转至

Strict Schema

ensure_strict_json_schema

ensure_strict_json_schema(
    schema: dict[str, Any],
    *,
    _reject_open_objects: bool = False,
) -> dict[str, Any]

Mutates the given JSON schema to ensure it conforms to the strict standard that the OpenAI API expects.

Source code in .tmp/v0/src/agents/strict_schema.py
def ensure_strict_json_schema(
    schema: dict[str, Any],
    *,
    _reject_open_objects: bool = False,
) -> dict[str, Any]:
    """Mutates the given JSON schema to ensure it conforms to the `strict` standard
    that the OpenAI API expects.
    """
    normalized, root_error = _prepare_strict_json_schema(
        schema, reject_open_objects=_reject_open_objects
    )
    if root_error is not None:
        raise UserError(root_error)
    return normalized