Schemas

Schema nodes describe structured LM output.

class autoform.Str(*, min=None, max=None, pattern=None)[source]

String schema node with optional length and pattern constraints.

Use this node in schema trees passed to autoform.lm_schema_call().

Parameters:
  • min (int | None) – Optional minimum length of the string.

  • max (int | None) – Optional maximum length of the string.

  • pattern (str | None) – Optional regular expression pattern that the string must match.

Example

>>> import autoform as af
>>> name = af.Str(min=1, max=80, pattern=r"^[A-Za-z ]+$")
class autoform.Int(*, min=None, max=None)[source]

Integer schema node with optional range constraints.

Use this node in schema trees passed to autoform.lm_schema_call().

Parameters:
  • min (int | None) – Optional minimum value.

  • max (int | None) – Optional maximum value.

Example

>>> import autoform as af
>>> count = af.Int(min=0, max=10)
class autoform.Float(*, min=None, max=None)[source]

Number schema node with optional range constraints.

Use this node in schema trees passed to autoform.lm_schema_call().

Parameters:
  • min (int | float | None) – Optional minimum value.

  • max (int | float | None) – Optional maximum value.

Example

>>> import autoform as af
>>> score = af.Float(min=0, max=1)
class autoform.Bool[source]

Boolean schema node.

Use this node in schema trees passed to autoform.lm_schema_call().

Example

>>> import autoform as af
>>> ok = af.Bool()
class autoform.Enum(*values)[source]

Enum schema node with a fixed set of allowed values.

Use this node in schema trees passed to autoform.lm_schema_call().

Parameters:

*values (Any) – Allowed values. Values must be non-empty, share one type, and be JSON scalar values.

Example

>>> import autoform as af
>>> kind = af.Enum("summary", "definition")
class autoform.Doc(text, /)[source]

Description node for attaching JSON Schema descriptions.

Use this node in schema trees passed to autoform.lm_schema_call().

Parameters:

text (str) – Description text.

Example

>>> import autoform as af
>>> name = af.Str() @ af.Doc("Subject name.")