TypeSafe.Question.Choice (TypeSafe AI v0.1.0-alpha.1)

Copy Markdown View Source

Pick one option from a set you define.

TypeSafe.choice("Which team should handle this?",
  billing: "Payments, invoicing, refunds",
  technical: "Bugs, outages, integrations",
  sales: nil
)

Criteria are stored as an ordered list of {key, description} pairs, not a map. The order is what the model sees, and Elixir maps stop preserving insertion order past 32 keys while a Choice allows up to 255 options. Keys may be atoms or strings; the answer comes back under the same kind. A nil description means the option name speaks for itself. A Choice needs at least two options (one option is not a choice) and the API allows at most 255; give it the full list rather than a shortlist, and add an other option when the list might not cover every input.

Summary

Functions

Builds a Choice question from a keyword list, map, or list of pairs.

The type tag this question and its answer carry on the wire.

Types

option()

@type option() :: {TypeSafe.Keys.key(), TypeSafe.Question.description() | nil}

t()

@type t() :: %TypeSafe.Question.Choice{
  criteria: [option()],
  instructions: TypeSafe.Question.description()
}

Functions

new(instructions, criteria)

@spec new(TypeSafe.Question.description(), [option()] | map()) :: t()

Builds a Choice question from a keyword list, map, or list of pairs.

A map is accepted for convenience only while it can preserve order: Elixir maps keep insertion order up to 32 entries, so a map with more than 32 options raises ArgumentError. Pass a keyword list or a list of {key, description} pairs for larger option sets.

wire_type()

@spec wire_type() :: String.t()

The type tag this question and its answer carry on the wire.