Return a stable line identifier for evidence within a document.
Input and workflow
Assign stable IDs before splitting the document. Return a source link using the winning line only when the coverage check passes.
Request
{
"model": "ngila-judge",
"state": {
"query": "How long can I keep the book?",
"lines": {
"L1": "A library card is free.",
"L2": "Loans expire after three weeks."
}
},
"questions": {
"line": {
"type": "choice",
"instructions": "Which line answers the query?",
"criteria": {
"L1": "",
"L2": "",
"none": ""
}
},
"covered": {
"type": "noul",
"instructions": "Does the excerpt specify the loan duration?"
}
}
}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 = {'query': 'How long can I keep the book?',
'lines': {'L1': 'A library card is free.',
'L2': 'Loans expire after three weeks.'}}
questions = {'line': {'type': 'choice',
'instructions': 'Which line answers the query?',
'criteria': {'L1': '', 'L2': '', 'none': ''}},
'covered': {'type': 'noul',
'instructions': 'Does the excerpt specify the loan duration?'}}
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.
line = a["line"]["choice"]
evidence = state["lines"].get(line) if a["covered"]["noul"] >= threshold else None