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(cli): a --questions path that cannot be read is a usage error naming the file
PerryLinkfb5c4e5c266a
diff --git a/laya/cli.py b/laya/cli.pyindex d5794be0..227675e9 100644--- a/laya/cli.py+++ b/laya/cli.py@@ -164,6 +164,13 @@ def load_questions(path):raw = json.load(handle)except FileNotFoundError:raise ValueError("no such --questions file: %s" % path)+ except OSError as error:+ # A path that exists but cannot be read as a file -- a directory, or one this process may+ # not open -- is the same class of fault as the three below: it is about *this* file, not+ # about a missing dependency or a failed checkpoint download. Letting the raw OSError reach+ # run()'s `except (ImportError, OSError, RuntimeError)` printed "could not run Laya" and+ # advised checking the network, which is a false diagnosis for a wrong --questions path.+ raise ValueError("--questions file %s cannot be read: %s" % (path, error)) from error# The same three refusals `laya/evidence.py::_read_json_object` makes: a bare JSONDecodeError or# UnicodeDecodeError says what is wrong with the text but not which file, and a too-deep document# surfaces as a RecursionError that the caller's `except (OSError, RuntimeError, ...)` misreads asdiff --git a/tests/test_cli.py b/tests/test_cli.pyindex a5454140..bd7c301c 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -710,6 +710,18 @@ check("questions: too-deep JSON is exit 2, not a download-error message",code == 2 and "nested deeper" in err and "checkpoint" not in err,"code %r err %r" % (code, err))+# A path that exists but is not a readable file -- here a directory -- is the same fault one step+# further out: `open()` raises IsADirectoryError, an OSError that run()'s+# `except (ImportError, OSError, RuntimeError)` reports as "could not run Laya" with advice to check+# the network. It has to name the path and stay a usage error, like the three cases above.+questions_dir = os.path.join(_TMP, "a-directory")+os.makedirs(questions_dir, exist_ok=True)+code, out, err, stub = run_cli(["hi", "--questions", questions_dir], router=QuestionRecorder())+check("questions: a directory is exit 2 naming the file, not a runtime error",+ code == 2 and "cannot be read" in err and questions_dir in err and "could not run Laya" not in err,+ "code %r err %r" % (code, err))+check("questions: a directory never reaches predict", stub.questions is None, str(stub.questions))+code, out, err, stub = run_cli(["hi", "--questions", INTENTS_PATH, "--preset", "triage"],router=QuestionRecorder())check("questions: two sources refuse each other",