trustmodel 3.5.0__tar.gz → 3.7.0__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.
- {trustmodel-3.5.0 → trustmodel-3.7.0}/PKG-INFO +29 -4
- {trustmodel-3.5.0 → trustmodel-3.7.0}/README.md +28 -3
- {trustmodel-3.5.0 → trustmodel-3.7.0}/pyproject.toml +1 -1
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/evaluation.py +30 -1
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/telemetry/auto_init.py +76 -1
- {trustmodel-3.5.0 → trustmodel-3.7.0}/.gitignore +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/LICENSE +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/cli.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/client.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/compat.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/_runtime_transport.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/agentcert.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/agentic.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/batch_jobs.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/config.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/credits.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/evaluations.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/frameworks.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/galileo.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/guardrails.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/mcp_scanner.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/endpoints/models.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/exceptions.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/agentcert.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/agentic.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/batch_job.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/credits.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/frameworks.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/galileo.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/guardrails.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/mcp_scanner.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/models.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/models/oauth.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/oauth/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/oauth/auth.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/oauth/scopes.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/telemetry/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/telemetry/_constants.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/telemetry/_instrumentors.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/utils/__init__.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/utils/validation.py +0 -0
- {trustmodel-3.5.0 → trustmodel-3.7.0}/src/trustmodel/utils/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustmodel
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: Official Python SDK for TrustModel AI evaluation platform
|
|
5
5
|
Project-URL: Homepage, https://trustmodel.ai
|
|
6
6
|
Author-email: TrustModel <info@predixtions.com>
|
|
@@ -1275,11 +1275,33 @@ trace.set_tracer_provider(provider)
|
|
|
1275
1275
|
|
|
1276
1276
|
# Then add TrustModel — both backends now receive every span
|
|
1277
1277
|
from trustmodel.telemetry import auto_init
|
|
1278
|
-
auto_init(api_key="tm-...", agent_id="my-agent")
|
|
1278
|
+
auto_init(api_key="tm-...", agent_id="my-agent", domain="general_ai")
|
|
1279
1279
|
```
|
|
1280
1280
|
|
|
1281
1281
|
Spans fan out to both your existing exporter and TrustModel's. Nothing in your existing pipeline is modified or replaced.
|
|
1282
1282
|
|
|
1283
|
+
### Optional ServiceNow Observe Export
|
|
1284
|
+
|
|
1285
|
+
After the real vendor-instance OTLP endpoint and its authentication scheme have
|
|
1286
|
+
been verified, the same spans can be sent to ServiceNow Observe through a second,
|
|
1287
|
+
independent batch processor:
|
|
1288
|
+
|
|
1289
|
+
```python
|
|
1290
|
+
auto_init(
|
|
1291
|
+
api_key="tm-...",
|
|
1292
|
+
agent_id="my-agent",
|
|
1293
|
+
domain="general_ai",
|
|
1294
|
+
observe_endpoint="https://verified-instance.example/otlp/v1/traces",
|
|
1295
|
+
observe_headers={"Authorization": "Bearer <load-from-secret-store>"},
|
|
1296
|
+
observe_enabled=True,
|
|
1297
|
+
)
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
Observe export is disabled by default, even when an endpoint is supplied. The
|
|
1301
|
+
endpoint must use HTTPS, credentials must be provided as headers rather than URL
|
|
1302
|
+
userinfo, and header values are never logged. A collector setup failure leaves
|
|
1303
|
+
the TrustModel exporter active.
|
|
1304
|
+
|
|
1283
1305
|
### Parameters
|
|
1284
1306
|
|
|
1285
1307
|
| Parameter | Required | Description |
|
|
@@ -1287,8 +1309,11 @@ Spans fan out to both your existing exporter and TrustModel's. Nothing in your e
|
|
|
1287
1309
|
| `api_key` | yes | Your TrustModel API key (`tm-...`) |
|
|
1288
1310
|
| `agent_id` | yes | Any string you choose. All traces sharing this `agent_id` are grouped together for evaluation. |
|
|
1289
1311
|
| `domain` | yes | One of `fair_lending`, `hr_bias`, `healthcare`, `general_ai`. Determines which evaluators run. |
|
|
1290
|
-
| `frameworks` |
|
|
1312
|
+
| `frameworks` | no | List of compliance framework slugs (e.g., `["ecoa-regb", "fcra"]`). When omitted, active frameworks for the domain are resolved from the API. |
|
|
1291
1313
|
| `service_name` | no | Logical service name (default: `"default"`) |
|
|
1314
|
+
| `observe_endpoint` | no | Verified HTTPS OTLP/HTTP trace endpoint for ServiceNow Observe. |
|
|
1315
|
+
| `observe_headers` | no | Collector authentication headers loaded from your secret store. |
|
|
1316
|
+
| `observe_enabled` | no | Explicit dual-export opt-in; defaults to `False`. |
|
|
1292
1317
|
|
|
1293
1318
|
### Schedule and Evaluation
|
|
1294
1319
|
|
|
@@ -1820,4 +1845,4 @@ trustmodel certify helpbot.cisco.com --verify-only
|
|
|
1820
1845
|
|
|
1821
1846
|
This project is licensed under a proprietary license - see the [LICENSE](LICENSE) file for details.
|
|
1822
1847
|
|
|
1823
|
-
**Important**: This SDK is provided exclusively for use with TrustModel's official API services. Modification, redistribution, or reverse engineering is prohibited.
|
|
1848
|
+
**Important**: This SDK is provided exclusively for use with TrustModel's official API services. Modification, redistribution, or reverse engineering is prohibited.
|
|
@@ -1207,11 +1207,33 @@ trace.set_tracer_provider(provider)
|
|
|
1207
1207
|
|
|
1208
1208
|
# Then add TrustModel — both backends now receive every span
|
|
1209
1209
|
from trustmodel.telemetry import auto_init
|
|
1210
|
-
auto_init(api_key="tm-...", agent_id="my-agent")
|
|
1210
|
+
auto_init(api_key="tm-...", agent_id="my-agent", domain="general_ai")
|
|
1211
1211
|
```
|
|
1212
1212
|
|
|
1213
1213
|
Spans fan out to both your existing exporter and TrustModel's. Nothing in your existing pipeline is modified or replaced.
|
|
1214
1214
|
|
|
1215
|
+
### Optional ServiceNow Observe Export
|
|
1216
|
+
|
|
1217
|
+
After the real vendor-instance OTLP endpoint and its authentication scheme have
|
|
1218
|
+
been verified, the same spans can be sent to ServiceNow Observe through a second,
|
|
1219
|
+
independent batch processor:
|
|
1220
|
+
|
|
1221
|
+
```python
|
|
1222
|
+
auto_init(
|
|
1223
|
+
api_key="tm-...",
|
|
1224
|
+
agent_id="my-agent",
|
|
1225
|
+
domain="general_ai",
|
|
1226
|
+
observe_endpoint="https://verified-instance.example/otlp/v1/traces",
|
|
1227
|
+
observe_headers={"Authorization": "Bearer <load-from-secret-store>"},
|
|
1228
|
+
observe_enabled=True,
|
|
1229
|
+
)
|
|
1230
|
+
```
|
|
1231
|
+
|
|
1232
|
+
Observe export is disabled by default, even when an endpoint is supplied. The
|
|
1233
|
+
endpoint must use HTTPS, credentials must be provided as headers rather than URL
|
|
1234
|
+
userinfo, and header values are never logged. A collector setup failure leaves
|
|
1235
|
+
the TrustModel exporter active.
|
|
1236
|
+
|
|
1215
1237
|
### Parameters
|
|
1216
1238
|
|
|
1217
1239
|
| Parameter | Required | Description |
|
|
@@ -1219,8 +1241,11 @@ Spans fan out to both your existing exporter and TrustModel's. Nothing in your e
|
|
|
1219
1241
|
| `api_key` | yes | Your TrustModel API key (`tm-...`) |
|
|
1220
1242
|
| `agent_id` | yes | Any string you choose. All traces sharing this `agent_id` are grouped together for evaluation. |
|
|
1221
1243
|
| `domain` | yes | One of `fair_lending`, `hr_bias`, `healthcare`, `general_ai`. Determines which evaluators run. |
|
|
1222
|
-
| `frameworks` |
|
|
1244
|
+
| `frameworks` | no | List of compliance framework slugs (e.g., `["ecoa-regb", "fcra"]`). When omitted, active frameworks for the domain are resolved from the API. |
|
|
1223
1245
|
| `service_name` | no | Logical service name (default: `"default"`) |
|
|
1246
|
+
| `observe_endpoint` | no | Verified HTTPS OTLP/HTTP trace endpoint for ServiceNow Observe. |
|
|
1247
|
+
| `observe_headers` | no | Collector authentication headers loaded from your secret store. |
|
|
1248
|
+
| `observe_enabled` | no | Explicit dual-export opt-in; defaults to `False`. |
|
|
1224
1249
|
|
|
1225
1250
|
### Schedule and Evaluation
|
|
1226
1251
|
|
|
@@ -1752,4 +1777,4 @@ trustmodel certify helpbot.cisco.com --verify-only
|
|
|
1752
1777
|
|
|
1753
1778
|
This project is licensed under a proprietary license - see the [LICENSE](LICENSE) file for details.
|
|
1754
1779
|
|
|
1755
|
-
**Important**: This SDK is provided exclusively for use with TrustModel's official API services. Modification, redistribution, or reverse engineering is prohibited.
|
|
1780
|
+
**Important**: This SDK is provided exclusively for use with TrustModel's official API services. Modification, redistribution, or reverse engineering is prohibited.
|
|
@@ -58,8 +58,37 @@ class EvaluationScore(BaseModel):
|
|
|
58
58
|
"""Individual evaluation score for a category."""
|
|
59
59
|
|
|
60
60
|
category: str
|
|
61
|
-
|
|
61
|
+
# TRUS-1967 / TRUS-1977: `score` is Optional because a dimension may be
|
|
62
|
+
# *not assessed* — no source for it existed on this run — which is
|
|
63
|
+
# categorically different from a measured 0.0. Branch on
|
|
64
|
+
# `assessment_status`, never on falsiness of `score`: 0.0 is a real,
|
|
65
|
+
# measured, failing score and must not be confused with "no data".
|
|
66
|
+
#
|
|
67
|
+
# This was `float = Field(..., ge=0.0, le=100.0)` in every release up to
|
|
68
|
+
# and including 3.6.0, which raised ValidationError on a null.
|
|
69
|
+
score: Optional[float] = Field(
|
|
70
|
+
default=None,
|
|
71
|
+
ge=0.0,
|
|
72
|
+
le=100.0,
|
|
73
|
+
description=(
|
|
74
|
+
"Score between 0 and 100, or None when the dimension was not "
|
|
75
|
+
"assessed (see assessment_status). None is NOT equivalent to 0."
|
|
76
|
+
),
|
|
77
|
+
)
|
|
62
78
|
max_score: float = Field(default=1.0, description="Maximum possible score")
|
|
79
|
+
assessment_status: str = Field(
|
|
80
|
+
default="scored",
|
|
81
|
+
description=(
|
|
82
|
+
"'scored' when this dimension was measured (including a measured "
|
|
83
|
+
"0.0); 'not_assessed' when no source for it existed on this run, in "
|
|
84
|
+
"which case score is None. Defaults to 'scored' so responses from "
|
|
85
|
+
"gateways predating TRUS-1967 parse unchanged."
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
not_assessed_reason: Optional[str] = Field(
|
|
89
|
+
default=None,
|
|
90
|
+
description="Why the dimension was not assessed; None when scored.",
|
|
91
|
+
)
|
|
63
92
|
details: Optional[Dict[str, Any]] = Field(default=None, description="Additional score details")
|
|
64
93
|
|
|
65
94
|
|
|
@@ -13,7 +13,8 @@ from __future__ import annotations
|
|
|
13
13
|
import atexit
|
|
14
14
|
import logging
|
|
15
15
|
import uuid as _uuid
|
|
16
|
-
from typing import TYPE_CHECKING, Any, List, Optional
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple
|
|
17
|
+
from urllib.parse import urlsplit
|
|
17
18
|
|
|
18
19
|
if TYPE_CHECKING:
|
|
19
20
|
from opentelemetry.sdk.trace import TracerProvider as SDKTracerProvider
|
|
@@ -39,6 +40,9 @@ def auto_init(
|
|
|
39
40
|
service_name: str = "default",
|
|
40
41
|
environment: str = "production",
|
|
41
42
|
base_url: Optional[str] = None,
|
|
43
|
+
observe_endpoint: Optional[str] = None,
|
|
44
|
+
observe_headers: Optional[Mapping[str, str]] = None,
|
|
45
|
+
observe_enabled: bool = False,
|
|
42
46
|
) -> List[str]:
|
|
43
47
|
"""
|
|
44
48
|
Initialize automatic OTel trace capture and export to TrustModel.
|
|
@@ -63,6 +67,12 @@ def auto_init(
|
|
|
63
67
|
service_name: Logical service name for this application.
|
|
64
68
|
environment: One of 'local', 'qa', 'production'.
|
|
65
69
|
base_url: Explicit base URL (overrides environment).
|
|
70
|
+
observe_endpoint: Verified ServiceNow Observe OTLP/HTTP trace endpoint.
|
|
71
|
+
Supplying an endpoint alone does not enable export.
|
|
72
|
+
observe_headers: Authentication headers for the Observe collector. Values
|
|
73
|
+
are passed directly to the OTLP exporter and are never logged.
|
|
74
|
+
observe_enabled: Explicit opt-in for dual export. Keep ``False`` until the
|
|
75
|
+
vendor-instance endpoint and authentication have been verified.
|
|
66
76
|
|
|
67
77
|
Returns:
|
|
68
78
|
List of instrumentor names that were successfully installed.
|
|
@@ -115,6 +125,9 @@ def auto_init(
|
|
|
115
125
|
service_name,
|
|
116
126
|
environment,
|
|
117
127
|
base_url,
|
|
128
|
+
observe_endpoint,
|
|
129
|
+
observe_headers,
|
|
130
|
+
observe_enabled,
|
|
118
131
|
)
|
|
119
132
|
except Exception:
|
|
120
133
|
logger.debug("TrustModel telemetry: auto_init failed", exc_info=True)
|
|
@@ -160,6 +173,9 @@ def _do_init(
|
|
|
160
173
|
service_name: str,
|
|
161
174
|
environment: str,
|
|
162
175
|
base_url: Optional[str],
|
|
176
|
+
observe_endpoint: Optional[str] = None,
|
|
177
|
+
observe_headers: Optional[Mapping[str, str]] = None,
|
|
178
|
+
observe_enabled: bool = False,
|
|
163
179
|
) -> List[str]:
|
|
164
180
|
global _initialized, _tracer_provider
|
|
165
181
|
|
|
@@ -225,6 +241,37 @@ def _do_init(
|
|
|
225
241
|
_tracer_provider = provider
|
|
226
242
|
logger.debug("TrustModel telemetry: created new TracerProvider")
|
|
227
243
|
|
|
244
|
+
# TRUS-1325: fan out through an independent processor only after an
|
|
245
|
+
# operator explicitly enables a verified Observe collector. A collector
|
|
246
|
+
# setup error cannot remove or block the TrustModel processor above.
|
|
247
|
+
if observe_enabled:
|
|
248
|
+
try:
|
|
249
|
+
endpoint, headers = _validate_observe_configuration(
|
|
250
|
+
observe_endpoint,
|
|
251
|
+
observe_headers,
|
|
252
|
+
)
|
|
253
|
+
observe_exporter = OTLPSpanExporter(endpoint=endpoint, headers=headers)
|
|
254
|
+
wrapped_observe = _make_trustmodel_exporter(
|
|
255
|
+
observe_exporter,
|
|
256
|
+
agent_id,
|
|
257
|
+
session_id,
|
|
258
|
+
domain_str,
|
|
259
|
+
frameworks_str,
|
|
260
|
+
)
|
|
261
|
+
_tracer_provider.add_span_processor(BatchSpanProcessor(wrapped_observe))
|
|
262
|
+
logger.info("TrustModel telemetry: Observe dual export is active")
|
|
263
|
+
except Exception:
|
|
264
|
+
logger.warning(
|
|
265
|
+
"TrustModel telemetry: Observe exporter was not enabled; "
|
|
266
|
+
"TrustModel export remains active",
|
|
267
|
+
exc_info=True,
|
|
268
|
+
)
|
|
269
|
+
elif observe_endpoint or observe_headers:
|
|
270
|
+
logger.warning(
|
|
271
|
+
"TrustModel telemetry: Observe configuration supplied while "
|
|
272
|
+
"observe_enabled=False; dual export remains disabled"
|
|
273
|
+
)
|
|
274
|
+
|
|
228
275
|
# Auto-detect and install instrumentors
|
|
229
276
|
from ._instrumentors import install_instrumentors
|
|
230
277
|
|
|
@@ -243,6 +290,34 @@ def _do_init(
|
|
|
243
290
|
return installed
|
|
244
291
|
|
|
245
292
|
|
|
293
|
+
def _validate_observe_configuration(
|
|
294
|
+
endpoint: Optional[str],
|
|
295
|
+
headers: Optional[Mapping[str, str]],
|
|
296
|
+
) -> Tuple[str, Dict[str, str]]:
|
|
297
|
+
"""Validate the optional collector without exposing its credentials."""
|
|
298
|
+
if not endpoint:
|
|
299
|
+
raise ValueError("observe_endpoint is required when observe_enabled=True")
|
|
300
|
+
parsed = urlsplit(endpoint)
|
|
301
|
+
if parsed.scheme.lower() != "https" or not parsed.hostname:
|
|
302
|
+
raise ValueError("observe_endpoint must be an absolute HTTPS URL")
|
|
303
|
+
if parsed.username or parsed.password:
|
|
304
|
+
raise ValueError("observe_endpoint must not contain embedded credentials")
|
|
305
|
+
if parsed.fragment:
|
|
306
|
+
raise ValueError("observe_endpoint must not contain a URL fragment")
|
|
307
|
+
|
|
308
|
+
blocked = {"host", "content-length", "transfer-encoding", "connection"}
|
|
309
|
+
normalized: Dict[str, str] = {}
|
|
310
|
+
for raw_name, raw_value in (headers or {}).items():
|
|
311
|
+
name = str(raw_name).strip()
|
|
312
|
+
value = str(raw_value)
|
|
313
|
+
if not name or name.lower() in blocked:
|
|
314
|
+
raise ValueError("observe_headers contains a reserved header")
|
|
315
|
+
if "\r" in name or "\n" in name or "\r" in value or "\n" in value:
|
|
316
|
+
raise ValueError("observe_headers contains an invalid newline")
|
|
317
|
+
normalized[name] = value
|
|
318
|
+
return endpoint, normalized
|
|
319
|
+
|
|
320
|
+
|
|
246
321
|
def flush(
|
|
247
322
|
api_key: str,
|
|
248
323
|
*,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|