Light Logo
CLI (v0.57.8)Reference

wriftai predictions create

CLI reference for wriftai predictions create

wriftai predictions create

Create a prediction

Synopsis

Create a prediction using either the latest version of a model or a specific model version.

Input data is provided with --input, in one of these forms:

  • String value: --input key=value (sets key to a string)
  • JSON value: --input key:=json (sets key to a number, boolean, array or object)
  • File input: --input key@path (sets key to a local file, which is uploaded)
  • Raw JSON: --input followed by a JSON object as a single-quoted string
  • JSON from file: --input @path/to/input.json (reads the whole input from a JSON file)
  • JSON from stdin: --input @- (reads the whole input as JSON from stdin)

The key forms (=, :=, @) can be repeated and mixed with each other, but not with raw JSON, a JSON file or stdin. A leading @ on the whole value always means JSON from file or stdin, so give file inputs as key@path or as an unquoted @path inside JSON.

File inputs:

  • Top level: use key@path, as in --input audio@meeting.wav. The path is taken as is.
  • Inside JSON (lists, objects, key:=, raw JSON, a JSON file or stdin): write an unquoted @path, as in --input clips:='[@a.wav, @b.wav]'.

Files are uploaded automatically and concurrently before the prediction is created. A file that appears in several places in the input is uploaded once.

In JSON, a quoted "@path" is just a string, and paths containing spaces or , ] } must be quoted as @"my file.wav". Append ;type=MIMETYPE to override the detected mime type, as in 'audio@a.bin;type=audio/wav'. Relative paths resolve against the current directory, and a leading ~ stands for your home directory.

wriftai predictions create [flags]

Examples

  Create a prediction against the latest version of a model
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello

  Create a prediction against a specific model version
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer:1 \
    --input text=hello

  Create a prediction using raw JSON input
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input '{"text": "hello"}'

  Create a prediction using a JSON file as input
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input @input.json

  Create a prediction using JSON from stdin
  $ echo '{"text":"hello"}' | wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input @-

  Create a prediction using multiple key=value pairs (string values)
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --input language=en

  Create a prediction using key=value pairs with typed/raw JSON values
  (numbers, booleans, arrays, and objects)
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --input threshold:=0.8 \
    --input tags:='["a","b"]'

  Create a prediction with a file input
  $ wriftai predictions create \
    --model pyannote/speaker-diarization-community-1 \
    --input audio@meeting.wav \
    --input num_speakers:=2

  Create a prediction with a list of files
  $ wriftai predictions create \
    --model johndoe/some-model \
    --input clips:='[@a.wav, @b.wav]'

  Create a prediction with a file nested in an object, mixed with other values
  $ wriftai predictions create \
    --model johndoe/some-model \
    --input config:='{"reference": @ref.wav, "num_speakers": 2, "label": "@not-a-file"}'

  Create a prediction with a file input and a mime type override
  $ wriftai predictions create \
    --model johndoe/some-model \
    --input 'audio@recording.bin;type=audio/wav'

  Create a prediction with a file path that contains spaces or special characters
  $ wriftai predictions create \
    --model johndoe/some-model \
    --input 'audio@my recording.wav' \
    --input clips:='[@"my clip.wav", @"take 2;final.wav"]'

  Create a prediction using raw JSON that includes a file
  $ wriftai predictions create \
    --model johndoe/some-model \
    --input '{"audio": @meeting.wav, "language": "en"}'

  Create a prediction with input validation enabled against model version's schema before processing
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --validate-input

  Create a prediction and send updates to the specified webhook
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input 'text=Good Job' \
    --webhook-url https://example.com/webhook \
    --webhook-secret a7b6e3f1a9d8c4b2

  Create a prediction and wait until it reaches a terminal state, polling if it isn't finished after the server's wait
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --wait

  Create a prediction and wait, polling at a custom interval once the server's wait ends
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --wait \
    --wait-poll-interval 3s

  Create a prediction and wait, with the server holding the request open for a custom duration before polling starts
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --wait \
    --wait-duration 30s

  Create a prediction and wait without polling, returning as soon as the server's wait ends
  $ wriftai predictions create \
    --model johndoe/sentiment-analyzer \
    --input text=hello \
    --wait \
    --wait-no-poll

Options

  -h, --help                          help for create
      --input stringArray             Input data for prediction (required). Supports raw JSON (e.g. '{"text":"hi"}'), a JSON file or stdin (e.g. @input.json or @-), or repeatable key=value pairs with key:=value for JSON values such as numbers, booleans, arrays, or objects, and key@path for file inputs. Repeatable keys are allowed; if a key is repeated, the last value wins.
      --model string                  Model reference in either owner/name or owner/name:version-number format (required)
  -o, --output format                 Set output format. Supported formats: json, yaml (default json)
      --validate-input                Enable input validation against the schema before processing
      --wait                          If set, waits for the prediction to finish: the server holds the request open for its wait time, and if the prediction isn't finished by then, polling continues until it reaches a terminal state. Otherwise the prediction is returned immediately
      --wait-duration duration        Maximum time the server holds the initial request open while waiting for the prediction to finish, before polling starts. If 0, the server's default is used. Ignored unless --wait is set.
      --wait-no-poll                  Return the prediction as is when the server's wait ends instead of polling. The prediction may not be in a terminal state. Ignored unless --wait is set.
      --wait-poll-interval duration   Time between polling attempts to check the prediction status. Only applies while polling, not to the server's initial wait. Ignored unless --wait is set. (default 1s)
      --webhook-secret string         Secret to generate the signature for the webhook
      --webhook-url string            HTTP URL to POST updates to

Options inherited from parent commands

      --debug   Enable debug mode

SEE ALSO