veratum 2.1.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.
- veratum-2.1.0/INTEGRATION_EXAMPLE.md +236 -0
- veratum-2.1.0/MANIFEST.in +7 -0
- veratum-2.1.0/PKG-INFO +380 -0
- veratum-2.1.0/README.md +328 -0
- veratum-2.1.0/pyproject.toml +86 -0
- veratum-2.1.0/setup.cfg +4 -0
- veratum-2.1.0/setup.py +55 -0
- veratum-2.1.0/veratum/__init__.py +121 -0
- veratum-2.1.0/veratum/bias.py +452 -0
- veratum-2.1.0/veratum/buffer.py +633 -0
- veratum-2.1.0/veratum/chain.py +172 -0
- veratum-2.1.0/veratum/crosswalk.py +666 -0
- veratum-2.1.0/veratum/evidence.py +687 -0
- veratum-2.1.0/veratum/instrument.py +494 -0
- veratum-2.1.0/veratum/integrations/__init__.py +12 -0
- veratum-2.1.0/veratum/merkle.py +372 -0
- veratum-2.1.0/veratum/prevention.py +920 -0
- veratum-2.1.0/veratum/privacy.py +372 -0
- veratum-2.1.0/veratum/receipt.py +415 -0
- veratum-2.1.0/veratum/sdk.py +839 -0
- veratum-2.1.0/veratum/signing.py +325 -0
- veratum-2.1.0/veratum/tiers.py +269 -0
- veratum-2.1.0/veratum/transparency.py +590 -0
- veratum-2.1.0/veratum/validation.py +356 -0
- veratum-2.1.0/veratum/verify.py +241 -0
- veratum-2.1.0/veratum/zk.py +694 -0
- veratum-2.1.0/veratum.egg-info/PKG-INFO +380 -0
- veratum-2.1.0/veratum.egg-info/SOURCES.txt +30 -0
- veratum-2.1.0/veratum.egg-info/dependency_links.txt +1 -0
- veratum-2.1.0/veratum.egg-info/not-zip-safe +1 -0
- veratum-2.1.0/veratum.egg-info/requires.txt +26 -0
- veratum-2.1.0/veratum.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Veratum SDK Integration Examples
|
|
2
|
+
|
|
3
|
+
## Basic Integration with Anthropic
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from veratum import VeratumSDK
|
|
7
|
+
import anthropic
|
|
8
|
+
|
|
9
|
+
# Initialize Veratum SDK
|
|
10
|
+
sdk = VeratumSDK(
|
|
11
|
+
endpoint="https://api.veratum.ai/v1",
|
|
12
|
+
api_key="vsk_your_api_key_here",
|
|
13
|
+
vertical="hiring"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Create Anthropic client
|
|
17
|
+
client = anthropic.Anthropic(api_key="sk_your_anthropic_key")
|
|
18
|
+
|
|
19
|
+
# Wrap the client - all calls are now audited
|
|
20
|
+
wrapped_client = sdk.wrap(client)
|
|
21
|
+
|
|
22
|
+
# Use as normal - receipts generated automatically
|
|
23
|
+
response = wrapped_client.messages.create(
|
|
24
|
+
model="claude-3-opus-20250219",
|
|
25
|
+
max_tokens=1024,
|
|
26
|
+
messages=[
|
|
27
|
+
{
|
|
28
|
+
"role": "user",
|
|
29
|
+
"content": "Evaluate this candidate profile..."
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Response is returned transparently
|
|
35
|
+
print(response.content[0].text)
|
|
36
|
+
|
|
37
|
+
# Cleanup
|
|
38
|
+
sdk.close()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Context Manager Pattern (Recommended)
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from veratum import VeratumSDK
|
|
45
|
+
import anthropic
|
|
46
|
+
|
|
47
|
+
with VeratumSDK(
|
|
48
|
+
endpoint="https://api.veratum.ai/v1",
|
|
49
|
+
api_key="vsk_your_api_key_here",
|
|
50
|
+
vertical="hiring"
|
|
51
|
+
) as sdk:
|
|
52
|
+
client = anthropic.Anthropic(api_key="sk_your_key")
|
|
53
|
+
wrapped_client = sdk.wrap(client)
|
|
54
|
+
|
|
55
|
+
response = wrapped_client.messages.create(
|
|
56
|
+
model="claude-3-opus-20250219",
|
|
57
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# SDK automatically cleaned up
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Multiple Clients
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from veratum import VeratumSDK
|
|
67
|
+
import anthropic
|
|
68
|
+
|
|
69
|
+
sdk = VeratumSDK(
|
|
70
|
+
endpoint="https://api.veratum.ai/v1",
|
|
71
|
+
api_key="vsk_your_api_key_here",
|
|
72
|
+
vertical="hiring"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Wrap multiple clients with same SDK
|
|
76
|
+
client1 = anthropic.Anthropic(api_key="sk_key1")
|
|
77
|
+
client2 = anthropic.Anthropic(api_key="sk_key2")
|
|
78
|
+
|
|
79
|
+
wrapped1 = sdk.wrap(client1)
|
|
80
|
+
wrapped2 = sdk.wrap(client2)
|
|
81
|
+
|
|
82
|
+
# All calls from both clients are audited
|
|
83
|
+
response1 = wrapped1.messages.create(
|
|
84
|
+
model="claude-3-opus-20250219",
|
|
85
|
+
messages=[{"role": "user", "content": "Request 1"}]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
response2 = wrapped2.messages.create(
|
|
89
|
+
model="claude-3-opus-20250219",
|
|
90
|
+
messages=[{"role": "user", "content": "Request 2"}]
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Checking Chain State
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from veratum import VeratumSDK
|
|
98
|
+
import anthropic
|
|
99
|
+
|
|
100
|
+
sdk = VeratumSDK(
|
|
101
|
+
endpoint="https://api.veratum.ai/v1",
|
|
102
|
+
api_key="vsk_your_api_key_here"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
client = anthropic.Anthropic(api_key="sk_...")
|
|
106
|
+
wrapped = sdk.wrap(client)
|
|
107
|
+
|
|
108
|
+
# Make some calls
|
|
109
|
+
for i in range(3):
|
|
110
|
+
wrapped.messages.create(
|
|
111
|
+
model="claude-3-opus-20250219",
|
|
112
|
+
messages=[{"role": "user", "content": f"Message {i}"}]
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Check chain integrity
|
|
116
|
+
state = sdk.get_chain_state()
|
|
117
|
+
print(f"Sequence number: {state['sequence_no']}") # 3
|
|
118
|
+
print(f"Previous hash: {state['prev_hash']}") # Last entry_hash
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Error Handling
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from veratum import VeratumSDK
|
|
125
|
+
import anthropic
|
|
126
|
+
|
|
127
|
+
sdk = VeratumSDK(
|
|
128
|
+
endpoint="https://api.veratum.ai/v1",
|
|
129
|
+
api_key="vsk_your_api_key_here"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
client = anthropic.Anthropic(api_key="sk_...")
|
|
133
|
+
wrapped = sdk.wrap(client)
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
response = wrapped.messages.create(
|
|
137
|
+
model="claude-3-opus-20250219",
|
|
138
|
+
messages=[{"role": "user", "content": "Test"}]
|
|
139
|
+
)
|
|
140
|
+
print("Response received and receipt uploaded")
|
|
141
|
+
except Exception as e:
|
|
142
|
+
# API call error - receipt may or may not have been created
|
|
143
|
+
print(f"Error: {e}")
|
|
144
|
+
finally:
|
|
145
|
+
sdk.close()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Environment Variables
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Set environment variables
|
|
152
|
+
export VERATUM_ENDPOINT="https://api.veratum.ai/v1"
|
|
153
|
+
export VERATUM_API_KEY="vsk_your_api_key"
|
|
154
|
+
export VERATUM_VERTICAL="hiring"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
import os
|
|
159
|
+
from veratum import VeratumSDK
|
|
160
|
+
import anthropic
|
|
161
|
+
|
|
162
|
+
# Load from environment
|
|
163
|
+
sdk = VeratumSDK(
|
|
164
|
+
endpoint=os.getenv("VERATUM_ENDPOINT"),
|
|
165
|
+
api_key=os.getenv("VERATUM_API_KEY"),
|
|
166
|
+
vertical=os.getenv("VERATUM_VERTICAL", "hiring")
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
client = anthropic.Anthropic()
|
|
170
|
+
wrapped = sdk.wrap(client)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Receipt Upload Details
|
|
174
|
+
|
|
175
|
+
When you call the wrapped client:
|
|
176
|
+
|
|
177
|
+
1. **Prompt Captured**: The input message is hashed (SHA256)
|
|
178
|
+
2. **API Called**: Original API call proceeds normally
|
|
179
|
+
3. **Response Captured**: Response text is hashed (SHA256)
|
|
180
|
+
4. **Receipt Generated**: Includes all Article 12 & ISO 24970 fields
|
|
181
|
+
5. **Chain Integrity**: Links to previous receipt via hash chain
|
|
182
|
+
6. **Upload**: Receipt posted to Veratum endpoint
|
|
183
|
+
7. **Return**: Original response returned transparently
|
|
184
|
+
|
|
185
|
+
All of this happens automatically without modifying your code!
|
|
186
|
+
|
|
187
|
+
## Vertical Classifications
|
|
188
|
+
|
|
189
|
+
Choose the appropriate vertical for your use case:
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
# Hiring/recruitment decisions
|
|
193
|
+
sdk = VeratumSDK(..., vertical="hiring")
|
|
194
|
+
|
|
195
|
+
# Lending/credit decisions
|
|
196
|
+
sdk = VeratumSDK(..., vertical="lending")
|
|
197
|
+
|
|
198
|
+
# Content moderation
|
|
199
|
+
sdk = VeratumSDK(..., vertical="content_moderation")
|
|
200
|
+
|
|
201
|
+
# Advertising/ad delivery
|
|
202
|
+
sdk = VeratumSDK(..., vertical="ad_delivery")
|
|
203
|
+
|
|
204
|
+
# Healthcare
|
|
205
|
+
sdk = VeratumSDK(..., vertical="healthcare")
|
|
206
|
+
|
|
207
|
+
# General purpose
|
|
208
|
+
sdk = VeratumSDK(..., vertical="general")
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Zero-Code Integration
|
|
212
|
+
|
|
213
|
+
The beauty of the Veratum SDK is that it requires zero changes to existing code:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
# Before: Regular Anthropic client
|
|
217
|
+
client = anthropic.Anthropic(api_key="sk_...")
|
|
218
|
+
response = client.messages.create(
|
|
219
|
+
model="claude-3-opus-20250219",
|
|
220
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# After: Just add 3 lines
|
|
224
|
+
from veratum import VeratumSDK
|
|
225
|
+
|
|
226
|
+
sdk = VeratumSDK(endpoint="...", api_key="...")
|
|
227
|
+
client = anthropic.Anthropic(api_key="sk_...")
|
|
228
|
+
client = sdk.wrap(client) # ← Add this one line!
|
|
229
|
+
|
|
230
|
+
response = client.messages.create(
|
|
231
|
+
model="claude-3-opus-20250219",
|
|
232
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Everything else stays the same!
|
|
236
|
+
```
|
veratum-2.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: veratum
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Litigation-grade evidence infrastructure for EU AI Act compliance
|
|
5
|
+
Home-page: https://github.com/veratum/sdk-python
|
|
6
|
+
Author: Ali Ashkir
|
|
7
|
+
Author-email: Ali Ashkir <ali@veratum.ai>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://veratum.ai
|
|
10
|
+
Project-URL: Documentation, https://docs.veratum.ai
|
|
11
|
+
Project-URL: Repository, https://github.com/veratum/sdk-python
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/veratum/sdk-python/issues
|
|
13
|
+
Keywords: audit,AI,accountability,transparency,compliance,evidence,blockchain,xrpl
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Office/Business
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: requests>=2.28.0
|
|
30
|
+
Provides-Extra: zk
|
|
31
|
+
Requires-Dist: ezkl>=15.0.0; extra == "zk"
|
|
32
|
+
Provides-Extra: litellm
|
|
33
|
+
Requires-Dist: litellm>=1.0; extra == "litellm"
|
|
34
|
+
Provides-Extra: portkey
|
|
35
|
+
Requires-Dist: portkey-ai>=1.0; extra == "portkey"
|
|
36
|
+
Provides-Extra: mcp
|
|
37
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: ezkl>=15.0.0; extra == "all"
|
|
40
|
+
Requires-Dist: litellm>=1.0; extra == "all"
|
|
41
|
+
Requires-Dist: portkey-ai>=1.0; extra == "all"
|
|
42
|
+
Requires-Dist: mcp>=1.0; extra == "all"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
46
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
47
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
48
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
49
|
+
Dynamic: author
|
|
50
|
+
Dynamic: home-page
|
|
51
|
+
Dynamic: requires-python
|
|
52
|
+
|
|
53
|
+
# Veratum SDK for Python
|
|
54
|
+
|
|
55
|
+
Production-grade SDK for AI auditability and accountability, with full compliance to Article 12 of the EU AI Act and ISO 24970 standards.
|
|
56
|
+
|
|
57
|
+
## Overview
|
|
58
|
+
|
|
59
|
+
The Veratum SDK provides seamless integration with AI model providers (starting with Anthropic) to capture, audit, and verify all interactions. Each interaction generates a cryptographically-signed receipt with full chain integrity, enabling transparent and accountable AI systems.
|
|
60
|
+
|
|
61
|
+
**Key Features:**
|
|
62
|
+
- Transparent prompt/response capture
|
|
63
|
+
- Automatic receipt generation with chain integrity
|
|
64
|
+
- Article 12 & ISO 24970 compliance fields
|
|
65
|
+
- Secure hash chain linking
|
|
66
|
+
- Blockchain-ready architecture
|
|
67
|
+
- Zero-friction client wrapping
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install veratum-sdk
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
### Basic Usage with Anthropic
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from veratum import VeratumSDK
|
|
81
|
+
import anthropic
|
|
82
|
+
|
|
83
|
+
# Initialize Veratum SDK
|
|
84
|
+
sdk = VeratumSDK(
|
|
85
|
+
endpoint="https://api.veratum.ai/v1",
|
|
86
|
+
api_key="vsk_your_api_key_here",
|
|
87
|
+
vertical="hiring"
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Create Anthropic client
|
|
91
|
+
client = anthropic.Anthropic(api_key="sk_your_key_here")
|
|
92
|
+
|
|
93
|
+
# Wrap the client - all calls are now audited
|
|
94
|
+
wrapped_client = sdk.wrap(client)
|
|
95
|
+
|
|
96
|
+
# Use as normal - receipts generated automatically
|
|
97
|
+
response = wrapped_client.messages.create(
|
|
98
|
+
model="claude-3-opus-20250219",
|
|
99
|
+
max_tokens=1024,
|
|
100
|
+
messages=[
|
|
101
|
+
{
|
|
102
|
+
"role": "user",
|
|
103
|
+
"content": "What are the key responsibilities of a product manager?"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
print(response.content[0].text)
|
|
109
|
+
|
|
110
|
+
# Cleanup
|
|
111
|
+
sdk.close()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Context Manager Usage
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from veratum import VeratumSDK
|
|
118
|
+
import anthropic
|
|
119
|
+
|
|
120
|
+
with VeratumSDK(
|
|
121
|
+
endpoint="https://api.veratum.ai/v1",
|
|
122
|
+
api_key="vsk_...",
|
|
123
|
+
vertical="hiring"
|
|
124
|
+
) as sdk:
|
|
125
|
+
client = anthropic.Anthropic(api_key="sk_...")
|
|
126
|
+
wrapped_client = sdk.wrap(client)
|
|
127
|
+
|
|
128
|
+
response = wrapped_client.messages.create(
|
|
129
|
+
model="claude-3-opus-20250219",
|
|
130
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## How It Works
|
|
135
|
+
|
|
136
|
+
### 1. Transparent Interception
|
|
137
|
+
|
|
138
|
+
The SDK monkey-patches the client's `messages.create()` method to intercept all API calls without requiring code changes:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
# The wrapper is transparent - code works identically
|
|
142
|
+
response = wrapped_client.messages.create(...) # Receipt generated automatically
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 2. Receipt Generation
|
|
146
|
+
|
|
147
|
+
For each interaction, the SDK generates a receipt containing:
|
|
148
|
+
|
|
149
|
+
**Core Fields:**
|
|
150
|
+
- `schema_version`: Receipt schema version
|
|
151
|
+
- `entry_hash`: SHA256 hash of canonical receipt JSON
|
|
152
|
+
- `prev_hash`: Link to previous receipt (chain integrity)
|
|
153
|
+
- `sequence_no`: Monotonically increasing sequence number
|
|
154
|
+
- `timestamp`: UTC ISO 8601 timestamp
|
|
155
|
+
|
|
156
|
+
**Interaction Data:**
|
|
157
|
+
- `prompt_hash`: SHA256 of input prompt
|
|
158
|
+
- `response_hash`: SHA256 of model response
|
|
159
|
+
- `model`: Model identifier used
|
|
160
|
+
- `provider`: Provider name (e.g., "anthropic")
|
|
161
|
+
- `tokens_in`: Input tokens consumed
|
|
162
|
+
- `tokens_out`: Output tokens generated
|
|
163
|
+
|
|
164
|
+
**Article 12 & ISO 24970 Compliance:**
|
|
165
|
+
- `decision_type`: Classification of decision
|
|
166
|
+
- `vertical`: Industry vertical (hiring, lending, content_moderation, etc.)
|
|
167
|
+
- `ai_score`: Model confidence/prediction score
|
|
168
|
+
- `ai_threshold`: Decision threshold
|
|
169
|
+
- `recruiter_action`: Action taken by human reviewer
|
|
170
|
+
- `human_review_state`: Status of human review
|
|
171
|
+
- `reviewer_id`: ID of human reviewer
|
|
172
|
+
- `override_reason`: Reason for any manual override
|
|
173
|
+
|
|
174
|
+
**Blockchain Integration:**
|
|
175
|
+
- `xrpl_tx_hash`: XRPL transaction hash (populated by backend)
|
|
176
|
+
- `signature`: Digital signature (populated by backend)
|
|
177
|
+
|
|
178
|
+
### 3. Chain Integrity
|
|
179
|
+
|
|
180
|
+
Receipts form a cryptographic hash chain:
|
|
181
|
+
|
|
182
|
+
- **Genesis Receipt**: `prev_hash = "0"*64`, `sequence_no = 0`
|
|
183
|
+
- **Each Receipt**: `prev_hash` points to previous receipt's `entry_hash`
|
|
184
|
+
- **Verification**: Each receipt can be verified to ensure:
|
|
185
|
+
- Correct entry_hash computation
|
|
186
|
+
- Proper linkage to previous receipt
|
|
187
|
+
- No tampering or reordering
|
|
188
|
+
|
|
189
|
+
### 4. Automatic Upload
|
|
190
|
+
|
|
191
|
+
Each receipt is immediately uploaded to the Veratum endpoint for:
|
|
192
|
+
- Secure storage
|
|
193
|
+
- Blockchain recording (via XRPL)
|
|
194
|
+
- Chain verification
|
|
195
|
+
- Compliance auditing
|
|
196
|
+
|
|
197
|
+
## Architecture
|
|
198
|
+
|
|
199
|
+
### Core Classes
|
|
200
|
+
|
|
201
|
+
#### `VeratumSDK`
|
|
202
|
+
Main SDK class for initialization and client wrapping.
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
sdk = VeratumSDK(
|
|
206
|
+
endpoint="https://api.veratum.ai/v1", # Veratum endpoint
|
|
207
|
+
api_key="vsk_...", # Your API key
|
|
208
|
+
vertical="hiring", # Industry classification
|
|
209
|
+
timeout=30.0 # Request timeout
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Wrap any compatible client
|
|
213
|
+
wrapped = sdk.wrap(client)
|
|
214
|
+
|
|
215
|
+
# Get current chain state
|
|
216
|
+
state = sdk.get_chain_state()
|
|
217
|
+
# {"sequence_no": 5, "prev_hash": "abc123..."}
|
|
218
|
+
|
|
219
|
+
# Reset chain (dev/testing only)
|
|
220
|
+
sdk.reset_chain()
|
|
221
|
+
|
|
222
|
+
# Cleanup resources
|
|
223
|
+
sdk.close()
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### `Receipt`
|
|
227
|
+
Generates audit receipts with full compliance.
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from veratum import Receipt, HashChain
|
|
231
|
+
|
|
232
|
+
chain = HashChain()
|
|
233
|
+
receipt_gen = Receipt(chain)
|
|
234
|
+
|
|
235
|
+
receipt = receipt_gen.generate(
|
|
236
|
+
prompt="What is the capital of France?",
|
|
237
|
+
response="The capital of France is Paris.",
|
|
238
|
+
model="claude-3-opus-20250219",
|
|
239
|
+
provider="anthropic",
|
|
240
|
+
tokens_in=12,
|
|
241
|
+
tokens_out=8,
|
|
242
|
+
decision_type="informational",
|
|
243
|
+
vertical="hiring",
|
|
244
|
+
ai_score=0.95,
|
|
245
|
+
ai_threshold=0.8
|
|
246
|
+
)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### `HashChain`
|
|
250
|
+
Manages cryptographic chain integrity.
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
from veratum import HashChain
|
|
254
|
+
|
|
255
|
+
chain = HashChain()
|
|
256
|
+
|
|
257
|
+
# Compute entry hash (excludes entry_hash, xrpl_tx_hash, signature)
|
|
258
|
+
entry_hash = chain.compute_entry_hash(receipt_dict)
|
|
259
|
+
|
|
260
|
+
# Advance chain
|
|
261
|
+
chain.advance_chain(receipt_dict)
|
|
262
|
+
|
|
263
|
+
# Get state
|
|
264
|
+
state = chain.get_chain_state()
|
|
265
|
+
# {"sequence_no": 1, "prev_hash": "abc123..."}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Configuration
|
|
269
|
+
|
|
270
|
+
### Environment Variables
|
|
271
|
+
|
|
272
|
+
You can configure via environment variables:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
export VERATUM_ENDPOINT="https://api.veratum.ai/v1"
|
|
276
|
+
export VERATUM_API_KEY="vsk_..."
|
|
277
|
+
export VERATUM_VERTICAL="hiring"
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Then initialize with minimal config:
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
from veratum import VeratumSDK
|
|
284
|
+
import os
|
|
285
|
+
|
|
286
|
+
sdk = VeratumSDK(
|
|
287
|
+
endpoint=os.getenv("VERATUM_ENDPOINT"),
|
|
288
|
+
api_key=os.getenv("VERATUM_API_KEY"),
|
|
289
|
+
vertical=os.getenv("VERATUM_VERTICAL", "hiring")
|
|
290
|
+
)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Vertical Classifications
|
|
294
|
+
|
|
295
|
+
Supported industry verticals:
|
|
296
|
+
- `hiring`: Recruitment and hiring decisions
|
|
297
|
+
- `lending`: Loan and credit decisions
|
|
298
|
+
- `content_moderation`: Content review and moderation
|
|
299
|
+
- `ad_delivery`: Advertisement targeting
|
|
300
|
+
- `healthcare`: Medical decision support
|
|
301
|
+
- `general`: General-purpose applications
|
|
302
|
+
|
|
303
|
+
## Compliance
|
|
304
|
+
|
|
305
|
+
### Article 12 - EU AI Act
|
|
306
|
+
|
|
307
|
+
The SDK automatically captures and documents:
|
|
308
|
+
- Training data used
|
|
309
|
+
- Testing and validation results
|
|
310
|
+
- Performance metrics
|
|
311
|
+
- Human oversight procedures
|
|
312
|
+
- Decision documentation
|
|
313
|
+
|
|
314
|
+
### ISO 24970 - AI Auditability
|
|
315
|
+
|
|
316
|
+
Receipts include:
|
|
317
|
+
- Complete audit trail with timestamps
|
|
318
|
+
- Cryptographic integrity verification
|
|
319
|
+
- Immutable record linkage
|
|
320
|
+
- Provider identification
|
|
321
|
+
- Model identification
|
|
322
|
+
- Decision reasoning information
|
|
323
|
+
|
|
324
|
+
## Error Handling
|
|
325
|
+
|
|
326
|
+
The SDK is designed to be resilient:
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
# Receipt failures don't break the application
|
|
330
|
+
try:
|
|
331
|
+
response = wrapped_client.messages.create(...)
|
|
332
|
+
except Exception as e:
|
|
333
|
+
# Application continues even if receipt upload fails
|
|
334
|
+
print(f"API call succeeded, but receipt upload may have failed: {e}")
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Performance Considerations
|
|
338
|
+
|
|
339
|
+
- **Transparent**: No latency added to API calls
|
|
340
|
+
- **Asynchronous Upload**: Receipts uploaded in background
|
|
341
|
+
- **Timeout Handling**: 30-second default timeout for receipt uploads
|
|
342
|
+
- **Error Recovery**: Failed uploads logged but don't block responses
|
|
343
|
+
|
|
344
|
+
## Testing
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Install dev dependencies
|
|
348
|
+
pip install veratum-sdk[dev]
|
|
349
|
+
|
|
350
|
+
# Run tests
|
|
351
|
+
pytest
|
|
352
|
+
|
|
353
|
+
# Check types
|
|
354
|
+
mypy veratum/
|
|
355
|
+
|
|
356
|
+
# Format code
|
|
357
|
+
black veratum/
|
|
358
|
+
|
|
359
|
+
# Lint
|
|
360
|
+
ruff check veratum/
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Security
|
|
364
|
+
|
|
365
|
+
- All communication uses HTTPS with Bearer token authentication
|
|
366
|
+
- Prompts and responses are hashed (SHA256), not stored
|
|
367
|
+
- Signatures use cryptographic signing (provided by backend)
|
|
368
|
+
- Chain integrity prevents tampering
|
|
369
|
+
- No sensitive data in logs
|
|
370
|
+
|
|
371
|
+
## Support
|
|
372
|
+
|
|
373
|
+
For issues, questions, or feedback:
|
|
374
|
+
- Documentation: https://docs.veratum.ai
|
|
375
|
+
- Email: team@veratum.ai
|
|
376
|
+
- GitHub: https://github.com/veratum/sdk-python
|
|
377
|
+
|
|
378
|
+
## License
|
|
379
|
+
|
|
380
|
+
MIT License - See LICENSE file for details
|