primitives.md

Primitives (Questions)

The three TypeSafe question types (Choice, Score, Noul), the typed answers they return, how to choose between them, and how to ask several at once.

TypeSafe Example Code

export function TypesafeExample({example, display, title}) {
  const keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
  function compressToEncodedURIComponent(input) {
    if (input == null) return "";
    return _compress(input, 6, function (a) {
      return keyStrUriSafe.charAt(a);
    });
  }
  // ...additional code...
}

TypeSafe's primitives are the small, typed building blocks you compose in code. They come in pairs: a question defines one judgment for a System One model to make about a state, and its answer is the typed value that comes back. You compose the answers in your code to make decisions. There are three question types, each returning a different shape of answer.

Type What it answers Returns
Choice Which of these options? choice, probabilities, confidence
Score Which level? score, legend, probabilities, confidence
Noul Is this true? noul (0 to 1)

Ask for One Snap Judgment Per Question

System One models are built for fast, focused judgments. Ask for a judgment a knowledgeable person makes in a second given the right context.

Define a Question

Every question has an ID, a type, and instructions. Choice and Score questions also take criteria, which define the options for a Choice question or the levels for a Score. Noul questions accept criteria as an optional clarification of what yes and no mean.

Example question:

ticket_message = "I was charged twice for order A-104. Please refund the duplicate."
questions = {
    "refund_requested": Noul(
        instructions="Does the customer request a refund?",
    ),
}

Choose a Question Type

What Comes Back

Answers are typed values that your code can utilize in further logic:

Type Answer fields How to read it
Choice choice, probabilities, confidence The selected option, distribution across every option, and summarized confidence.
Score score, legend, probabilities, confidence The position along your levels and the distribution across levels.
Noul noul The probability that the answer is yes.

Next Steps

Explore further patterns using these question types to enhance your application.