Normandy.LLM.StructuredOutputs (normandy v2.2.0)

View Source

Decides whether a request should use Anthropic structured outputs. Enabled by default; disable globally via config :normandy, :structured_outputs, false or per client via client.options[:structured_outputs]. A schema that the JSON Schema translator cannot express falls back (:skip).

Summary

Functions

Returns whether client uses structured outputs.

Returns {:ok, schema}, the translated JSON Schema of response_model, or :skip.

Functions

enabled?(client)

@spec enabled?(struct()) :: boolean()

Returns whether client uses structured outputs.

The client's options[:structured_outputs] wins when it is not nil; otherwise config :normandy, :structured_outputs decides, true by default.

schema_for(client, response_model)

@spec schema_for(
  struct(),
  term()
) :: {:ok, map()} | :skip

Returns {:ok, schema}, the translated JSON Schema of response_model, or :skip.

:skip when structured outputs are off for client, when response_model is not a struct of a module with get_json_schema/0, or when the JSON Schema translator cannot express its specification. The caller then uses the legacy parse-and-retry path.