Console ↗

Guardrails for LLMs

Check an assistant's proposed reply against the user's request and the support policy before releasing it.

Input and workflow

Evaluate evidence and relevance separately. A relevant answer can still invent an opening time. Send unsupported replies back for revision before publication.

Request

{
  "model": "ngila-judge",
  "state": {
    "request": "When does the shop close?",
    "policy": "Give hours only when the schedule is supplied.",
    "reply": "We close at nine."
  },
  "questions": {
    "has_evidence": {
      "type": "noul",
      "instructions": "Do the supplied records support the stated closing time?"
    },
    "addresses_question": {
      "type": "noul",
      "instructions": "Does the reply answer the question?"
    }
  }
}

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 = {'request': 'When does the shop close?',
 'policy': 'Give hours only when the schedule is supplied.',
 'reply': 'We close at nine.'}
questions = {'has_evidence': {'type': 'noul',
                  'instructions': 'Do the supplied records support the stated '
                                  'closing time?'},
 'addresses_question': {'type': 'noul',
                        'instructions': 'Does the reply answer the question?'}}

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.

publish = all(a[k]["noul"] >= minimum for k in ("has_evidence","addresses_question"))

Browse cookbooks · System One request and response