Console ↗

Choosing from a large catalog

Narrow a large inventory to a small candidate set over several passes.

Input and workflow

Chunk an inventory by category. Carry forward several candidates from each shortlist, then ask a final choice with a none option.

Request

{
  "model": "ngila-judge",
  "state": {
    "description": "A portable light for reading after dark.",
    "shortlist": [
      "clip-on lamp",
      "desk organizer",
      "notebook"
    ]
  },
  "questions": {
    "product": {
      "type": "choice",
      "instructions": "Select the closest match.",
      "criteria": {
        "clip-on lamp": "",
        "desk organizer": "",
        "notebook": "",
        "none": ""
      }
    }
  }
}

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 = {'description': 'A portable light for reading after dark.',
 'shortlist': ['clip-on lamp', 'desk organizer', 'notebook']}
questions = {'product': {'type': 'choice',
             'instructions': 'Select the closest match.',
             'criteria': {'clip-on lamp': '',
                          'desk organizer': '',
                          'notebook': '',
                          'none': ''}}}

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.

winner = a["product"]["choice"]
match = None if winner == "none" else winner

Browse cookbooks · System One request and response