System One Codec
Reads and writes the System One wire format, the JSON protocol for asking a decision model several typed questions about one piece of state in a single request.
A request is {"state", "model", "questions"}. Questions are keyed q1 to qN in spec order, replacing application question names in the JSON sent to the model endpoint. The input and question instructions are still sent. A proposition goes out as a noul question, a choice as a choice question with its options as criteria, and a rating as a score question with its level descriptions as an ordered criteria list.
A response is {"model", "answers", "usage"}. The envelope is read strictly: anything that is not one JSON object with a non-empty answers object, a repeated member, or trailing content throws SystemOneFormatException and fails the whole request. Each answer is then read on its own, so one bad answer fails only its question. Members this codec doesn't know are ignored, so a newer model can add fields. The evidence rules for each answer type are in SystemOneAnswers.
Properties
Functions
Reads a response body into a decision response for the spec that was asked.
Writes the request body for one decision request with no model in it, for a host that names the model outside the System One request.
Writes the request body for one decision request.
Reads the model names from a model listing. It reads the System One shape, {"models": [{"name", ...}]}, and the OpenAI shape that Ollama serves, {"data": [{"id", ...}]}.