Skip to content

armgit / laya

Public Imported from GitHub
0

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.

Merge pull request #808 from modusensus/fix/gui-error-page-exception-text

Nandakishor581f820d8d31
diff --cc examples/server.py
index e070a6cd,84864a80..54e63c9c
--- a/examples/server.py
+++ b/examples/server.py
@@@ -69,22 -69,14 +69,28 @@@ MAX_STATE_CHARS = getattr(_laya_serve,
MAX_CHOICE_OPTIONS = getattr(_laya_serve, "MAX_CHOICE_OPTIONS", 100)
MAX_SCORE_LEVELS = getattr(_laya_serve, "MAX_SCORE_LEVELS", 32)
MAX_TOTAL_OPTIONS = getattr(_laya_serve, "MAX_TOTAL_OPTIONS", 512)
+DEFAULT_MAX_TOKEN_BUDGET = getattr(_laya_serve, "DEFAULT_MAX_TOKEN_BUDGET", 8192)
+
+# The set of controls a client may put on the body, and the set that must be refused rather than
+# silently dropped -- both read from `laya.serve` so the demo cannot drift from the server it
+# demonstrates. `BODY_CONTROLS` is what the shipped `/v1/systemone` forwards; `BODY_REFUSALS` is
+# the hook surface (`hooks`, `hooks_raise`, `hooks_timeout`, `on_predict_start`, `on_predict_end`)
+# that a `ServerApp` cannot receive over HTTP but the Router does take as call arguments -- the
+# demo has no hook receiver, so those are refused the same way.
+BODY_CONTROLS = tuple(getattr(_laya_serve, "BODY_CONTROLS",
+ ("model", "max_len", "head_max_len", "task", "lang",
+ "lang_guess", "min_confidence")))
+BODY_REFUSALS = tuple(getattr(_laya_serve, "BODY_REFUSALS",
+ ("hooks", "on_predict_start", "on_predict_end",
+ "hooks_raise", "hooks_timeout")))
+ # The sentence `laya.serve._state_length` answers a state it cannot measure with. Named because
+ # `_limit_violation` hands this answer back as data for `/gui` rather than reading it off the
+ # exception (`py/stack-trace-exposure`): one literal, two readers.
+ _STATE_NOT_SERIALIZABLE = "'state' must be JSON-serializable"
+
+
def _fallback_state_length(state: Any) -> int:
"""`laya.serve._state_length` for a laya that predates it, 400 included.