trustgraph-laya 2.10.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trustgraph_laya-2.10.17/PKG-INFO +16 -0
- trustgraph_laya-2.10.17/pyproject.toml +35 -0
- trustgraph_laya-2.10.17/setup.cfg +4 -0
- trustgraph_laya-2.10.17/trustgraph/__init__.py +1 -0
- trustgraph_laya-2.10.17/trustgraph/laya_version.py +1 -0
- trustgraph_laya-2.10.17/trustgraph/model/__init__.py +1 -0
- trustgraph_laya-2.10.17/trustgraph/model/decision_scoring/__init__.py +1 -0
- trustgraph_laya-2.10.17/trustgraph/model/decision_scoring/laya/__init__.py +2 -0
- trustgraph_laya-2.10.17/trustgraph/model/decision_scoring/laya/__main__.py +6 -0
- trustgraph_laya-2.10.17/trustgraph/model/decision_scoring/laya/service.py +132 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/PKG-INFO +16 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/SOURCES.txt +14 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/dependency_links.txt +1 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/entry_points.txt +2 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/requires.txt +6 -0
- trustgraph_laya-2.10.17/trustgraph_laya.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trustgraph-laya
|
|
3
|
+
Version: 2.10.17
|
|
4
|
+
Summary: Laya decision-scoring service for TrustGraph.
|
|
5
|
+
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
|
6
|
+
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: trustgraph-base<2.11,>=2.10
|
|
12
|
+
Requires-Dist: trustgraph-flow<2.11,>=2.10
|
|
13
|
+
Requires-Dist: laya
|
|
14
|
+
Requires-Dist: pulsar-client
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Requires-Dist: prometheus-client
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "trustgraph-laya"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
authors = [{name = "trustgraph.ai", email = "security@trustgraph.ai"}]
|
|
9
|
+
description = "Laya decision-scoring service for TrustGraph."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"trustgraph-base>=2.10,<2.11",
|
|
14
|
+
"trustgraph-flow>=2.10,<2.11",
|
|
15
|
+
"laya",
|
|
16
|
+
"pulsar-client",
|
|
17
|
+
"pyyaml",
|
|
18
|
+
"prometheus-client",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/trustgraph-ai/trustgraph"
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
decision-scoring-laya = "trustgraph.model.decision_scoring.laya:run"
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
include = ["trustgraph*"]
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.dynamic]
|
|
35
|
+
version = {attr = "trustgraph.laya_version.__version__"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.10.17"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
Decision scoring service using Laya. Provides fast, structured
|
|
4
|
+
decision-making with three output types: choice, score, and noul.
|
|
5
|
+
Input is state + questions specification, output is answers with
|
|
6
|
+
confidence scores.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
from .... base import FlowProcessor, ConsumerSpec, ProducerSpec
|
|
13
|
+
from .... base import ParameterSpec
|
|
14
|
+
from .... schema import DecisionScoringRequest, DecisionScoringResponse
|
|
15
|
+
from .... schema import Error
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
default_ident = "decision-scoring"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Processor(FlowProcessor):
|
|
23
|
+
|
|
24
|
+
def __init__(self, **params):
|
|
25
|
+
|
|
26
|
+
model = params.get("model")
|
|
27
|
+
|
|
28
|
+
init_params = params
|
|
29
|
+
if model:
|
|
30
|
+
init_params = params | {"model": model}
|
|
31
|
+
|
|
32
|
+
super(Processor, self).__init__(**init_params)
|
|
33
|
+
|
|
34
|
+
self.model_override = model
|
|
35
|
+
|
|
36
|
+
self.register_specification(
|
|
37
|
+
ParameterSpec(name="model")
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
self.register_specification(
|
|
41
|
+
ConsumerSpec(
|
|
42
|
+
name="request",
|
|
43
|
+
schema=DecisionScoringRequest,
|
|
44
|
+
handler=self.on_request,
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
self.register_specification(
|
|
49
|
+
ProducerSpec(
|
|
50
|
+
name="response",
|
|
51
|
+
schema=DecisionScoringResponse,
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
self.router = None
|
|
56
|
+
|
|
57
|
+
async def start(self):
|
|
58
|
+
|
|
59
|
+
from laya import Router
|
|
60
|
+
|
|
61
|
+
logger.info("Loading Laya router with preloaded checkpoints...")
|
|
62
|
+
loop = asyncio.get_event_loop()
|
|
63
|
+
self.router = await loop.run_in_executor(
|
|
64
|
+
None, lambda: Router(preload=True)
|
|
65
|
+
)
|
|
66
|
+
logger.info("Laya router loaded successfully")
|
|
67
|
+
|
|
68
|
+
await super().start()
|
|
69
|
+
|
|
70
|
+
async def on_request(self, msg, consumer, flow):
|
|
71
|
+
|
|
72
|
+
request = msg.value()
|
|
73
|
+
id = msg.properties()["id"]
|
|
74
|
+
producer = flow("response")
|
|
75
|
+
|
|
76
|
+
model = flow("model") or self.model_override
|
|
77
|
+
|
|
78
|
+
if self.router is None:
|
|
79
|
+
response = DecisionScoringResponse(
|
|
80
|
+
error=Error(
|
|
81
|
+
type="not-ready",
|
|
82
|
+
message="Laya router is still loading",
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
await producer.send(response, properties={"id": id})
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
|
|
90
|
+
kwargs = {}
|
|
91
|
+
if model:
|
|
92
|
+
kwargs["model"] = model
|
|
93
|
+
|
|
94
|
+
result = self.router.predict(
|
|
95
|
+
request.state, request.questions, **kwargs
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
answers = result.get("answers", {})
|
|
99
|
+
routing = result.get("routing", {})
|
|
100
|
+
model_used = routing.get("model", "")
|
|
101
|
+
|
|
102
|
+
response = DecisionScoringResponse(
|
|
103
|
+
answers=answers,
|
|
104
|
+
model=model_used,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
except Exception as e:
|
|
108
|
+
logger.error(f"Decision scoring error: {e}")
|
|
109
|
+
response = DecisionScoringResponse(
|
|
110
|
+
error=Error(
|
|
111
|
+
type="decision-scoring-error",
|
|
112
|
+
message=str(e),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
await producer.send(response, properties={"id": id})
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def add_args(parser):
|
|
120
|
+
|
|
121
|
+
FlowProcessor.add_args(parser)
|
|
122
|
+
|
|
123
|
+
parser.add_argument(
|
|
124
|
+
'-m', '--model',
|
|
125
|
+
default=None,
|
|
126
|
+
help='Laya model override (default: auto-route by language)'
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def run():
|
|
131
|
+
|
|
132
|
+
Processor.launch(default_ident, __doc__)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trustgraph-laya
|
|
3
|
+
Version: 2.10.17
|
|
4
|
+
Summary: Laya decision-scoring service for TrustGraph.
|
|
5
|
+
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
|
6
|
+
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: trustgraph-base<2.11,>=2.10
|
|
12
|
+
Requires-Dist: trustgraph-flow<2.11,>=2.10
|
|
13
|
+
Requires-Dist: laya
|
|
14
|
+
Requires-Dist: pulsar-client
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Requires-Dist: prometheus-client
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
trustgraph/__init__.py
|
|
3
|
+
trustgraph/laya_version.py
|
|
4
|
+
trustgraph/model/__init__.py
|
|
5
|
+
trustgraph/model/decision_scoring/__init__.py
|
|
6
|
+
trustgraph/model/decision_scoring/laya/__init__.py
|
|
7
|
+
trustgraph/model/decision_scoring/laya/__main__.py
|
|
8
|
+
trustgraph/model/decision_scoring/laya/service.py
|
|
9
|
+
trustgraph_laya.egg-info/PKG-INFO
|
|
10
|
+
trustgraph_laya.egg-info/SOURCES.txt
|
|
11
|
+
trustgraph_laya.egg-info/dependency_links.txt
|
|
12
|
+
trustgraph_laya.egg-info/entry_points.txt
|
|
13
|
+
trustgraph_laya.egg-info/requires.txt
|
|
14
|
+
trustgraph_laya.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
trustgraph
|