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
fix(examples): read a bad LAYA_MAX_LOADED as unset, not as an import crash
Aashishdd5a80875db9
diff --git a/examples/server.py b/examples/server.pyindex 1e089209..7b25a949 100644--- a/examples/server.py+++ b/examples/server.py@@ -411,6 +411,26 @@ class BatchRequest(BaseModel):# --------------------------------------------------------------------------- #ROUTER: Optional[Router] = None+++def _resolve_max_loaded() -> Optional[int]:+ """Resident-checkpoint cap from ``LAYA_MAX_LOADED``; ``None`` leaves it to ``Router``.++ Mirrors ``laya/serve.py::_resolve_max_loaded``. Unparseable or non-positive input falls back+ to "not asked for" rather than reaching the ``int()`` below as a crash: a typo in a deployment+ file must not stop the server at import, which is the same fail-soft the shipped server keeps+ and the one the ``--max-loaded`` flag already gets from argparse ``type=int``.+ """+ raw = os.environ.get("LAYA_MAX_LOADED")+ if not raw or not raw.strip():+ return None+ try:+ n = int(raw)+ except ValueError:+ return None+ return n if n > 0 else None++_CFG: Dict[str, Any] = {"preload": os.getenv("LAYA_PRELOAD", "1") not in ("0", "false", "False"),"device": os.getenv("LAYA_DEVICE") or None,@@ -423,8 +443,7 @@ _CFG: Dict[str, Any] = {# neither key when the variable is unset -- moved with it."default": (os.environ["LAYA_DEFAULT_MODEL"].strip()if os.getenv("LAYA_DEFAULT_MODEL", "").strip() else None),- "max_loaded": (int(os.environ["LAYA_MAX_LOADED"])- if os.getenv("LAYA_MAX_LOADED", "").strip() else None),+ "max_loaded": _resolve_max_loaded(),}diff --git a/tests/test_example_server_limits.py b/tests/test_example_server_limits.pyindex 9f9f9713..3589ea7c 100644--- a/tests/test_example_server_limits.py+++ b/tests/test_example_server_limits.py@@ -440,6 +440,17 @@ def main():== build_router().max_loaded,"%r vs %r" % (fresh._router_kwargs(fresh._CFG), build_router().max_loaded))+ # A bad or non-positive LAYA_MAX_LOADED must fall back to "not asked for" the way+ # laya.serve's `_resolve_max_loaded` documents ("a typo in a deployment file should not stop+ # the server from starting"), not reach `int()` as an import crash and not forward a cap+ # Router cannot honour. FAILS_ON_MAIN: the bare int() at module level aborts the reload.+ for raw in ("abc", "2.5", "0", "-3", ""):+ fresh = with_cap(raw)+ ok("LAYA_MAX_LOADED=%r falls back to 'not asked for'" % raw,+ "max_loaded" not in fresh._router_kwargs(fresh._CFG),+ repr(fresh._router_kwargs(fresh._CFG)))+ with_cap(None) # leave the ambient env clean for the checks below+# --- the routing fallback: derived, not copied --------------------------# The copy retired above said a number. The one beside it named a checkpoint: 3cf26cb moved# `Router(default=...)` from `english` to `multilingual` in 0.4.0, and `laya.serve` followed