ai.internal._schema_for_signature

(internal) One JSON Schema object for a function's parameters, derived from the signature: every parameter typed via baml.json.schema, under the aliased names `baml.sap.coerce` reads the arguments by (`ai.tools._typed_arguments`).

Reference version

Signature

function ai.internal._schema_for_signature(
handler: reflect.AnyFunction<Returns = unknown, Throws = unknown>
) -> map<string, unknown> throws baml.errors.Unsupported | baml.json.DecodeError

(internal) One JSON Schema object for a function's parameters, derived from the signature: every parameter typed via baml.json.schema, under the aliased names baml.sap.coerce reads the arguments by (ai.tools._typed_arguments).

An unknown parameter receives its argument as the model sent it, which is parsed JSON (ai.tools._typed_arguments), so its schema is that of baml.json.json. baml.json.schema rejects unknown itself: everywhere else, unknown holds values no schema describes.

baml.json.schema puts the classes and aliases a type reaches in $defs at the root of the schema it returns, and its $refs point there (#/$defs/Name). A parameter's schema is a property of this object, so its $defs move to this object's root, where those $refs resolve. A parameter scopes its definitions and references, because distinct types reached by different parameters can have the same display name.

Source:<builtin>/ai/ns_internal/helpers.bamlbytes 1047–2285