ExTypesafe.Question (ExTypesafe v0.1.0)

Copy Markdown View Source

Typed question structs for the TypeSafe API.

TypeSafe supports three question primitives that can be mixed freely in a single request:

Example

questions = %{
  is_urgent: ExTypesafe.Question.noul("Does this convey urgency?"),
  department: ExTypesafe.Question.choice(
    "Which team should handle this?",
    %{billing: "Payments, invoicing, refunds", technical: "Bugs, outages, integrations"}
  ),
  frustration: ExTypesafe.Question.score(
    "How frustrated is the customer?",
    ["Calm", "Frustrated", "Very angry"]
  )
}

Summary

Functions

Builds a Choice question.

Builds a Noul question (yes/no).

Builds a Score question.

Types

instructions()

@type instructions() :: String.t() | map()

t()

Functions

choice(instructions, criteria)

Builds a Choice question.

Parameters

  • instructions — What the model should decide. Can be a string or a structured map.
  • criteria — Map of option name to rubric description. Use nil value for options needing no description.

Examples

iex> ExTypesafe.Question.choice("Which team should handle this?", %{
...>   billing: "Payments, invoicing, refunds",
...>   technical: "Bugs, outages, integrations"
...> })
%ExTypesafe.Question.Choice{type: "choice", instructions: "Which team should handle this?", criteria: %{billing: "Payments, invoicing, refunds", technical: "Bugs, outages, integrations"}}

noul(instructions, criteria \\ nil)

@spec noul(instructions(), map() | nil) :: ExTypesafe.Question.Noul.t()

Builds a Noul question (yes/no).

Parameters

  • instructions — The yes/no question to evaluate. Can be a string or a structured map.
  • criteria — Optional map with :true and/or :false keys describing what each means.

Examples

iex> ExTypesafe.Question.noul("Does this convey urgency?")
%ExTypesafe.Question.Noul{type: "noul", instructions: "Does this convey urgency?", criteria: nil}

iex> ExTypesafe.Question.noul("Is this spam?", %{true: "Clearly promotional", false: "Legitimate message"})
%ExTypesafe.Question.Noul{type: "noul", instructions: "Is this spam?", criteria: %{true: "Clearly promotional", false: "Legitimate message"}}

score(instructions, criteria)

Builds a Score question.

Parameters

  • instructions — What the model should rate. Can be a string or a structured map.
  • criteria — Ordered list of level descriptions (2–10 levels, low to high).

Examples

iex> ExTypesafe.Question.score("How frustrated is the customer?", ["Calm", "Frustrated", "Very angry"])
%ExTypesafe.Question.Score{type: "score", instructions: "How frustrated is the customer?", criteria: ["Calm", "Frustrated", "Very angry"]}