Skip to content

DocsExamples

3 min read · updated

Use cases

Six recipes for putting decisio in a product, each with the question, the code that routes on its certificate, and what it did when measured.

Each recipe is the same three steps: ask one question about the text, teach and certify it from your labelled examples, and act on the certified answers while a person takes the rest. The routing code is the same in every recipe; this is support routing’s:

python
import json
import os
import urllib.error
import urllib.request
QUESTION = {
"type": "choice",
"instructions": "Which support queue should handle this ticket?",
"criteria": {
"billing": "Invoices, charges, refunds",
"access": "Login, passwords, permissions",
"bug": "The product behaves wrongly",
"shipping": "Orders and deliveries",
"other": "Anything else"
}
}
BASE_URL = os.environ.get("DECISIO_BASE_URL", "http://127.0.0.1:8000").rstrip("/")
TIMEOUT = 15
REVIEW = "to a person"
def route(text):
request = urllib.request.Request(
BASE_URL + "/v1/systemone",
data=json.dumps({"state": text, "questions": {"queue": QUESTION}}).encode(),
headers={"Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
answer = json.load(response)["answers"]["queue"]
if not isinstance(answer, dict) or answer.get("type") != QUESTION["type"]:
return REVIEW
if not (answer.get("choice") in QUESTION["criteria"]):
return REVIEW
# A gold certificate is about correctness; agreement alone is insufficient.
if (answer.get("certified") is True
and answer.get("certificate_kind") == "gold"
and isinstance(answer.get("certificate"), str)
and answer["certificate"]):
return f"send to {answer['choice']}"
return f"to a person, {answer['choice']} suggested"
except (urllib.error.URLError, TimeoutError, OSError, ValueError, KeyError, TypeError):
return REVIEW
if __name__ == "__main__":
print(route("My card was charged twice this month. Please refund one of the charges."))
Output
to a person, billing suggested
Use caseWhat decisio decidesProof
Support routingwhich queue a ticket goes tomeasured
Coding-agent gatekeeperallow, ask or block a shell command, by your rulesmeasured
Issue triagethe kind of a new issue, and its owning teammeasured
Guardrailswhether a message breaks a policymeasured for toxicity
RAG: answer or abstainwhether a retrieved passage answers the questionmeasured as accuracy
Document classificationthe type of an incoming documentrecipe

“Measured” means a published run of the same question; “recipe” means the steps and the code, with no published run yet.

Each answer is read from one forward pass and no generated text, so nothing is worked out step by step. A question that needs reasoning over several steps, or knowledge the text does not hold, is not a good fit.

Every recipe caller sends an uncertified answer to review. It does the same on an HTTP error, a timeout or a malformed answer. It requires a gold certificate before acting on its own: a learned table’s agreement certificate alone does not meet that policy.

The callers use a 15-second network timeout; set it to fit your application, and log failures where you call route. Each caller prints an action for your backend to perform: connect that action to your own queue, workflow or review interface.