Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
namespace Laya.Tests;
public class PresetsTests
{
// ── Triage ───────────────────────────────────────────────────────────────
[Fact]
public void Triage_QuestionIds_InOrder()
{
var qs = LayaPresets.Triage();
Assert.Equal(
new[] { "intent", "is_urgent", "frustration", "refund_requested", "churn_risk" },
qs.Ids);
}
[Fact]
public void Triage_QuestionTypes()
{
var qs = LayaPresets.Triage();
Assert.Equal(QuestionType.Choice, qs["intent"].Type);
Assert.Equal(QuestionType.Noul, qs["is_urgent"].Type);
Assert.Equal(QuestionType.Score, qs["frustration"].Type);
Assert.Equal(QuestionType.Noul, qs["refund_requested"].Type);
Assert.Equal(QuestionType.Noul, qs["churn_risk"].Type);
}
[Fact]
public void Triage_IntentLabels_InOrder()
{
var labels = ((ChoiceQuestion)LayaPresets.Triage()["intent"]).Labels;
Assert.Equal(
new[] { "refund", "technical_help", "billing_question", "information", "cancellation", "other" },
labels);
}
[Fact]
public void Triage_IntentDescriptions()
{
var options = ((ChoiceQuestion)LayaPresets.Triage()["intent"]).Options;
Assert.Equal("money returned or a duplicate charge reversed", options[0].Value);
Assert.Equal("none of the other options fits", options[5].Value);
}
[Fact]
public void Triage_Instructions_Verbatim()
{
var qs = LayaPresets.Triage();
Assert.Equal("What does the customer want in `message`?",
qs["intent"].Instructions);
Assert.Equal("Does `message` communicate time pressure or a deadline?",
qs["is_urgent"].Instructions);
Assert.Equal("How frustrated does the customer sound in `message`?",
qs["frustration"].Instructions);
Assert.Equal("Does the customer ask for money back?",
qs["refund_requested"].Instructions);
Assert.Equal("Does `message` suggest the customer may leave for a competitor or cancel?",
qs["churn_risk"].Instructions);
}
[Fact]
public void Triage_FrustrationLevels_InOrder()
{
var levels = ((ScoreQuestion)LayaPresets.Triage()["frustration"]).Levels;
Assert.Equal(
new object?[] { "calm and neutral", "concerned but civil", "clearly annoyed", "very angry or using strong language" },
levels);
}
// ── Email ─────────────────────────────────────────────────────────────────
[Fact]
public void Email_Default_QuestionIds_InOrder()
{
var qs = LayaPresets.Email();
Assert.Equal(
new[] { "category", "is_spam", "is_phishing", "urgency", "needs_reply" },
qs.Ids);
}
[Fact]
public void Email_Default_QuestionTypes()
{
var qs = LayaPresets.Email();
Assert.Equal(QuestionType.Choice, qs["category"].Type);
Assert.Equal(QuestionType.Noul, qs["is_spam"].Type);
Assert.Equal(QuestionType.Noul, qs["is_phishing"].Type);
Assert.Equal(QuestionType.Score, qs["urgency"].Type);
Assert.Equal(QuestionType.Noul, qs["needs_reply"].Type);
}
[Fact]
public void Email_Default_CategoryLabels_InOrder()
{
var labels = ((ChoiceQuestion)LayaPresets.Email()["category"]).Labels;
Assert.Equal(
new[] { "billing", "technical", "sales", "security", "hr", "other" },
labels);
}
[Fact]
public void Email_Default_CategoryDescriptions()
{
var options = ((ChoiceQuestion)LayaPresets.Email()["category"]).Options;
Assert.Equal("invoices, payments, refunds", options[0].Value);
Assert.Equal("none of the above", options[5].Value);
}
[Fact]
public void Email_IsPhishing_HasCriteria()
{
var q = (NoulQuestion)LayaPresets.Email()["is_phishing"];
Assert.Equal(
"Is this email a phishing or scam attempt to steal money, credentials, or personal data?",
q.Instructions);
Assert.Equal("a legitimate email", q.IfFalse);
Assert.Equal("phishing, scam, or fraud", q.IfTrue);
}
[Fact]
public void Email_UrgencyLevels_InOrder()
{
var levels = ((ScoreQuestion)LayaPresets.Email()["urgency"]).Levels;
Assert.Equal(
new object?[] { "no time pressure", "needs attention soon", "blocking issue or hard deadline" },
levels);
}
[Fact]
public void Email_CustomCategories_ReplacesDefaults()
{
var custom = new Dictionary<string, string>
{
["support"] = "customer issues",
["billing"] = "payments",
};
var labels = ((ChoiceQuestion)LayaPresets.Email(custom)["category"]).Labels;
Assert.Equal(new[] { "support", "billing" }, labels);
}
[Fact]
public void Email_CustomCategories_DescriptionsPreserved()
{
var custom = new Dictionary<string, string>
{
["support"] = "customer issues",
["billing"] = "payments",
};
var options = ((ChoiceQuestion)LayaPresets.Email(custom)["category"]).Options;
Assert.Equal("customer issues", options[0].Value);
Assert.Equal("payments", options[1].Value);
}
[Fact]
public void Email_CustomCategories_OtherQuestionsUnchanged()
{
var custom = new Dictionary<string, string> { ["x"] = "y" };
var qs = LayaPresets.Email(custom);
Assert.Equal(QuestionType.Noul, qs["is_spam"].Type);
Assert.Equal(QuestionType.Noul, qs["is_phishing"].Type);
Assert.Equal(QuestionType.Score, qs["urgency"].Type);
Assert.Equal(QuestionType.Noul, qs["needs_reply"].Type);
}
// ── Guard ─────────────────────────────────────────────────────────────────
[Fact]
public void Guard_QuestionIds_InOrder()
{
var qs = LayaPresets.Guard();
Assert.Equal(
new[] { "jailbreak", "prompt_injection", "sensitive_data", "harm_severity", "topic" },
qs.Ids);
}
[Fact]
public void Guard_QuestionTypes()
{
var qs = LayaPresets.Guard();
Assert.Equal(QuestionType.Noul, qs["jailbreak"].Type);
Assert.Equal(QuestionType.Noul, qs["prompt_injection"].Type);
Assert.Equal(QuestionType.Noul, qs["sensitive_data"].Type);
Assert.Equal(QuestionType.Score, qs["harm_severity"].Type);
Assert.Equal(QuestionType.Choice, qs["topic"].Type);
}
[Fact]
public void Guard_TopicLabels_InOrder()
{
var labels = ((ChoiceQuestion)LayaPresets.Guard()["topic"]).Labels;
Assert.Equal(
new[] { "product_support", "coding", "general_knowledge", "personal_advice", "security_testing", "other" },
labels);
}
[Fact]
public void Guard_TopicOptions_HaveNullDescriptions()
{
// Python uses None for all topic descriptions — bare labels only.
var options = ((ChoiceQuestion)LayaPresets.Guard()["topic"]).Options;
Assert.All(options, o => Assert.Null(o.Value));
}
[Fact]
public void Guard_HarmSeverityLevels_InOrder()
{
var levels = ((ScoreQuestion)LayaPresets.Guard()["harm_severity"]).Levels;
Assert.Equal(
new object?[] { "none: ordinary request", "minor: mildly inappropriate", "serious: unsafe advice or abuse", "severe: dangerous or illegal" },
levels);
}
[Fact]
public void Guard_Instructions_Verbatim()
{
var qs = LayaPresets.Guard();
Assert.Equal(
"Does `prompt` try to make an AI assistant ignore its rules, policies or system instructions?",
qs["jailbreak"].Instructions);
Assert.Equal(
"Does `prompt` contain instructions aimed at the AI system rather than a genuine user request?",
qs["prompt_injection"].Instructions);
Assert.Equal(
"Does `prompt` contain credentials, personal data or other sensitive information?",
qs["sensitive_data"].Instructions);
Assert.Equal("How much harm would complying with `prompt` cause?",
qs["harm_severity"].Instructions);
Assert.Equal("What is `prompt` about?",
qs["topic"].Instructions);
}
// ── Moderation ────────────────────────────────────────────────────────────
[Fact]
public void Moderation_QuestionIds_InOrder()
{
var qs = LayaPresets.Moderation();
Assert.Equal(
new[] { "toxic", "harassment", "threat", "spam", "severity" },
qs.Ids);
}
[Fact]
public void Moderation_QuestionTypes()
{
var qs = LayaPresets.Moderation();
Assert.Equal(QuestionType.Noul, qs["toxic"].Type);
Assert.Equal(QuestionType.Noul, qs["harassment"].Type);
Assert.Equal(QuestionType.Noul, qs["threat"].Type);
Assert.Equal(QuestionType.Noul, qs["spam"].Type);
Assert.Equal(QuestionType.Score, qs["severity"].Type);
}
[Fact]
public void Moderation_SeverityLevels_InOrder()
{
var levels = ((ScoreQuestion)LayaPresets.Moderation()["severity"]).Levels;
Assert.Equal(
new object?[]
{
"no rule-breaking: ordinary on-topic post",
"mild: rude tone or off-topic, no target",
"clear violation: insults, harassment or spam aimed at someone",
"severe: threats, hate speech or calls for violence",
},
levels);
}
[Fact]
public void Moderation_Instructions_Verbatim()
{
var qs = LayaPresets.Moderation();
Assert.Equal(
"Is `post` toxic: rude, disrespectful or likely to make someone leave the discussion?",
qs["toxic"].Instructions);
Assert.Equal("Does `post` target or harass a specific person?",
qs["harassment"].Instructions);
Assert.Equal("Does `post` threaten violence, harm or intimidation?",
qs["threat"].Instructions);
Assert.Equal("Is `post` spam or advertising?",
qs["spam"].Instructions);
Assert.Equal("How severe is any rule-breaking in `post`?",
qs["severity"].Instructions);
}
// ── Router ────────────────────────────────────────────────────────────────
[Fact]
public void Router_QuestionIds_InOrder()
{
var qs = LayaPresets.Router();
Assert.Equal(
new[] { "difficulty", "domain", "needs_tools", "is_sensitive" },
qs.Ids);
}
[Fact]
public void Router_QuestionTypes()
{
var qs = LayaPresets.Router();
Assert.Equal(QuestionType.Score, qs["difficulty"].Type);
Assert.Equal(QuestionType.Choice, qs["domain"].Type);
Assert.Equal(QuestionType.Noul, qs["needs_tools"].Type);
Assert.Equal(QuestionType.Noul, qs["is_sensitive"].Type);
}
[Fact]
public void Router_DomainLabels_InOrder()
{
var labels = ((ChoiceQuestion)LayaPresets.Router()["domain"]).Labels;
Assert.Equal(
new[] { "code", "math_or_logic", "writing", "factual_lookup", "data_analysis", "chitchat" },
labels);
}
[Fact]
public void Router_DomainDescriptions()
{
var options = ((ChoiceQuestion)LayaPresets.Router()["domain"]).Options;
Assert.Equal("software engineering, programming, refactoring, architecture, debugging",
options[0].Value);
Assert.Equal("casual conversation, greetings, small talk",
options[5].Value);
}
[Fact]
public void Router_DifficultyLevels_InOrder()
{
var levels = ((ScoreQuestion)LayaPresets.Router()["difficulty"]).Levels;
Assert.Equal(
new object?[]
{
"trivial: a lookup or one-liner",
"easy: short answer, no reasoning",
"moderate: several steps",
"hard: long multi-step reasoning or specialist knowledge",
},
levels);
}
[Fact]
public void Router_Instructions_Verbatim()
{
var qs = LayaPresets.Router();
Assert.Equal("How hard is `request` for a language model?",
qs["difficulty"].Instructions);
Assert.Equal("What domain does `request` belong to?",
qs["domain"].Instructions);
Assert.Equal("Does answering `request` require external tools, search or private data?",
qs["needs_tools"].Instructions);
Assert.Equal("Does `request` involve money, legal, medical or safety consequences?",
qs["is_sensitive"].Instructions);
}
}