JSON output
With --json, ThinkThen prints one line of JSON for each text it judges. Each line says whether it answered, was not sure or failed, with the answer, its probability and its details; the SDKs return the same fields.
jq . spreads each line out so you can read it. A yes:
echo 'Please refund my order.' | thinkthen decide --json \ 'Does the customer request a refund?' | jq .Output
{
"function": "decide",
"position": 1,
"source": {
"question_identity": "5132ed9868967585162c6dbe9857c49aa3fabb369a607b921f7645bc225b8bf2",
"backend": "systemone",
"model": "jev-1.13.0"
},
"status": "answered",
"answer": true,
"probability": 0.99
}
The fields on every line
Section titled “The fields on every line”| Field | What it holds |
|---|---|
function |
The function that answered, such as decide. |
position |
Where the text came in the input, counting from 1. |
id |
The id of the JSON line, when it has one. A string or a whole number, exactly as it was. |
source |
Which question was asked, and where. See below. |
status |
answered, unsure for not sure, or failed. |
source holds:
| Field | What it holds |
|---|---|
question_identity |
A fingerprint of the question. The same question asked the same way has the same fingerprint. |
backend |
The service that answered, such as systemone. |
model |
The model that answered. |
name |
The name from --name, when you gave one. |
The fields for each status
Section titled “The fields for each status”answered adds answer, and probability and detail for the functions that have them.
unsure adds probability, which fell short of your bar for a sure answer, and detail for the functions that have it. It has no answer.
echo 'I was charged twice for one invoice.' | thinkthen decide --low 0.2 --high 0.8 --json \ 'Does the customer request a refund?' | jq .Output
{
"function": "decide",
"position": 1,
"source": {
"question_identity": "fee570dbf2ecad88b2e5569e5b2919263a04593aad817a9a77c2bd6504fb7235",
"backend": "systemone",
"model": "jev-1.13.0"
},
"status": "unsure",
"probability": 0.7
}
Not sure: the chance of yes falls between the bars of 0.2 and 0.8.
failed adds error, with its code and message, and http_status when the service sent one. It has no answer. Troubleshooting lists each code.
echo '{"id":"a4"}' | thinkthen decide --from jsonl --field /text --json \ 'Does the customer request a refund?' | jq .Output
{
"function": "decide",
"position": 1,
"id": "a4",
"source": {
"question_identity": "7cd1876e82c67b9664acdb9d3ffea1967cb0a1d895c05e75aa5702006c60036a",
"backend": "systemone",
"model": "jev-1.13.0"
},
"status": "failed",
"error": {
"code": "record.missing",
"message": "the record holds nothing at /text"
}
}
thinkthen: record.missing: position 1 id a4 file -: the record holds nothing at /text
Failed: the line has no text field to judge.
The answer and details of each function
Section titled “The answer and details of each function”| Function | answer |
detail |
|---|---|---|
| decide | true or false |
none |
| filter | true or false |
none |
| choose | One of your choices | labels: the chance of each choice |
| tag | A list of the labels that fit | labels: the chance of each label |
| score | A number from 0 to 1 along your levels | levels: the chance of each level, in your order |
| rank | The text's place, counting from 1 | levels: the chance of each level, in your order |
| find | The part that answers, as text, start and end, or null when none does |
none |
| recognize | A list of names, each with text, start, end, kind and probability |
names and pieces: the chance of each kind for each name and piece |
| relate | A list of links, each with source, relation, target and probability |
names, and pairs: the chance of each allowed link |
| annotate | An object with one answer per question name | none |
start and end count characters from 0, and end is the position after the last character. In relate, source and target are names, each with text, start, end and kind, and either is true when the link can go either way.
Each answer inside annotate has the function, status, answer, probability, detail and error fields of its own function, without position, id or source.
The extra fields from filter
Section titled “The extra fields from filter”filter adds two fields on the command line. item holds the text or JSON line it judged, and kept is true for a line it keeps.
JSON Lines shows how to keep your own fields and add the answer with --into.