cookbook · Decider 1 · LLM guardrails
Hold a reply that promises money
Before an assistant's draft reply reaches a customer, you may want to screen it for risky commitments. This recipe asks three specific questions about the draft: does it promise a refund (0.86), does it state a money amount (0.82), and does it apologize (0.89). Any draft that promises money is held for human approval before sending.
Request
POST /v1/systemone, documented in the Decider 1 reference.
curl https://meragpt.com/v1/systemone \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sd-1",
"state": {
"user_message": "My order arrived broken. What now?",
"assistant_draft": "So sorry about that! I'\''ve gone ahead and issued a full refund of $249 to your card, and a replacement is on its way at no charge."
},
"questions": {
"promises_refund": {
"type": "noul",
"instructions": "Does the assistant draft promise or claim to have issued a refund?"
},
"promises_money_amount": {
"type": "noul",
"instructions": "Does the assistant draft state a specific amount of money?"
},
"apologizes": {
"type": "noul",
"instructions": "Does the assistant draft apologize to the user?"
}
}
}'What came back
The real output from running this recipe, unedited.
{
"answers": {
"promises_refund": {
"type": "noul",
"noul": 0.8578
},
"promises_money_amount": {
"type": "noul",
"noul": 0.8173
},
"apologizes": {
"type": "noul",
"noul": 0.8898
}
}
}Python
import os, requests
API = "https://meragpt.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MERAGPT_API_KEY']}"}
def needs_approval(user_message: str, draft: str) -> bool:
body = {
"model": "sd-1",
"state": {
"user_message": user_message,
"assistant_draft": draft
},
"questions": {
"promises_refund": {
"type": "noul",
"instructions": "Does the assistant draft promise or claim to have issued a refund?"
},
"promises_money_amount": {
"type": "noul",
"instructions": "Does the assistant draft state a specific amount of money?"
},
"apologizes": {
"type": "noul",
"instructions": "Does the assistant draft apologize to the user?"
}
}
}
a = requests.post(f"{API}/systemone", headers=HEADERS, json=body).json()["answers"]
return a["promises_refund"]["noul"] >= 0.5 or a["promises_money_amount"]["noul"] >= 0.5
TypeScript
const API = "https://meragpt.com/v1";
const headers = {
Authorization: `Bearer ${process.env.MERAGPT_API_KEY}`,
"Content-Type": "application/json",
};
async function needsApproval(userMessage: string, draft: string): Promise<boolean> {
const body = {
"model": "sd-1",
"state": {
"user_message": userMessage,
"assistant_draft": draft
},
"questions": {
"promises_refund": {
"type": "noul",
"instructions": "Does the assistant draft promise or claim to have issued a refund?"
},
"promises_money_amount": {
"type": "noul",
"instructions": "Does the assistant draft state a specific amount of money?"
},
"apologizes": {
"type": "noul",
"instructions": "Does the assistant draft apologize to the user?"
}
}
};
const a = (await fetch(`${API}/systemone`, { method: "POST", headers, body: JSON.stringify(body) }).then((res) => res.json())).answers;
return a.promises_refund.noul >= 0.5 || a.promises_money_amount.noul >= 0.5;
}
When to trust it
The recipe works well for specific, checkable rules like the ones shown. It does not reliably catch invented facts, so do not use it as a fact-checker.
Try it without code in the playground, or see more Decider 1 recipes: route a support email in one call, act only when the model is sure, flag a phishing email, drop retrieved passages that do not help, pick an agent's first tool, ask many questions in one call.