{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/processor/onnx-genai",
  "title" : "Onnx-genai Processor Configuration",
  "description" : "Runs ONNX model inference using Generative AI extensions for onnxruntime. See the official\n[github repo](https://github.com/microsoft/onnxruntime-genai) for more information.\n\nThis processor can either use an existing model reference defined in `resources` section or create\n a new model instance using the provided URI.\n\nIt supports various hugging-face style configuration options for model generation parameters, chat formatting, and caching.\n\n## Models\n\nSupported model architectures as of onnx-genai-0.8.3 release are: AMD OLMo, ChatGLM, DeepSeek, ERNIE 4.5,\nGemma, Granite, Llama (and derivatives), Mistral (and derivatives), Nemotron, Phi (language + vision), Qwen\n\n## Downloads\n\nThe `modelUri` can point to a location on local-disk (using `file://` scheme) or on a remote storage.\nRemote storage support depends on available plugins, e.g., S3 plugin allows downloads from an S3-compatible bucket.\n\n## Files\n\nThe `modelUri` should point to a location containing the following files:\n— genai_config.json\n— model.onnx\n— model.onnx.data\n— tokenizer.json\n— tokenizer_config.json\n",
  "type" : "object",
  "properties" : {
    "onnx-genai" : {
      "type" : "object",
      "properties" : {
        "modelResource" : {
          "description" : "Reference to an existing ONNX GenAI model resource. If specified, modelUri is ignored.",
          "anyOf" : [ {
            "type" : "string"
          }, {
            "$ref" : "resource-onnx-genai.schema.json#/properties/onnx-genai"
          } ]
        },
        "modelUri" : {
          "type" : "string",
          "format" : "uri",
          "description" : "URI to the directory containing the model files. Required if modelResource is not specified."
        },
        "printDownloadProgress" : {
          "type" : "boolean",
          "description" : "Whether to display progress information during model file downloads.",
          "default" : "false"
        },
        "chatTemplate" : {
          "type" : "string",
          "description" : "Template for formatting chat input. The {input} placeholder will be replaced with the actual input text.",
          "default" : "<|user|>\n{input} <|end|>\n<|assistant|>"
        },
        "streamResponse" : {
          "type" : "boolean",
          "description" : "Whether to stream the model's response token by token as individual events (true) or return the complete response at once (false).",
          "default" : "false"
        },
        "cache" : {
          "type" : "object",
          "description" : "This configuration controls how model files are cached locally, including the cache location,\nsize limits, expiration policy, and cleanup behavior. If not provided files will be cached in the /tmp directory.\n",
          "properties" : {
            "directory" : {
              "type" : "string",
              "description" : "Directory where files will be cached. If not specified, a temporary directory will be created."
            },
            "maxCacheSize" : {
              "type" : "integer",
              "description" : "Maximum size of the cache in bytes. Files will be evicted when the cache exceeds this size. Use 0 for unlimited.",
              "default" : "0",
              "minimum" : -9223372036854775808,
              "maximum" : 9223372036854775807
            },
            "expirationTime" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Duration after which cached files are considered stale and will not be used by the system."
            },
            "cleanupOnStart" : {
              "type" : "boolean",
              "description" : "Whether to clean up expired or invalid cache entries when the cache is initialized.",
              "default" : "false"
            }
          },
          "additionalProperties" : false
        },
        "properties" : {
          "type" : "object",
          "description" : "Model-specific generation parameters as key-value pairs. Supported value types are numbers and booleans.\nCommon parameters include max_length, temperature, top_p, etc.",
          "additionalProperties" : {
            "type" : "string"
          }
        },
        "promptExtractor" : {
          "type" : "string",
          "description" : "Transforms the incoming input event into the raw prompt text passed to the model. The\nreturned string is then plugged into `chatTemplate` (replacing `{input}`) before generation."
        },
        "computeFunction" : {
          "type" : "string",
          "description" : "Computes the result event emitted to the next operator from the original input and a\nsingle chunk of generated text. When `streamResponse` is true this is invoked once per\ntoken (plus once with a trailing newline); otherwise it is invoked once with the full\ngenerated response."
        }
      },
      "required" : [ "promptExtractor", "computeFunction" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "onnx-genai" ],
  "additionalProperties" : false
}
