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
docs(hooks): a routing pin must be a hook object, not a plain callable
Adeshina Lasisid6e60d63ab60
diff --git a/docs/hooks/examples.md b/docs/hooks/examples.mdindex 96d49e1e..13933d1d 100644--- a/docs/hooks/examples.md+++ b/docs/hooks/examples.md@@ -187,29 +187,32 @@ misses the threshold, not only the first state's.## Routing pin-Force a checkpoint for a class of traffic.+Force a checkpoint for a class of traffic. A routing hook is an object, not a plain callable:+`on_predict_start=` / `on_predict_end=` are the only single-event parameters, so `hooks=` is the+only way in and it reads for lifecycle method names.```pythonfrom laya import Routerfrom laya.router import RouteDecision-def pin(ctx):- if "refund" in str(ctx.states[0]).lower():- ctx.decision = RouteDecision(- model="typed-decisions",- repo="convaiinnovations/laya/typed-decisions",- reason="refund workflow",- detection=None,- workflow=None,- )--router = Router(hooks=[pin])+class Pin:+ def on_route(self, ctx):+ if "refund" in str(ctx.states[0]).lower():+ ctx.decision = RouteDecision(+ model="typed-decisions",+ repo="convaiinnovations/laya/typed-decisions",+ reason="refund workflow",+ detection=None,+ workflow=None,+ )++router = Router(hooks=[Pin()])```Per-call, without installing:```python-router.predict("refund request", QUESTIONS, hooks=[pin])+router.predict("refund request", QUESTIONS, hooks=[Pin()])```## Lifecycle@@ -275,7 +278,7 @@ agent.system_one(router.predict(state,questions,- hooks=[pin], # applies to on_route too+ hooks=[Pin()], # applies to on_route tooon_predict_end=audit,)```diff --git a/docs/hooks/patterns.md b/docs/hooks/patterns.mdindex 2088a141..f5d73814 100644--- a/docs/hooks/patterns.md+++ b/docs/hooks/patterns.md@@ -178,22 +178,25 @@ one ships every other low-confidence answer unannotated.### Routing override-`on_route` may replace `ctx.decision` to pin a checkpoint for a class of traffic.+`on_route` may replace `ctx.decision` to pin a checkpoint for a class of traffic. It has to be a+hook object: the convenience callables cover `on_predict_start` / `on_predict_end` only, so a bare+function in `hooks=` is refused (see [plain callables in `hooks=`](#plain-callables-in-hooks)).```pythonfrom laya.router import RouteDecision-def pin(ctx):- if "refund" in str(ctx.states[0]).lower():- ctx.decision = RouteDecision(- model="typed-decisions",- repo="convaiinnovations/laya/typed-decisions",- reason="refund workflow",- detection=None,- workflow=None,- )--Router(hooks=[pin])+class Pin:+ def on_route(self, ctx):+ if "refund" in str(ctx.states[0]).lower():+ ctx.decision = RouteDecision(+ model="typed-decisions",+ repo="convaiinnovations/laya/typed-decisions",+ reason="refund workflow",+ detection=None,+ workflow=None,+ )++Router(hooks=[Pin()])```### Model lifecycle