{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://decisionmodelprotocol.io/schema/response.json",
  "title": "DMP Draft 0.1 response",
  "type": "object",
  "required": ["model", "answers"],
  "properties": {
    "model": { "type": "string", "minLength": 1 },
    "answers": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "oneOf": [
          { "$ref": "#/$defs/choice" },
          { "$ref": "#/$defs/score" },
          { "$ref": "#/$defs/noul" }
        ]
      }
    },
    "usage": {
      "type": "object",
      "required": ["input_tokens", "output_tokens"],
      "properties": {
        "input_tokens": { "type": "integer", "minimum": 0 },
        "output_tokens": { "type": "integer", "minimum": 0 }
      }
    }
  },
  "$defs": {
    "probability": { "type": "number", "minimum": 0, "maximum": 1 },
    "distribution": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": { "$ref": "#/$defs/probability" }
    },
    "choice": {
      "type": "object",
      "required": ["type", "choice", "probabilities", "confidence"],
      "properties": {
        "type": { "const": "choice" },
        "choice": { "type": "string" },
        "probabilities": { "$ref": "#/$defs/distribution" },
        "confidence": { "$ref": "#/$defs/probability" }
      }
    },
    "score": {
      "type": "object",
      "required": ["type", "score", "legend", "probabilities", "confidence"],
      "properties": {
        "type": { "const": "score" },
        "score": { "type": "number", "minimum": 0 },
        "legend": { "type": "object", "minProperties": 2, "propertyNames": { "pattern": "^(0|[1-9][0-9]*)$" }, "additionalProperties": { "type": "string" } },
        "probabilities": { "allOf": [{ "$ref": "#/$defs/distribution" }], "type": "object", "minProperties": 2, "propertyNames": { "pattern": "^(0|[1-9][0-9]*)$" } },
        "confidence": { "$ref": "#/$defs/probability" }
      }
    },
    "noul": {
      "type": "object",
      "required": ["type", "noul"],
      "properties": {
        "type": { "const": "noul" },
        "noul": { "$ref": "#/$defs/probability" }
      }
    }
  }
}
