Skip to content
SONOEDocs
EspañolESConsole

Choice

A Choice picks one option from a set you define. The answer is the most likely option, a probability for every option, and a confidence.

Request

type"choice"required
instructionsstring | object | arrayoptional

What to decide. If omitted, Sonoe asks which option fits best.

criteriamap<string, string | object | array | null>required

The options: each key is an option name you choose, each value a description of it (or null). Between 2 and 255 options.

{
  "model": "sonoe-latest",
  "state": "my package never arrived, where is it?",
  "questions": {
    "team": {
      "type": "choice",
      "instructions": "Which team should handle this?",
      "criteria": {
        "billing": "Payments, charges, refunds",
        "shipping": "Deliveries, packages and tracking",
        "technical": "Bugs, the app or the website",
        "other": "None of these"
      }
    }
  }
}

Answer

type"choice"required
choicestringrequired
The option with the highest probability, by the name you gave it.
probabilitiesmap<string, number>required
Every option and its probability. They add up to 1.
confidencenumberrequired
How sure Sonoe is, from 0 to 1. See Confidence.
{
  "model": "sonoe-1.1.0",
  "answers": {
    "team": {
      "type": "choice",
      "choice": "shipping",
      "probabilities": { "billing": 0.0052, "shipping": 0.9335, "technical": 0.0158, "other": 0.0454 },
      "confidence": 0.7853
    }
  },
  "usage": { "input_tokens": 149, "output_tokens": 0 }
}

How options are read

Each option is read on its own with the state and the question, and scored. The scores then become probabilities across the options. Two consequences:

  • Order doesn't matter. The first option has no advantage over the last.
  • Each option costs tokens. A Choice with 10 options reads the state and the question 10 times. Keep options to the ones that matter.

Tips

  • Describe every option. A short description ("shipping": "Deliveries, packages and tracking") is more accurate than null, especially when option names are codes or jargon.
  • Add a way out. If none of the options might fit, include one such as "other": "None of these". Otherwise Sonoe has to pick something.
  • Watch the confidence. With vague wording, the best option can still be wrong. In this example, "What does the customer need?" with options track_order, refund, change_address, other picked change_address for the same message, with a confidence of only 0.195: a clear signal not to act on it.
  • Keep option names stable. Your code switches on them; the descriptions are what you tune.