volidator-python 0.1.0__py3-none-any.whl
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.
- volidator/__init__.py +5 -0
- volidator/agent.py +137 -0
- volidator/client.py +1129 -0
- volidator/compliance.py +70 -0
- volidator/plugins/__init__.py +1 -0
- volidator/plugins/langchain.py +115 -0
- volidator/plugins/llamaindex.py +96 -0
- volidator_python-0.1.0.dist-info/METADATA +102 -0
- volidator_python-0.1.0.dist-info/RECORD +11 -0
- volidator_python-0.1.0.dist-info/WHEEL +5 -0
- volidator_python-0.1.0.dist-info/top_level.txt +1 -0
volidator/__init__.py
ADDED
volidator/agent.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class VolidatorAgent:
|
|
5
|
+
def __init__(self, client):
|
|
6
|
+
self.client = client
|
|
7
|
+
|
|
8
|
+
def _log_agent(
|
|
9
|
+
self,
|
|
10
|
+
action: str,
|
|
11
|
+
eu_ai_act: str,
|
|
12
|
+
nist_ai_rmf: str,
|
|
13
|
+
soc2_control: str,
|
|
14
|
+
iso_control: str,
|
|
15
|
+
payload: dict[str, Any]
|
|
16
|
+
) -> bool:
|
|
17
|
+
core_fields = {
|
|
18
|
+
"actor",
|
|
19
|
+
"actorId",
|
|
20
|
+
"target",
|
|
21
|
+
"targetId",
|
|
22
|
+
"tenant",
|
|
23
|
+
"tenantId",
|
|
24
|
+
"metadata",
|
|
25
|
+
"context",
|
|
26
|
+
"telemetry",
|
|
27
|
+
"req",
|
|
28
|
+
"traceId",
|
|
29
|
+
"spanId",
|
|
30
|
+
"parentSpanId",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Enriched metadata includes any additional keyword args passed at root level
|
|
34
|
+
agent_data = {k: v for k, v in payload.items() if k not in core_fields}
|
|
35
|
+
metadata = payload.get("metadata") or {}
|
|
36
|
+
|
|
37
|
+
enriched_metadata = {
|
|
38
|
+
**metadata,
|
|
39
|
+
**agent_data,
|
|
40
|
+
"eu_ai_act": eu_ai_act,
|
|
41
|
+
"nist_ai_rmf": nist_ai_rmf,
|
|
42
|
+
"soc2_control": soc2_control,
|
|
43
|
+
"iso27001": iso_control,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Build base payload structure
|
|
47
|
+
base_payload = {k: v for k, v in payload.items() if k in core_fields}
|
|
48
|
+
base_payload["action"] = action
|
|
49
|
+
base_payload["metadata"] = enriched_metadata
|
|
50
|
+
|
|
51
|
+
# AI logs have a larger 5MB metadata allowance
|
|
52
|
+
return self.client.log(base_payload, max_meta_override=5242880)
|
|
53
|
+
|
|
54
|
+
async def _log_agent_async(
|
|
55
|
+
self,
|
|
56
|
+
action: str,
|
|
57
|
+
eu_ai_act: str,
|
|
58
|
+
nist_ai_rmf: str,
|
|
59
|
+
soc2_control: str,
|
|
60
|
+
iso_control: str,
|
|
61
|
+
payload: dict[str, Any]
|
|
62
|
+
) -> bool:
|
|
63
|
+
core_fields = {
|
|
64
|
+
"actor",
|
|
65
|
+
"actorId",
|
|
66
|
+
"target",
|
|
67
|
+
"targetId",
|
|
68
|
+
"tenant",
|
|
69
|
+
"tenantId",
|
|
70
|
+
"metadata",
|
|
71
|
+
"context",
|
|
72
|
+
"telemetry",
|
|
73
|
+
"req",
|
|
74
|
+
"traceId",
|
|
75
|
+
"spanId",
|
|
76
|
+
"parentSpanId",
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
agent_data = {k: v for k, v in payload.items() if k not in core_fields}
|
|
80
|
+
metadata = payload.get("metadata") or {}
|
|
81
|
+
|
|
82
|
+
enriched_metadata = {
|
|
83
|
+
**metadata,
|
|
84
|
+
**agent_data,
|
|
85
|
+
"eu_ai_act": eu_ai_act,
|
|
86
|
+
"nist_ai_rmf": nist_ai_rmf,
|
|
87
|
+
"soc2_control": soc2_control,
|
|
88
|
+
"iso27001": iso_control,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
base_payload = {k: v for k, v in payload.items() if k in core_fields}
|
|
92
|
+
base_payload["action"] = action
|
|
93
|
+
base_payload["metadata"] = enriched_metadata
|
|
94
|
+
|
|
95
|
+
return await self.client.log_async(base_payload, max_meta_override=5242880)
|
|
96
|
+
|
|
97
|
+
# 1. tool_call / tool_call_async
|
|
98
|
+
def tool_call(self, payload: dict[str, Any]) -> bool:
|
|
99
|
+
return self._log_agent("agent.tool_call", "Article 12", "MANAGE 2.2", "CC6.6", "A.12.4.1", payload)
|
|
100
|
+
|
|
101
|
+
async def tool_call_async(self, payload: dict[str, Any]) -> bool:
|
|
102
|
+
return await self._log_agent_async("agent.tool_call", "Article 12", "MANAGE 2.2", "CC6.6", "A.12.4.1", payload)
|
|
103
|
+
|
|
104
|
+
# 2. decision / decision_async
|
|
105
|
+
def decision(self, payload: dict[str, Any]) -> bool:
|
|
106
|
+
return self._log_agent("agent.decision", "Article 12 & 13", "GOVERN 1.7", "CC6.2", "A.18.1.3", payload)
|
|
107
|
+
|
|
108
|
+
async def decision_async(self, payload: dict[str, Any]) -> bool:
|
|
109
|
+
return await self._log_agent_async("agent.decision", "Article 12 & 13", "GOVERN 1.7", "CC6.2", "A.18.1.3", payload)
|
|
110
|
+
|
|
111
|
+
# 3. escalation / escalation_async
|
|
112
|
+
def escalation(self, payload: dict[str, Any]) -> bool:
|
|
113
|
+
return self._log_agent("agent.escalation", "Article 14", "GOVERN 5.1", "CC6.3", "A.6.1.2", payload)
|
|
114
|
+
|
|
115
|
+
async def escalation_async(self, payload: dict[str, Any]) -> bool:
|
|
116
|
+
return await self._log_agent_async("agent.escalation", "Article 14", "GOVERN 5.1", "CC6.3", "A.6.1.2", payload)
|
|
117
|
+
|
|
118
|
+
# 4. anomaly / anomaly_async
|
|
119
|
+
def anomaly(self, payload: dict[str, Any]) -> bool:
|
|
120
|
+
return self._log_agent("agent.anomaly", "Article 9", "MANAGE 2.4", "CC7.2", "A.16.1.2", payload)
|
|
121
|
+
|
|
122
|
+
async def anomaly_async(self, payload: dict[str, Any]) -> bool:
|
|
123
|
+
return await self._log_agent_async("agent.anomaly", "Article 9", "MANAGE 2.4", "CC7.2", "A.16.1.2", payload)
|
|
124
|
+
|
|
125
|
+
# 5. refusal / refusal_async
|
|
126
|
+
def refusal(self, payload: dict[str, Any]) -> bool:
|
|
127
|
+
return self._log_agent("agent.refusal", "Article 5", "GOVERN 1.1", "CC6.8", "A.18.1.3", payload)
|
|
128
|
+
|
|
129
|
+
async def refusal_async(self, payload: dict[str, Any]) -> bool:
|
|
130
|
+
return await self._log_agent_async("agent.refusal", "Article 5", "GOVERN 1.1", "CC6.8", "A.18.1.3", payload)
|
|
131
|
+
|
|
132
|
+
# 6. handoff / handoff_async
|
|
133
|
+
def handoff(self, payload: dict[str, Any]) -> bool:
|
|
134
|
+
return self._log_agent("agent.handoff", "Article 12", "MAP 1.6", "CC6.6", "A.12.4.1", payload)
|
|
135
|
+
|
|
136
|
+
async def handoff_async(self, payload: dict[str, Any]) -> bool:
|
|
137
|
+
return await self._log_agent_async("agent.handoff", "Article 12", "MAP 1.6", "CC6.6", "A.12.4.1", payload)
|