Drex

Ask questions

nace decide --state "I was charged twice for my March invoice." \
  --noul "wants_refund=Is the customer asking for a refund?" \
  --choice "topic=billing,shipping,other: Which topic is it?" \
  --score "urgency=low,medium,high: How urgent is it?"

Stdout gets one line per answer, and stderr gets the model, the input tokens, the model's time and the request_id:

wants_refund  noul    0.930
topic         choice  billing (confidence 0.880)
urgency       score   1.400 on low < medium < high (confidence 0.500)
drex-v2.0 · 61 input tokens · 143 ms · req_...
FlagWhat it does
--state STATEThe state: text, @FILE, or - for stdin. Text that starts with { or [ and parses as JSON is sent as JSON; anything else as a string. Required unless --body has one.
--noul NAME=INSTRUCTIONSA yes/no question. Repeatable.
--choice NAME=A,B,C[: INSTRUCTIONS]A pick-one question: labels before the first colon, separated by commas, then instructions. Repeatable.
--score NAME=LOW,...,HIGH[: INSTRUCTIONS]An ordered-levels question, levels from low to high. Repeatable.
--questions JSONA questions object, name to question: inline JSON, @FILE, a path, or -.
--body JSONA whole request body: inline JSON, @FILE, a path, or -.
--image IMAGEAn image for Drex Max: a local PNG, JPEG or WebP file, or ws:<workspace_id>/<file_id> for a file you already uploaded (ids, not a path). Repeatable, up to 8. See Images.
-m, --model MODELThe model id. Default: --body's model, else drex-max with --image, else $NACE_DEFAULT_DECISION_MODEL, else drex-latest. See nace models.
--jsonPrint the response body as Drex sent it, request_id included, instead of the lines above.

At least one question is required. Questions merge by name: --body's questions first, then --questions, then each shorthand flag, so a later question replaces an earlier one with the same name. --state and -m replace --body's state and model, and --image replaces its images; its other fields are sent as given.

The shorthand labels can't contain , or : and carry no descriptions. For label descriptions or noul criteria, use --questions:

questions.json
{
  "wants_refund": {
    "type": "noul",
    "instructions": "Is the customer asking for a refund?",
    "criteria": { "true": "The customer asks for money back", "false": "Anything else" }
  },
  "topic": {
    "type": "choice",
    "instructions": "Which topic is it?",
    "criteria": { "billing": "Payments, invoices or charges", "shipping": "Delivery and tracking", "other": null }
  }
}
nace decide --state @ticket.txt --questions questions.json --json

See Questions for what each type accepts and Reading answers for the response.

Images

The served Drex Max models read images. Use nace models with the same API key and base URL to check availability. Retired ids that resolve to Max v1.1 accept images too. Pass each with --image, in the order the state and questions refer to them as "Image 1", "Image 2" and so on:

nace decide --image receipt.jpg --image logo.png \
  --state "Image 1 is a scanned receipt. Image 2 is the shop's logo." \
  --noul "same_shop=Was the receipt in Image 1 issued by the shop whose logo is Image 2?"

A local file of 256 KiB or less is sent inline, base64 in the request body. A larger one is first uploaded under drex-max-images/, named by its content so the same image isn't stored twice, and sent as a file reference; stderr says uploaded ws:<workspace_id>/<file_id>, which you can pass to --image next time. ws:<workspace_id>/<file_id> names a file you already uploaded by its ids, such as the source nace upload prints (without --workspace); a file in one of your Workspaces returns 422. Anything that isn't a PNG, JPEG or WebP file, or more than 8 images, is refused before anything is uploaded or sent.

With --image and no model named, nace decide sends the original Max id, which resolves to Max v1.1. Pass -m with a served model id from Models to select it explicitly. Models that do not support images return 422. Images are at most 16 MiB each and 32 MiB in all. Their tokens are already in the input tokens, and stderr shows them too:

drex-max-v1.1 · 1873 input tokens (1536 image) · 2210 ms · req_...

On this page