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(serve): reject a null score level with 422 instead of an unparseable null legend (#302)
AlKor135dfe1e0518b7
diff --git a/laya/serve.py b/laya/serve.pyindex 12254fae..dd1438d7 100644--- a/laya/serve.py+++ b/laya/serve.py@@ -530,6 +530,15 @@ def _check_request_limits(state: Any, questions: Any) -> None:status_code=413,detail="too many score levels for %r (%d > %d)" % (qid, count, MAX_SCORE_LEVELS),)+ # A null level is a hole in the rubric: the answer's `legend` would carry+ # `{"<i>": null}`, which a Jev client's schema refuses to parse (#302). Reject it as a+ # malformed request rather than answering 200 with an unparseable legend.+ if None in crit:+ raise HTTPException(+ status_code=422,+ detail="score question %r has a null level at index %d; give every level a "+ "description" % (qid, crit.index(None)),+ )if total_options > MAX_TOTAL_OPTIONS:raise HTTPException(status_code=413,diff --git a/tests/test_serve.py b/tests/test_serve.pyindex 155aeffb..f2186a7d 100644--- a/tests/test_serve.py+++ b/tests/test_serve.py@@ -868,6 +868,19 @@ def test_malformed_question_id_is_a_named_422(monkeypatch, bad_qid):assert "question id" in response.text, response.text+def test_score_null_level_is_a_named_422(monkeypatch):+ """A null score level would come back as `legend: {"<i>": null}`, which Jev clients refuse to+ parse (#302). The request is rejected as a named 422 instead of answered 200."""+ monkeypatch.delenv("LAYA_API_KEY", raising=False)+ client = TestClient(create_app(router=ValidatingRouter()), raise_server_exceptions=False)+ body = dict(REQ)+ body["questions"] = {"urgency": {"type": "score", "instructions": "How urgent?",+ "criteria": ["low", None, "high"]}}+ response = client.post("/v1/systemone", json=body)+ assert response.status_code == 422, response.text+ assert "null level" in response.text and "urgency" in response.text, response.text++def test_a_nested_choice_label_is_a_caller_error_not_a_server_fault(monkeypatch):"""A `criteria` list containing a list/dict label is the caller's mistake, so it must be 422.