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
refactor(email): one definition of email_questions (#136)
Ludwig J. Marx4419a013518a
diff --git a/laya/email.py b/laya/email.pyindex 958f98a1..b5592e1d 100644--- a/laya/email.py+++ b/laya/email.py@@ -9,6 +9,10 @@ history (often a *different* request) weighed on the answer as much as the new mimport refrom typing import Dict, List, Optional+# One definition, in the module that holds the other presets. Re-exported here because+# `from laya.email import email_questions` is a path callers already have.+from .presets import email_questions # noqa: F401+_QUOTE_HEADERS = [re.compile(r"^\s*On .{0,300}wrote:\s*$", re.I),# "Em resposta ao que você escreveu:" is body text; a client's attribution always carries a date@@ -182,40 +186,3 @@ def email_state(subject: str, body: str, sender: Optional[str] = None, clean: bostate["from"] = senderstate.update({k: v for k, v in extra.items() if v is not None})return state---def email_questions(categories: Optional[Dict[str, str]] = None) -> Dict:- """Standard pre-built questions for email triage."""- categories = categories or {- "billing": "invoices, payments, refunds",- "technical": "bugs, outages, integrations",- "sales": "pricing, demos, new purchases",- "security": "phishing, scams, account compromise",- "hr": "hiring, leave, payroll",- "other": "none of the above",- }- return {- "category": {- "type": "choice",- "instructions": "Which team should handle the email in `body`?",- "criteria": categories,- },- "is_spam": {- "type": "noul",- "instructions": "Is this email unsolicited spam or bulk marketing?",- },- "is_phishing": {- "type": "noul",- "instructions": "Is this email a phishing or scam attempt to steal money, credentials, or personal data?",- "criteria": {"true": "phishing, scam, or fraud", "false": "a legitimate email"},- },- "urgency": {- "type": "score",- "instructions": "How urgent is the request in `body`?",- "criteria": ["no time pressure", "needs attention soon", "blocking issue or hard deadline"],- },- "needs_reply": {- "type": "noul",- "instructions": "Does the sender expect a reply?",- },- }diff --git a/tests/test_email.py b/tests/test_email.pyindex e64c7993..b49de7d3 100644--- a/tests/test_email.py+++ b/tests/test_email.py@@ -17,12 +17,20 @@ as the start of a signature and everything after it was cut:clean_email_body("Hi,\\n\\nThanks for the quick reply.\\nCould you refund invoice 4411?")# before: 'Hi,' <- the request was cut away++The last block guards a different kind of silence. `email_questions` was defined twice, here and+in `laya/presets.py`, and `laya/__init__.py` re-exports the `presets` one. Editing the copy in+`laya/email.py` moved `laya.email.email_questions` and left `laya.email_questions` where it was,+with no test and no lint failing."""import osimport syssys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))+import laya # noqa: E402+from laya import email as email_module # noqa: E402+from laya import presets # noqa: E402from laya.email import clean_email_body, email_state # noqa: E402PASS, FAIL = [], []@@ -390,6 +398,28 @@ check()+# ------------------------------------------- email_questions has exactly one definition+check_true(+ "email_questions/one definition behind both module paths",+ email_module.email_questions is presets.email_questions,+ "laya.email.email_questions is not laya.presets.email_questions",+)+check_true(+ "email_questions/the package export is that same object",+ laya.email_questions is presets.email_questions,+)+check(+ "email_questions/both paths answer the same",+ email_module.email_questions(),+ laya.email_questions(),+)+check(+ "email_questions/a caller override reaches both paths",+ email_module.email_questions({"legal": "contracts"})["category"]["criteria"],+ laya.email_questions({"legal": "contracts"})["category"]["criteria"],+)++print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))for f in FAIL:print(" FAIL " + f)