memoryintelligence 1.0.1__tar.gz → 2.0.1__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.
- memoryintelligence-2.0.1/CHANGELOG.md +242 -0
- memoryintelligence-2.0.1/PKG-INFO +317 -0
- memoryintelligence-2.0.1/README.md +282 -0
- memoryintelligence-2.0.1/memoryintelligence/__init__.py +205 -0
- memoryintelligence-2.0.1/memoryintelligence/_async_client.py +599 -0
- memoryintelligence-2.0.1/memoryintelligence/_auth.py +305 -0
- memoryintelligence-2.0.1/memoryintelligence/_client.py +972 -0
- memoryintelligence-2.0.1/memoryintelligence/_crypto.py +414 -0
- memoryintelligence-2.0.1/memoryintelligence/_edge_client.py +362 -0
- memoryintelligence-2.0.1/memoryintelligence/_errors.py +232 -0
- memoryintelligence-2.0.1/memoryintelligence/_http.py +400 -0
- memoryintelligence-2.0.1/memoryintelligence/_license.py +543 -0
- memoryintelligence-1.0.1/memoryintelligence/mi_types.py → memoryintelligence-2.0.1/memoryintelligence/_models.py +154 -185
- memoryintelligence-2.0.1/memoryintelligence/_utils.py +386 -0
- memoryintelligence-2.0.1/memoryintelligence/_version.py +3 -0
- memoryintelligence-2.0.1/memoryintelligence/py.typed +2 -0
- memoryintelligence-2.0.1/memoryintelligence.egg-info/SOURCES.txt +18 -0
- memoryintelligence-2.0.1/pyproject.toml +67 -0
- memoryintelligence-1.0.1/CHANGELOG.md +0 -52
- memoryintelligence-1.0.1/PKG-INFO +0 -183
- memoryintelligence-1.0.1/README.md +0 -148
- memoryintelligence-1.0.1/memoryintelligence/__init__.py +0 -152
- memoryintelligence-1.0.1/memoryintelligence/edge_client.py +0 -384
- memoryintelligence-1.0.1/memoryintelligence/memory_client.py +0 -690
- memoryintelligence-1.0.1/memoryintelligence.egg-info/SOURCES.txt +0 -9
- memoryintelligence-1.0.1/pyproject.toml +0 -84
- {memoryintelligence-1.0.1 → memoryintelligence-2.0.1}/LICENSE +0 -0
- {memoryintelligence-1.0.1 → memoryintelligence-2.0.1}/MANIFEST.in +0 -0
- {memoryintelligence-1.0.1 → memoryintelligence-2.0.1}/setup.cfg +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.0.1] - 2026-03-27
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Corrected all documentation and billing URLs from `memoryintelligence.dev` to `memoryintelligence.io`
|
|
7
|
+
- Updated default API base URL from `api.memoryintelligence.dev` to `api.memoryintelligence.io`
|
|
8
|
+
- Resolved dead links in error messages, edge client defaults, and PyPI package metadata
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
All notable changes to the Memory Intelligence Python SDK.
|
|
12
|
+
|
|
13
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
14
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
15
|
+
|
|
16
|
+
## [2.0.0] - 2026-02-27
|
|
17
|
+
|
|
18
|
+
### Breaking Changes
|
|
19
|
+
|
|
20
|
+
#### UMO Namespace Pattern
|
|
21
|
+
- **Changed:** All UMO operations moved to `mi.umo.*` namespace
|
|
22
|
+
- `mi.process()` → `mi.umo.process()`
|
|
23
|
+
- `mi.search()` → `mi.umo.search()`
|
|
24
|
+
- `mi.match()` → `mi.umo.match()`
|
|
25
|
+
- `mi.explain()` → `mi.umo.explain()`
|
|
26
|
+
- `mi.delete()` → `mi.umo.delete()`
|
|
27
|
+
|
|
28
|
+
#### Mandatory Encryption
|
|
29
|
+
- **Changed:** Client-side AES-256-GCM encryption is now **mandatory**
|
|
30
|
+
- **Removed:** `enable_encryption` parameter (previously optional in v1)
|
|
31
|
+
- **Added:** Automatic encryption with ephemeral key if `MI_ENCRYPTION_KEY` not set
|
|
32
|
+
- **Added:** Warning logged when using ephemeral keys in production
|
|
33
|
+
|
|
34
|
+
#### User ID Format
|
|
35
|
+
- **Changed:** `user_id` parameter renamed to `user_ulid`
|
|
36
|
+
- **Changed:** Must use ULID format (26-character string: `01ABC...`)
|
|
37
|
+
- **Migration:** Generate ULIDs: `str(ULID())`
|
|
38
|
+
|
|
39
|
+
#### Dual Identity Pattern
|
|
40
|
+
- **Changed:** `user_ulid` no longer defaults from client constructor
|
|
41
|
+
- **Added:** `for_user(user_ulid)` method for scoped clients
|
|
42
|
+
- **Usage:**
|
|
43
|
+
```python
|
|
44
|
+
# v2.0
|
|
45
|
+
mi = MemoryClient()
|
|
46
|
+
user_client = mi.for_user("01USER12345678901234567890")
|
|
47
|
+
umo = user_client.umo.process("content")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Model Serialization
|
|
51
|
+
- **Changed:** Models converted from dataclasses to Pydantic BaseModel
|
|
52
|
+
- **Changed:** `asdict(umo)` → `umo.model_dump()`
|
|
53
|
+
- **Changed:** `json.dumps(asdict(umo))` → `umo.model_dump_json()`
|
|
54
|
+
- **Added:** Full Pydantic validation and serialization support
|
|
55
|
+
|
|
56
|
+
#### Error Classes
|
|
57
|
+
- **Renamed:** `AuthError` → `AuthenticationError`
|
|
58
|
+
- **Added:** New exception classes:
|
|
59
|
+
- `LicenseError` - License validation and feature gating
|
|
60
|
+
- `PIIViolationError` - PII detection violations (HTTP 451)
|
|
61
|
+
- `PaymentRequiredError` - License required (HTTP 402)
|
|
62
|
+
- `ConflictError` - Resource conflicts (HTTP 409)
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
#### EdgeClient
|
|
67
|
+
- **Added:** `EdgeClient` for on-premises deployment
|
|
68
|
+
- **Features:**
|
|
69
|
+
- HIPAA mode (`hipaa_mode=True`)
|
|
70
|
+
- Air-gapped deployment (`air_gapped=True`)
|
|
71
|
+
- Federated aggregation (`aggregate()`)
|
|
72
|
+
- PHI handling verification (`verify_phi_handling()`)
|
|
73
|
+
- Audit log export (`export_audit_log()`)
|
|
74
|
+
- **License Required:** ENTERPRISE tier only
|
|
75
|
+
|
|
76
|
+
#### Async Support
|
|
77
|
+
- **Added:** `AsyncMemoryClient` for non-blocking operations
|
|
78
|
+
- **Features:**
|
|
79
|
+
- Full async/await support
|
|
80
|
+
- Connection pooling with `httpx.AsyncClient`
|
|
81
|
+
- Same API as sync client
|
|
82
|
+
|
|
83
|
+
#### License System
|
|
84
|
+
- **Added:** License tier enforcement (TRIAL, STARTER, PROFESSIONAL, ENTERPRISE)
|
|
85
|
+
- **Added:** Feature gating:
|
|
86
|
+
- STARTER: `process()`, `search()` only
|
|
87
|
+
- PROFESSIONAL: All cloud features (`match()`, `explain()`)
|
|
88
|
+
- ENTERPRISE: All features including EdgeClient
|
|
89
|
+
- **Added:** Grace periods:
|
|
90
|
+
- Cloud: 14 days
|
|
91
|
+
- Air-gapped: 30 days
|
|
92
|
+
- **Added:** License caching with 24-hour TTL
|
|
93
|
+
- **Added:** Background license revalidation
|
|
94
|
+
|
|
95
|
+
#### Encryption Enhancements
|
|
96
|
+
- **Added:** AES-256-GCM encryption with PBKDF2 (100,000 iterations)
|
|
97
|
+
- **Added:** User ULID binding via associated data
|
|
98
|
+
- **Added:** Key identification via SHA-256 hash
|
|
99
|
+
- **Added:** `EncryptedPayload` model for inspection
|
|
100
|
+
|
|
101
|
+
#### HTTP Transport
|
|
102
|
+
- **Added:** `SyncTransport` and `AsyncTransport` with retry logic
|
|
103
|
+
- **Added:** Exponential backoff with jitter
|
|
104
|
+
- **Added:** Retry on: 408, 429, 500, 502, 503, 504
|
|
105
|
+
- **Added:** ULID request IDs for tracing
|
|
106
|
+
- **Added:** Automatic error mapping from HTTP status codes
|
|
107
|
+
|
|
108
|
+
#### Models
|
|
109
|
+
- **Added:** Pydantic models for all API responses:
|
|
110
|
+
- `MeaningObject`, `Entity`, `Topic`, `SVOTriple`
|
|
111
|
+
- `SearchResponse`, `SearchResult`, `MatchResult`
|
|
112
|
+
- `Explanation`, `HumanExplanation`, `AuditExplanation`
|
|
113
|
+
- `Provenance`, `PIIInfo`, `DeleteResult`
|
|
114
|
+
- **Added:** Enum types:
|
|
115
|
+
- `Scope` (USER, CLIENT, ORGANIZATION)
|
|
116
|
+
- `PIIHandling` (EXTRACT_AND_REDACT, HASH, REJECT)
|
|
117
|
+
- `RetentionPolicy` (FULL, MEANING_ONLY, NO_STORAGE)
|
|
118
|
+
- `ProvenanceMode` (MINIMAL, STANDARD, AUDIT)
|
|
119
|
+
- `LicenseType` (TRIAL, STARTER, PROFESSIONAL, ENTERPRISE)
|
|
120
|
+
- `LicenseStatus` (ACTIVE, EXPIRED, REVOKED, SUSPENDED)
|
|
121
|
+
|
|
122
|
+
### Changed
|
|
123
|
+
|
|
124
|
+
#### Dependencies
|
|
125
|
+
- **Added:** `httpx>=0.27.0` (was `requests` in v1)
|
|
126
|
+
- **Added:** `pydantic>=2.5.0`
|
|
127
|
+
- **Added:** `cryptography>=42.0.0`
|
|
128
|
+
- **Added:** `python-ulid>=2.0.0`
|
|
129
|
+
- **Removed:** `requests` dependency
|
|
130
|
+
|
|
131
|
+
#### Configuration
|
|
132
|
+
- **Changed:** `MI_API_KEY` environment variable now the primary auth method
|
|
133
|
+
- **Changed:** `MI_ENCRYPTION_KEY` for persistent encryption keys
|
|
134
|
+
- **Added:** Validation for API key format (`mi_sk_` prefix)
|
|
135
|
+
|
|
136
|
+
#### Error Handling
|
|
137
|
+
- **Changed:** All errors now include `code` attribute
|
|
138
|
+
- **Changed:** `RateLimitError` includes `retry_after` seconds
|
|
139
|
+
- **Changed:** `ServerError` includes `request_id` for debugging
|
|
140
|
+
- **Changed:** `ValidationError` includes `field` for invalid parameters
|
|
141
|
+
- **Changed:** `LicenseError` includes `days_expired` and `renew_url`
|
|
142
|
+
|
|
143
|
+
### Removed
|
|
144
|
+
|
|
145
|
+
- **Removed:** Direct method calls on `MemoryClient` (use `mi.umo.*`)
|
|
146
|
+
- **Removed:** `enable_encryption` parameter (always enabled)
|
|
147
|
+
- **Removed:** `user_id` parameter (use `user_ulid`)
|
|
148
|
+
- **Removed:** `AuthError` exception (use `AuthenticationError`)
|
|
149
|
+
|
|
150
|
+
### Security
|
|
151
|
+
|
|
152
|
+
- **Added:** Mandatory client-side encryption for all content
|
|
153
|
+
- **Added:** User ULID binding prevents cross-user decryption
|
|
154
|
+
- **Added:** Authentication tags prevent tampering
|
|
155
|
+
- **Added:** PII detection with configurable handling
|
|
156
|
+
- **Added:** HIPAA mode for healthcare compliance
|
|
157
|
+
- **Added:** Audit logging for compliance reviews
|
|
158
|
+
- **Added:** Scope isolation (user/client/organization)
|
|
159
|
+
|
|
160
|
+
### Documentation
|
|
161
|
+
|
|
162
|
+
- **Added:** Quickstart guide (`docs/quickstart.md`)
|
|
163
|
+
- **Added:** Authentication guide (`docs/authentication.md`)
|
|
164
|
+
- **Added:** Encryption guide (`docs/encryption.md`)
|
|
165
|
+
- **Added:** Licensing guide (`docs/licensing.md`)
|
|
166
|
+
- **Added:** API reference (`docs/api_reference.md`)
|
|
167
|
+
- **Added:** Enterprise guide (`docs/enterprise.md`)
|
|
168
|
+
- **Added:** Migration guide (`docs/migration_v1_to_v2.md`)
|
|
169
|
+
- **Added:** FAQ (`docs/faq.md`)
|
|
170
|
+
- **Added:** OpenAPI specification (`docs/openapi.yaml`)
|
|
171
|
+
|
|
172
|
+
### Testing
|
|
173
|
+
|
|
174
|
+
- **Added:** Comprehensive test suite:
|
|
175
|
+
- `tests/test_client.py` - UMONamespace methods
|
|
176
|
+
- `tests/test_crypto.py` - Encryption/decryption
|
|
177
|
+
- `tests/test_license.py` - License validation
|
|
178
|
+
- `tests/test_edge_client.py` - EdgeClient functionality
|
|
179
|
+
- `tests/test_errors.py` - HTTP status mapping
|
|
180
|
+
- `tests/test_integration.py` - End-to-end workflows
|
|
181
|
+
- **Added:** pytest fixtures with mocked transport
|
|
182
|
+
- **Added:** Test coverage for all license tiers
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## [1.0.1] - 2026-02-07
|
|
187
|
+
|
|
188
|
+
### Fixed
|
|
189
|
+
- Corrected `ProvenanceError` in `__all__` exports list (final typo fix)
|
|
190
|
+
|
|
191
|
+
## [1.0.0] - 2026-02-07 [YANKED]
|
|
192
|
+
|
|
193
|
+
### Added
|
|
194
|
+
- **MemoryClient** with 6 core operations: process, search, match, explain, delete, verify_provenance
|
|
195
|
+
- **EdgeClient** for on-premises HIPAA-compliant deployments
|
|
196
|
+
- Privacy-first architecture with meaning-only retention (default)
|
|
197
|
+
- Structured semantic extraction (entities, topics, SVO triples, key phrases)
|
|
198
|
+
- Explainable search results with human + audit explanations
|
|
199
|
+
- Cryptographic provenance tracking with hash chain verification
|
|
200
|
+
- ULID-based identity firewall for cryptographic tenant isolation
|
|
201
|
+
- Scope-based access control (user, team, client, organization)
|
|
202
|
+
- PII detection and configurable handling (extract_and_redact, hash, reject)
|
|
203
|
+
- Type-safe API with Pydantic models
|
|
204
|
+
- Comprehensive error handling (7 exception types)
|
|
205
|
+
- 30+ unit and integration tests
|
|
206
|
+
|
|
207
|
+
### Known Limitations
|
|
208
|
+
- Pagination not yet implemented (coming in v1.1.0)
|
|
209
|
+
- Streaming search results not yet available
|
|
210
|
+
- Temporal intelligence parameter present but not fully validated in tests
|
|
211
|
+
|
|
212
|
+
### Fixed
|
|
213
|
+
- Corrected `ProvenanceError` exception name (was misspelled as `ProvenenaceError`)
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Migration Guide
|
|
218
|
+
|
|
219
|
+
See [docs/migration_v1_to_v2.md](docs/migration_v1_to_v2.md) for detailed migration instructions.
|
|
220
|
+
|
|
221
|
+
### Quick Migration Checklist
|
|
222
|
+
|
|
223
|
+
- [ ] Update imports to use `mi.umo.*` namespace
|
|
224
|
+
- [ ] Rename `user_id` to `user_ulid` (use ULID format)
|
|
225
|
+
- [ ] Set `MI_ENCRYPTION_KEY` environment variable
|
|
226
|
+
- [ ] Update `asdict(umo)` to `umo.model_dump()`
|
|
227
|
+
- [ ] Rename `AuthError` to `AuthenticationError`
|
|
228
|
+
- [ ] Use `for_user()` for multi-user applications
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Support
|
|
233
|
+
|
|
234
|
+
- **Documentation:** [docs.memoryintelligence.dev](https://docs.memoryintelligence.dev)
|
|
235
|
+
- **Migration Help:** migration@memoryintelligence.dev
|
|
236
|
+
- **Issues:** [github.com/memoryintelligence/sdk-python/issues](https://github.com/memoryintelligence/sdk-python/issues)
|
|
237
|
+
- **Changelog:** This file
|
|
238
|
+
|
|
239
|
+
[2.0.0]: https://github.com/memoryintelligence/sdk-python/releases/tag/v2.0.0
|
|
240
|
+
[1.0.1]: https://github.com/memoryintelligence/sdk-python/releases/tag/v1.0.1
|
|
241
|
+
[1.0.0]: https://github.com/memoryintelligence/sdk-python/releases/tag/v1.0.0
|
|
242
|
+
[Unreleased]: https://github.com/memoryintelligence/sdk-python/compare/v2.0.0...HEAD
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memoryintelligence
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: Official Python SDK for Memory Intelligence — Verifiable meaning infrastructure
|
|
5
|
+
Author-email: Memory Intelligence Team <sdk@memoryintelligence.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://memoryintelligence.io
|
|
8
|
+
Project-URL: Documentation, https://docs.memoryintelligence.io
|
|
9
|
+
Project-URL: Repository, https://github.com/memoryintelligence/sdk-python
|
|
10
|
+
Project-URL: Changelog, https://github.com/memoryintelligence/sdk-python/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ai,llm,memory,rag,embeddings,privacy,compliance,hipaa,gdpr,provenance,umo
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: httpx>=0.27.0
|
|
24
|
+
Requires-Dist: pydantic>=2.5.0
|
|
25
|
+
Requires-Dist: cryptography>=42.0.0
|
|
26
|
+
Requires-Dist: python-ulid>=2.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-httpx>=0.30; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.3; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# Memory Intelligence SDK
|
|
37
|
+
|
|
38
|
+
The official Python SDK for Memory Intelligence - Verifiable meaning infrastructure for AI.
|
|
39
|
+
|
|
40
|
+
[](https://pypi.org/project/memoryintelligence/)
|
|
41
|
+
[](https://pypi.org/project/memoryintelligence/)
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from memoryintelligence import MemoryClient
|
|
47
|
+
|
|
48
|
+
# Initialize client
|
|
49
|
+
mi = MemoryClient(api_key="mi_sk_...")
|
|
50
|
+
|
|
51
|
+
# Process content → meaning
|
|
52
|
+
umo = mi.umo.process("Meeting notes from today", user_ulid="01ABC...")
|
|
53
|
+
|
|
54
|
+
# Search meaning
|
|
55
|
+
results = mi.umo.search("What did we discuss?", user_ulid="01ABC...", explain=True)
|
|
56
|
+
|
|
57
|
+
# Match for recommendations
|
|
58
|
+
match = mi.umo.match("01ABC...", "01XYZ...", explain=True)
|
|
59
|
+
|
|
60
|
+
# Get explanation
|
|
61
|
+
explanation = mi.umo.explain("01ABC...")
|
|
62
|
+
|
|
63
|
+
# Delete for GDPR
|
|
64
|
+
result = mi.umo.delete(user_ulid="01ABC...")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Key Features
|
|
68
|
+
|
|
69
|
+
- **Meaning-First Architecture**: Raw content discarded after processing
|
|
70
|
+
- **Five Core Operations**: Process, Search, Match, Explain, Delete
|
|
71
|
+
- **Provenance Tracking**: Cryptographic verification of content lineage
|
|
72
|
+
- **GDPR Compliance**: One-call data deletion with audit proof
|
|
73
|
+
- **Built-in Telemetry**: Debug logs for content processing
|
|
74
|
+
- **Simplified API**: Only 12 essential exports
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install memoryintelligence
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage Guide
|
|
83
|
+
|
|
84
|
+
### Initialize the Client
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from memoryintelligence import MemoryClient
|
|
88
|
+
|
|
89
|
+
# For production (API key required)
|
|
90
|
+
mi = MemoryClient(api_key="mi_sk_prod_...")
|
|
91
|
+
|
|
92
|
+
# For development
|
|
93
|
+
mi = MemoryClient(api_key="mi_sk_dev_...")
|
|
94
|
+
|
|
95
|
+
# For specific user (multi-tenant)
|
|
96
|
+
user_mi = mi.for_user("01USER12345678901234567890")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Process Content
|
|
100
|
+
|
|
101
|
+
Convert raw content to meaning (discards raw content by default):
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from memoryintelligence import RetentionPolicy, PIIHandling, ProvenanceMode
|
|
105
|
+
|
|
106
|
+
umo = mi.umo.process(
|
|
107
|
+
"Budget approved for Q3 initiatives",
|
|
108
|
+
user_ulid="01ABC...",
|
|
109
|
+
retention_policy=RetentionPolicy.MEANING_ONLY,
|
|
110
|
+
pii_handling=PIIHandling.EXTRACT_AND_REDACT,
|
|
111
|
+
provenance_mode=ProvenanceMode.STANDARD
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
print(umo.entities) # [Entity(text="Q3", type="DATE"), ...]
|
|
115
|
+
print(umo.topics) # ["budget", "initiatives"]
|
|
116
|
+
print(umo.svo_triples) # [SVOTriple(subject="budget", verb="approved", object="initiatives")]
|
|
117
|
+
print(umo.umo_id) # "01KGE95Q4P9H89H63T26FNKKBR"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Search for Meaning
|
|
121
|
+
|
|
122
|
+
Find relevant memories with explanation:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from datetime import datetime, timezone
|
|
126
|
+
|
|
127
|
+
results = mi.umo.search(
|
|
128
|
+
"Q3 budget decisions",
|
|
129
|
+
user_ulid="01ABC...",
|
|
130
|
+
explain=True,
|
|
131
|
+
limit=5,
|
|
132
|
+
topics=["budget", "finance"],
|
|
133
|
+
date_from=datetime(2024, 1, 1, tzinfo=timezone.utc)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
for result in results.results:
|
|
137
|
+
print(f"Score: {result.score:.2f}")
|
|
138
|
+
print(f"Summary: {result.umo.summary}")
|
|
139
|
+
if result.explain:
|
|
140
|
+
print(f"Why: {result.explain.human.summary}")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Match for Recommendations
|
|
144
|
+
|
|
145
|
+
Compare two memories for relevance:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
match = mi.umo.match(
|
|
149
|
+
source_ulid="01ABC...",
|
|
150
|
+
candidate_ulid="01XYZ...",
|
|
151
|
+
explain=True
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
print(f"Match score: {match.score}")
|
|
155
|
+
print(f"Is match: {match.match}")
|
|
156
|
+
if match.explain:
|
|
157
|
+
print(f"Reason: {match.explain.human.summary}")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Get Explanations
|
|
161
|
+
|
|
162
|
+
Understand why content is relevant:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from memoryintelligence import ExplainLevel
|
|
166
|
+
|
|
167
|
+
explanation = mi.umo.explain(
|
|
168
|
+
"01ABC...",
|
|
169
|
+
level=ExplainLevel.FULL
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
print(explanation.human.summary)
|
|
173
|
+
print(explanation.human.key_reasons)
|
|
174
|
+
print(explanation.audit.semantic_score)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Delete Data
|
|
178
|
+
|
|
179
|
+
GDPR-compliant data removal:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from memoryintelligence import Scope
|
|
183
|
+
|
|
184
|
+
result = mi.umo.delete(
|
|
185
|
+
user_ulid="01ABC...",
|
|
186
|
+
scope=Scope.USER
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
print(f"Deleted {result.deleted_count} memories")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Async Support
|
|
193
|
+
|
|
194
|
+
For async frameworks:
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from memoryintelligence import AsyncMemoryClient
|
|
198
|
+
|
|
199
|
+
mi = AsyncMemoryClient(api_key="mi_sk_...")
|
|
200
|
+
|
|
201
|
+
# Process
|
|
202
|
+
umo = await mi.umo.process("Content", user_ulid="01ABC...")
|
|
203
|
+
|
|
204
|
+
# Search with iteration
|
|
205
|
+
async for result in mi.umo.search_iter("query", user_ulid="01ABC..."):
|
|
206
|
+
print(result.umo.summary)
|
|
207
|
+
|
|
208
|
+
# Batch processing
|
|
209
|
+
contents = ["Note 1", "Note 2", "Note 3"]
|
|
210
|
+
results = await mi.umo.process_batch(contents, user_ulid="01ABC...")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Edge Deployment (HIPAA/Air-gapped)
|
|
214
|
+
|
|
215
|
+
For regulated industries:
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
from memoryintelligence import EdgeClient
|
|
219
|
+
|
|
220
|
+
# HIPAA-compliant edge deployment
|
|
221
|
+
edge = EdgeClient(
|
|
222
|
+
endpoint="https://mi.internal.yourcompany.com",
|
|
223
|
+
api_key="mi_sk_...",
|
|
224
|
+
hipaa_mode=True
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# Process locally (data never leaves)
|
|
228
|
+
umo = edge.umo.process(clinical_note, user_ulid="01PATIENT...")
|
|
229
|
+
|
|
230
|
+
# Air-gapped (no external calls)
|
|
231
|
+
air_gapped = EdgeClient(
|
|
232
|
+
endpoint="https://mi.internal.com",
|
|
233
|
+
air_gapped=True # No API key needed
|
|
234
|
+
)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Error Handling
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
from memoryintelligence import (
|
|
241
|
+
MemoryClient,
|
|
242
|
+
LicenseError,
|
|
243
|
+
RateLimitError,
|
|
244
|
+
ValidationError,
|
|
245
|
+
AuthenticationError
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
try:
|
|
249
|
+
mi = MemoryClient(api_key="mi_sk_...")
|
|
250
|
+
umo = mi.umo.process("Content", user_ulid="01ABC...")
|
|
251
|
+
except LicenseError as e:
|
|
252
|
+
print(f"License expired {e.days_expired} days ago")
|
|
253
|
+
print(f"Renew at: {e.renew_url}")
|
|
254
|
+
except RateLimitError as e:
|
|
255
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
256
|
+
except ValidationError as e:
|
|
257
|
+
print(f"Validation failed: {e.message}")
|
|
258
|
+
except AuthenticationError:
|
|
259
|
+
print("Invalid API key")
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Webhook Verification
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from memoryintelligence import verify_webhook_signature
|
|
266
|
+
|
|
267
|
+
# Verify webhook from Memory Intelligence
|
|
268
|
+
is_valid = verify_webhook_signature(
|
|
269
|
+
payload=request_body,
|
|
270
|
+
signature=headers["X-MI-Signature"],
|
|
271
|
+
secret="whsec_..."
|
|
272
|
+
)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Monitoring & Telemetry
|
|
276
|
+
|
|
277
|
+
The SDK provides built-in telemetry for operational visibility:
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
import logging
|
|
281
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Key Log Events:
|
|
285
|
+
- `DEBUG`: Content processing metrics (size, time)
|
|
286
|
+
- `INFO`: Operation completion with results
|
|
287
|
+
- `WARNING`: PII detection events
|
|
288
|
+
- `ERROR`: API and integration errors
|
|
289
|
+
|
|
290
|
+
## Configuration
|
|
291
|
+
|
|
292
|
+
Environment variables:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Required for persistent encryption
|
|
296
|
+
export MI_ENCRYPTION_KEY="$(openssl rand -base64 32)"
|
|
297
|
+
|
|
298
|
+
# API configuration
|
|
299
|
+
export MI_API_KEY="mi_sk_live_..."
|
|
300
|
+
export MI_BASE_URL="https://api.memoryintelligence.io"
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Documentation
|
|
304
|
+
|
|
305
|
+
Full documentation is available at:
|
|
306
|
+
- [API Reference](https://docs.memoryintelligence.io)
|
|
307
|
+
- [Getting Started Guide](https://memoryintelligence.io/docs/getting-started)
|
|
308
|
+
|
|
309
|
+
## Support
|
|
310
|
+
|
|
311
|
+
For SDK issues, please contact:
|
|
312
|
+
- support@memoryintelligence.io
|
|
313
|
+
- GitHub Issues: [Create New Issue](https://github.com/memoryintelligence/sdk-python/issues/new)
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
This SDK is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|