Console ↗

Shopping cart

Resolve a customer's order against a finite menu before computing a price.

Input and workflow

Map recognized items to internal product IDs. Use menu prices and quantities in ordinary arithmetic; request clarification for unspecified modifiers.

Request

{
  "model": "ngila-judge",
  "state": "One small oat latte and a plain bagel.",
  "questions": {
    "latte": {
      "type": "noul",
      "instructions": "Does the order include a latte?"
    },
    "bagel": {
      "type": "noul",
      "instructions": "Does the order include a bagel?"
    },
    "milk": {
      "type": "choice",
      "instructions": "What milk was requested?",
      "criteria": {
        "oat": "",
        "dairy": "",
        "unspecified": ""
      }
    }
  }
}

Open request in Playground →

Run locally

Save ngila.py alongside your script and set NGILA_API_KEY. Save any linked input images in the same directory.

import json
from ngila import NgilaClient

state = 'One small oat latte and a plain bagel.'
questions = {'latte': {'type': 'noul', 'instructions': 'Does the order include a latte?'},
 'bagel': {'type': 'noul', 'instructions': 'Does the order include a bagel?'},
 'milk': {'type': 'choice',
          'instructions': 'What milk was requested?',
          'criteria': {'oat': '', 'dairy': '', 'unspecified': ''}}}

response = NgilaClient().system_one(state, questions)
a = response["answers"]
print(json.dumps(a, indent=2, ensure_ascii=False))

Use the answers

The following application fragment uses a = response["answers"]. Supply any thresholds, lookup tables, or previous results from your workflow before applying it.

items = [k for k in ("latte","bagel") if a[k]["noul"] >= threshold]

Browse cookbooks · System One request and response