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(integrations): one LayaLowConfidenceError for LlamaIndex and CrewAI, local URLs in tests
Nandakishored5f7de4ad67
diff --git a/laya/integrations/__init__.py b/laya/integrations/__init__.pyindex 7eb80c55..f99ed903 100644--- a/laya/integrations/__init__.py+++ b/laya/integrations/__init__.py@@ -1,8 +1,8 @@"""Third-party agent and framework integrations for Laya."""+from ._errors import LayaLowConfidenceErrorfrom .crewai import (CrewRouteDecision,LayaCrewRouter,- LayaLowConfidenceError,LayaTaskGuard,LayaTaskGuardError,)@@ -15,7 +15,6 @@ from .langchain import (LayaTriage,)from .llamaindex import (- LayaLowConfidenceError,LayaMultiSelector,LayaQueryRouter,LayaSingleSelector,diff --git a/laya/integrations/_errors.py b/laya/integrations/_errors.pynew file mode 100644index 00000000..a126abfb--- /dev/null+++ b/laya/integrations/_errors.py@@ -0,0 +1,12 @@+"""Exceptions shared by the framework integrations."""+from typing import Any, Dict+++class LayaLowConfidenceError(ValueError):+ """Raised when a routing decision falls below the confidence threshold and no fallback is set."""++ def __init__(self, message: str, confidence: float, threshold: float, raw_decision: Dict[str, Any]):+ super().__init__(message)+ self.confidence = confidence+ self.threshold = threshold+ self.raw_decision = raw_decisiondiff --git a/laya/integrations/crewai.py b/laya/integrations/crewai.pyindex 4ed9da0f..5c154c71 100644--- a/laya/integrations/crewai.py+++ b/laya/integrations/crewai.py@@ -51,14 +51,8 @@ class LayaTaskGuardError(ValueError):self.raw_decision = raw_decision-class LayaLowConfidenceError(ValueError):- """Raised when task routing confidence falls below the configured threshold and no fallback is set."""-- def __init__(self, message: str, confidence: float, threshold: float, raw_decision: Dict[str, Any]):- super().__init__(message)- self.confidence = confidence- self.threshold = threshold- self.raw_decision = raw_decision+# One class for every integration, so `except LayaLowConfidenceError` catches all of them.+from ._errors import LayaLowConfidenceError # noqa: E402@dataclassdiff --git a/laya/integrations/llamaindex.py b/laya/integrations/llamaindex.pyindex 4bf8f960..6e7615a2 100644--- a/laya/integrations/llamaindex.py+++ b/laya/integrations/llamaindex.py@@ -60,14 +60,8 @@ except ImportError:return self.query_str-class LayaLowConfidenceError(ValueError):- """Raised when a routing decision falls below the confidence threshold and no fallback is set."""-- def __init__(self, message: str, confidence: float, threshold: float, raw_decision: Dict[str, Any]):- super().__init__(message)- self.confidence = confidence- self.threshold = threshold- self.raw_decision = raw_decision+# One class for every integration, so `except LayaLowConfidenceError` catches all of them.+from ._errors import LayaLowConfidenceError # noqa: E402def _extract_query_str(query: Union[str, QueryBundle, Any]) -> str:diff --git a/tests/test_crewai.py b/tests/test_crewai.pyindex b0a02f93..c2587763 100644--- a/tests/test_crewai.py+++ b/tests/test_crewai.py@@ -270,7 +270,7 @@ with patch("urllib.request.build_opener") as mock_build_opener:mock_build_opener.return_value = mock_openerremote_router = LayaCrewRouter(- base_url="https://api.laya.ai",+ base_url="http://localhost:8000",api_key="sk-crew-key",)dec_remote = remote_router.route("Analyze codebase", agents)@@ -279,7 +279,7 @@ with patch("urllib.request.build_opener") as mock_build_opener:# Verify request headers and URLcall_args = mock_opener.open.call_argsreq = call_args[0][0]- check("remote/url", req.full_url, "https://api.laya.ai/v1/systemone")+ check("remote/url", req.full_url, "http://localhost:8000/v1/systemone")check("remote/auth", req.headers.get("Authorization"), "Bearer sk-crew-key")diff --git a/tests/test_llamaindex.py b/tests/test_llamaindex.pyindex e056599a..7b3cbc23 100644--- a/tests/test_llamaindex.py+++ b/tests/test_llamaindex.py@@ -380,7 +380,7 @@ with patch("urllib.request.build_opener") as mock_build_opener:mock_build_opener.return_value = mock_openerremote_selector = LayaSingleSelector(- base_url="https://api.laya.ai",+ base_url="http://localhost:8000",api_key="sk-test-token",)res_remote = remote_selector.select(tools, "Query via remote server")@@ -389,7 +389,7 @@ with patch("urllib.request.build_opener") as mock_build_opener:# Check request headers and URLcall_args = mock_opener.open.call_argsreq = call_args[0][0]- check("remote/url", req.full_url, "https://api.laya.ai/v1/systemone")+ check("remote/url", req.full_url, "http://localhost:8000/v1/systemone")check("remote/auth", req.headers.get("Authorization"), "Bearer sk-test-token")