memoryintelligence 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.
- memoryintelligence/__init__.py +71 -0
- memoryintelligence/_auth.py +316 -0
- memoryintelligence/_errors.py +232 -0
- memoryintelligence/_http.py +419 -0
- memoryintelligence/_simple.py +301 -0
- memoryintelligence/_version.py +3 -0
- memoryintelligence/py.typed +2 -0
- memoryintelligence-0.1.0.dist-info/METADATA +220 -0
- memoryintelligence-0.1.0.dist-info/RECORD +12 -0
- memoryintelligence-0.1.0.dist-info/WHEEL +5 -0
- memoryintelligence-0.1.0.dist-info/licenses/LICENSE +31 -0
- memoryintelligence-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""The flat client: eight verbs, on the canonical public endpoints.
|
|
2
|
+
|
|
3
|
+
from memoryintelligence import MemoryIntelligence
|
|
4
|
+
|
|
5
|
+
mi = MemoryIntelligence.from_env() # reads MI_API_KEY
|
|
6
|
+
note = mi.capture("Sarah proposed provenance hashing for the deck.")
|
|
7
|
+
|
|
8
|
+
for hit in mi.ask("what did sarah suggest?"):
|
|
9
|
+
print(f"{hit.score:.2f} {hit.summary}")
|
|
10
|
+
|
|
11
|
+
if mi.verify(note.id): # every memory has a receipt
|
|
12
|
+
print("intact")
|
|
13
|
+
|
|
14
|
+
This is the surface most people want: capture, ask, get, list, verify, explain,
|
|
15
|
+
forget, batch, upload. It maps one-to-one onto the canonical `/v1/*` endpoints
|
|
16
|
+
(the ones the public OpenAPI and operationIds describe) and hides the wire
|
|
17
|
+
format so results come back as small typed objects, not envelopes.
|
|
18
|
+
|
|
19
|
+
It is built on the same transport and error family as `MemoryClient`, so it
|
|
20
|
+
shares connection pooling, retries, and `except MIError` behavior. `MemoryClient`
|
|
21
|
+
(the `mi.umo.*` namespace, multi-tenant `user_ulid`, edge and crypto features)
|
|
22
|
+
stays available for advanced and regulated use.
|
|
23
|
+
"""
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
from dataclasses import dataclass, field
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from typing import Any, Iterable
|
|
29
|
+
|
|
30
|
+
from ._auth import (
|
|
31
|
+
resolve_api_key,
|
|
32
|
+
resolve_base_url,
|
|
33
|
+
validate_key_environment,
|
|
34
|
+
validate_key_format,
|
|
35
|
+
)
|
|
36
|
+
from ._errors import MIError
|
|
37
|
+
from ._http import SyncTransport
|
|
38
|
+
|
|
39
|
+
__all__ = ["MemoryIntelligence", "MI", "Memory", "Match", "Proof", "Explanation", "Receipt"]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
# Result types. Small, typed, readable. Each keeps a `.raw` escape hatch and
|
|
44
|
+
# supports item access, so you are never boxed in by our field choices:
|
|
45
|
+
# `note.id` when it is clean, `note["quality_score"]` when you need something we
|
|
46
|
+
# did not surface.
|
|
47
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
class _Record:
|
|
50
|
+
raw: dict
|
|
51
|
+
|
|
52
|
+
def __getitem__(self, key: str) -> Any:
|
|
53
|
+
return self.raw[key]
|
|
54
|
+
|
|
55
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
56
|
+
return self.raw.get(key, default)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class Memory(_Record):
|
|
61
|
+
"""A stored memory (a Unified Memory Object). `id` is what you pass back to
|
|
62
|
+
verify, explain, and forget."""
|
|
63
|
+
id: str
|
|
64
|
+
quality_score: float | None = None
|
|
65
|
+
summary: str | None = None
|
|
66
|
+
channel: str | None = None
|
|
67
|
+
created_at: str | None = None
|
|
68
|
+
raw: dict = field(default_factory=dict, repr=False)
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def _wrap(cls, d: dict) -> "Memory":
|
|
72
|
+
return cls(
|
|
73
|
+
id=d.get("umo_id") or d.get("id"),
|
|
74
|
+
quality_score=d.get("quality_score"),
|
|
75
|
+
summary=d.get("summary"),
|
|
76
|
+
channel=d.get("channel"),
|
|
77
|
+
created_at=d.get("created_at"),
|
|
78
|
+
raw=d,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def entities(self) -> list[dict]:
|
|
83
|
+
return self.raw.get("entities", [])
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass(frozen=True)
|
|
87
|
+
class Match(_Record):
|
|
88
|
+
"""One search result: a `memory` plus its relevance `score` (0 to 1)."""
|
|
89
|
+
score: float
|
|
90
|
+
memory: Memory
|
|
91
|
+
raw: dict = field(default_factory=dict, repr=False)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def id(self) -> str:
|
|
95
|
+
return self.memory.id
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def summary(self) -> str | None:
|
|
99
|
+
return self.memory.summary
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def entities(self) -> list[dict]:
|
|
103
|
+
return self.memory.entities
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass(frozen=True)
|
|
107
|
+
class Proof(_Record):
|
|
108
|
+
"""The receipt for a memory. Truthy when intact: `if mi.verify(id): ...`"""
|
|
109
|
+
valid: bool
|
|
110
|
+
hash_chain_valid: bool | None = None
|
|
111
|
+
mode: str | None = None # cryptographic | legacy | incomplete
|
|
112
|
+
tampered: bool | None = None
|
|
113
|
+
raw: dict = field(default_factory=dict, repr=False)
|
|
114
|
+
|
|
115
|
+
def __bool__(self) -> bool:
|
|
116
|
+
return bool(self.valid)
|
|
117
|
+
|
|
118
|
+
@classmethod
|
|
119
|
+
def _wrap(cls, d: dict) -> "Proof":
|
|
120
|
+
audit = d.get("audit_proof") or {}
|
|
121
|
+
return cls(
|
|
122
|
+
valid=bool(d.get("valid")),
|
|
123
|
+
hash_chain_valid=d.get("hash_chain_valid"),
|
|
124
|
+
mode=audit.get("verification_mode"),
|
|
125
|
+
tampered=audit.get("chain_tampered"),
|
|
126
|
+
raw=d,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass(frozen=True)
|
|
131
|
+
class Explanation(_Record):
|
|
132
|
+
"""What the pipeline extracted from a memory and why it matched."""
|
|
133
|
+
id: str
|
|
134
|
+
raw: dict = field(default_factory=dict, repr=False)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass(frozen=True)
|
|
138
|
+
class Receipt(_Record):
|
|
139
|
+
"""Confirmation that a memory was deleted, with its deletion record.
|
|
140
|
+
Truthy when the delete took effect."""
|
|
141
|
+
id: str
|
|
142
|
+
deleted: bool
|
|
143
|
+
raw: dict = field(default_factory=dict, repr=False)
|
|
144
|
+
|
|
145
|
+
def __bool__(self) -> bool:
|
|
146
|
+
return bool(self.deleted)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
150
|
+
# The client.
|
|
151
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
152
|
+
|
|
153
|
+
class MemoryIntelligence:
|
|
154
|
+
"""A connection to Memory Intelligence.
|
|
155
|
+
|
|
156
|
+
mi = MemoryIntelligence("mi_sk_...")
|
|
157
|
+
mi = MemoryIntelligence.from_env() # reads MI_API_KEY
|
|
158
|
+
|
|
159
|
+
Reuse one instance across your app. It is a thin, synchronous wrapper over a
|
|
160
|
+
pooled connection, cheap to hold and safe to share within a thread. Close it
|
|
161
|
+
when you are done, or use it as a context manager.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
def __init__(
|
|
165
|
+
self,
|
|
166
|
+
api_key: str | None = None,
|
|
167
|
+
*,
|
|
168
|
+
base_url: str | None = None,
|
|
169
|
+
timeout: float = 30.0,
|
|
170
|
+
max_retries: int = 2,
|
|
171
|
+
):
|
|
172
|
+
self._api_key = resolve_api_key(api_key)
|
|
173
|
+
self._base_url = resolve_base_url(base_url)
|
|
174
|
+
validate_key_format(self._api_key)
|
|
175
|
+
validate_key_environment(self._api_key, self._base_url)
|
|
176
|
+
self._transport = SyncTransport(
|
|
177
|
+
api_key=self._api_key,
|
|
178
|
+
base_url=self._base_url,
|
|
179
|
+
timeout=timeout,
|
|
180
|
+
max_retries=max_retries,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
@classmethod
|
|
184
|
+
def from_env(cls, **kwargs: Any) -> "MemoryIntelligence":
|
|
185
|
+
"""Build a client from MI_API_KEY (and optional MI_BASE_URL)."""
|
|
186
|
+
return cls(None, **kwargs)
|
|
187
|
+
|
|
188
|
+
# ── the eight verbs ──────────────────────────────────────────────────────
|
|
189
|
+
|
|
190
|
+
def capture(self, content: str, *, source: str | None = None, **metadata: Any) -> Memory:
|
|
191
|
+
"""Turn raw content into a structured, verifiable memory.
|
|
192
|
+
|
|
193
|
+
note = mi.capture("Deploy is Friday at 3pm.", source="standup")
|
|
194
|
+
|
|
195
|
+
Keep `note.id`: it is how you verify, explain, and forget this later.
|
|
196
|
+
"""
|
|
197
|
+
body: dict[str, Any] = {"content": content}
|
|
198
|
+
if source:
|
|
199
|
+
body["source"] = source
|
|
200
|
+
if metadata:
|
|
201
|
+
body["metadata"] = metadata
|
|
202
|
+
return Memory._wrap(self._data(self._transport.request("POST", "/v1/process", json=body)))
|
|
203
|
+
|
|
204
|
+
def ask(self, query: str, *, limit: int = 5, **filters: Any) -> list[Match]:
|
|
205
|
+
"""Find memories by meaning, not keywords.
|
|
206
|
+
|
|
207
|
+
for hit in mi.ask("what did we decide about pricing?", limit=3):
|
|
208
|
+
print(hit.score, hit.summary)
|
|
209
|
+
|
|
210
|
+
Filters (source, topics, entities, date_from, date_to) pass through.
|
|
211
|
+
Returns matches already sorted by relevance.
|
|
212
|
+
"""
|
|
213
|
+
body = {"query": query, "limit": limit, **filters}
|
|
214
|
+
payload = self._transport.request("POST", "/v1/memories/query", json=body)
|
|
215
|
+
container = payload.get("data", payload) # tolerate either envelope
|
|
216
|
+
return [
|
|
217
|
+
Match(score=r.get("score"), memory=Memory._wrap(r.get("umo", {})), raw=r)
|
|
218
|
+
for r in container.get("results", [])
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
def get(self, id: str) -> Memory:
|
|
222
|
+
"""Retrieve one memory by id."""
|
|
223
|
+
return Memory._wrap(self._data(self._transport.request("GET", f"/v1/memories/{id}")))
|
|
224
|
+
|
|
225
|
+
def list(self, *, limit: int | None = None) -> list[Memory]:
|
|
226
|
+
"""List the memories this key can see, newest first."""
|
|
227
|
+
params = {"limit": limit} if limit is not None else None
|
|
228
|
+
payload = self._transport.request("GET", "/v1/memories", params=params)
|
|
229
|
+
container = payload.get("data", payload)
|
|
230
|
+
rows = container.get("memories") or container.get("results") or container
|
|
231
|
+
return [Memory._wrap(r) for r in rows] if isinstance(rows, list) else []
|
|
232
|
+
|
|
233
|
+
def verify(self, id: str) -> Proof:
|
|
234
|
+
"""Prove a memory is real and unaltered. The result is truthy when
|
|
235
|
+
intact, so `assert mi.verify(id)` reads naturally."""
|
|
236
|
+
return Proof._wrap(self._data(self._transport.request("GET", f"/v1/memories/{id}/proof")))
|
|
237
|
+
|
|
238
|
+
def explain(self, id: str) -> Explanation:
|
|
239
|
+
"""See what the pipeline extracted from a memory and why it matched."""
|
|
240
|
+
d = self._data(self._transport.request("GET", f"/v1/memories/{id}/explain"))
|
|
241
|
+
return Explanation(id=id, raw=d)
|
|
242
|
+
|
|
243
|
+
def forget(self, id: str) -> Receipt:
|
|
244
|
+
"""Delete a memory and get a deletion receipt. Soft delete with a grace
|
|
245
|
+
window: recoverable until the window closes."""
|
|
246
|
+
d = self._data(self._transport.request("DELETE", f"/v1/memories/{id}"))
|
|
247
|
+
return Receipt(id=id, deleted=d.get("deleted", True), raw=d)
|
|
248
|
+
|
|
249
|
+
def batch(self, items: Iterable[str | dict]) -> list[Memory]:
|
|
250
|
+
"""Capture many memories in one round trip.
|
|
251
|
+
|
|
252
|
+
mi.batch(["first note", "second note"])
|
|
253
|
+
mi.batch([{"content": "with a source", "source": "import"}])
|
|
254
|
+
"""
|
|
255
|
+
payload = [
|
|
256
|
+
{"content": it} if isinstance(it, str) else dict(it)
|
|
257
|
+
for it in items
|
|
258
|
+
]
|
|
259
|
+
result = self._transport.request("POST", "/v1/batch", json={"items": payload})
|
|
260
|
+
container = result.get("data", result)
|
|
261
|
+
rows = container.get("results") or container.get("items") or []
|
|
262
|
+
return [Memory._wrap(r.get("umo", r)) for r in rows]
|
|
263
|
+
|
|
264
|
+
def upload(self, path: str | Path) -> Memory:
|
|
265
|
+
"""Capture a media file (audio, video, image, PDF). MI extracts the
|
|
266
|
+
content and structures it the same way capture() does."""
|
|
267
|
+
p = Path(path)
|
|
268
|
+
with p.open("rb") as fh:
|
|
269
|
+
result = self._transport.request("POST", "/v1/upload", files={"file": (p.name, fh)})
|
|
270
|
+
return Memory._wrap(self._data(result))
|
|
271
|
+
|
|
272
|
+
def health(self) -> bool:
|
|
273
|
+
"""True when the API is reachable and serving."""
|
|
274
|
+
try:
|
|
275
|
+
self._transport.request("GET", "/health")
|
|
276
|
+
return True
|
|
277
|
+
except MIError:
|
|
278
|
+
return False
|
|
279
|
+
|
|
280
|
+
# ── internals ────────────────────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
@staticmethod
|
|
283
|
+
def _data(payload: dict) -> dict:
|
|
284
|
+
"""Unwrap the {status, data} envelope so the caller always gets the
|
|
285
|
+
useful object, never the wrapper. Bare bodies pass through."""
|
|
286
|
+
if isinstance(payload, dict) and isinstance(payload.get("data"), dict):
|
|
287
|
+
return payload["data"]
|
|
288
|
+
return payload
|
|
289
|
+
|
|
290
|
+
def close(self) -> None:
|
|
291
|
+
self._transport.close()
|
|
292
|
+
|
|
293
|
+
def __enter__(self) -> "MemoryIntelligence":
|
|
294
|
+
return self
|
|
295
|
+
|
|
296
|
+
def __exit__(self, *exc: Any) -> None:
|
|
297
|
+
self.close()
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
# A terse alias for those who want it: `from memoryintelligence import MI`.
|
|
301
|
+
MI = MemoryIntelligence
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memoryintelligence
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for Memory Intelligence. Structured, verifiable memory for AI.
|
|
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/somewhere11/memoryintelligence-python-sdk
|
|
10
|
+
Project-URL: Changelog, https://github.com/somewhere11/memoryintelligence-python-sdk/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: python-ulid>=2.0.0
|
|
25
|
+
Provides-Extra: dotenv
|
|
26
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "dotenv"
|
|
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
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Memory Intelligence API
|
|
38
|
+
|
|
39
|
+
**Memory without meaning is just storage.**
|
|
40
|
+
|
|
41
|
+
This API turns raw content (text, conversations, images) into structured meaning. Searchable, explainable, provenance-tracked. No black box. No hallucinations.
|
|
42
|
+
|
|
43
|
+
**For Python backends:** FastAPI, Django, Flask, Lambda, Cloud Functions.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install memoryintelligence
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Get your API key:** [memoryintelligence.io/beta](https://memoryintelligence.io/beta)
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from memoryintelligence import MemoryIntelligence
|
|
61
|
+
|
|
62
|
+
mi = MemoryIntelligence.from_env() # reads MI_API_KEY
|
|
63
|
+
|
|
64
|
+
# Turn content into a structured, verifiable memory
|
|
65
|
+
note = mi.capture(
|
|
66
|
+
"Discussed pricing with ACME. They prefer quarterly billing.",
|
|
67
|
+
source="sales_call",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Ask by meaning, not keywords
|
|
71
|
+
for hit in mi.ask("what did ACME say about billing?"):
|
|
72
|
+
print(f"{hit.score:.2f} {hit.summary}")
|
|
73
|
+
|
|
74
|
+
# Every memory has a receipt
|
|
75
|
+
if mi.verify(note.id):
|
|
76
|
+
print("intact")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> **Upgrading from `MemoryClient`?** The flat `MemoryIntelligence` client above is
|
|
80
|
+
> the recommended surface. The older `MemoryClient` (the `mi.umo.*` namespace, with
|
|
81
|
+
> multi-tenant `user_ulid`) still works for advanced use, and `EdgeClient` still
|
|
82
|
+
> serves regulated on-premise deployments, but `MemoryClient` is deprecated and will
|
|
83
|
+
> be removed in a future major. See [Core Operations](#core-operations) for the full
|
|
84
|
+
> eight-verb surface.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## What It Does
|
|
89
|
+
|
|
90
|
+
- **Processes** → Extracts entities, topics, relationships, sentiment
|
|
91
|
+
- **Searches** → Returns ranked results with explainability
|
|
92
|
+
- **Matches** → Compares memories for relevance/similarity
|
|
93
|
+
- **Explains** → Shows *why* results matched (semantic, temporal, graph)
|
|
94
|
+
- **Deletes** → GDPR-compliant data removal with audit trail
|
|
95
|
+
|
|
96
|
+
**No vector database setup. No chunking strategies. No embedding models to manage.**
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Security: API Keys Are Server-Only
|
|
101
|
+
|
|
102
|
+
Your API key grants full account access. Keep it server-side.
|
|
103
|
+
|
|
104
|
+
**✅ Backend (environment variable):**
|
|
105
|
+
```python
|
|
106
|
+
mi = MemoryIntelligence.from_env() # reads MI_API_KEY
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**❌ Never hardcoded:**
|
|
110
|
+
```python
|
|
111
|
+
# Don't - visible in logs/code
|
|
112
|
+
mi = MemoryIntelligence(api_key='mi_sk_live_...')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**For web apps:** Use your API key in the backend, build your own endpoints with your auth, let your frontend call those.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## What Makes This Different
|
|
120
|
+
|
|
121
|
+
| Others | Memory Intelligence |
|
|
122
|
+
|--------|---------------------|
|
|
123
|
+
| Store text, embed, hope | Extract meaning first |
|
|
124
|
+
| "Here are similar chunks" | "Here's why this matched" |
|
|
125
|
+
| No audit trail | Cryptographic provenance |
|
|
126
|
+
| Your data = their model training | We never train on your data |
|
|
127
|
+
|
|
128
|
+
**Setting the standard for memory.**
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Core Operations
|
|
133
|
+
|
|
134
|
+
Eight verbs, mapped one-to-one onto the public API:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
note = mi.capture(content, source="notes") # POST /v1/process
|
|
138
|
+
hits = mi.ask(query, limit=5) # POST /v1/memories/query
|
|
139
|
+
note = mi.get(umo_id) # GET /v1/memories/{id}
|
|
140
|
+
notes = mi.list(limit=20) # GET /v1/memories
|
|
141
|
+
proof = mi.verify(umo_id) # GET /v1/memories/{id}/proof
|
|
142
|
+
why = mi.explain(umo_id) # GET /v1/memories/{id}/explain
|
|
143
|
+
receipt = mi.forget(umo_id) # DELETE /v1/memories/{id}
|
|
144
|
+
notes = mi.batch(["note one", "note two"]) # POST /v1/batch
|
|
145
|
+
note = mi.upload("meeting.mp3") # POST /v1/upload
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Results come back as small typed objects (`Memory`, `Match`, `Proof`, `Receipt`),
|
|
149
|
+
each with a `.raw` escape hatch and item access, so `note.id` when it is clean and
|
|
150
|
+
`note["quality_score"]` when you need a field we did not surface.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Async Support
|
|
155
|
+
|
|
156
|
+
An async twin of the flat client (`AsyncMemoryIntelligence`) is on the roadmap.
|
|
157
|
+
Until then, the async surface is the older `AsyncMemoryClient` (the `mi.umo.*`
|
|
158
|
+
namespace, deprecated alongside `MemoryClient`):
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from memoryintelligence import AsyncMemoryClient
|
|
162
|
+
|
|
163
|
+
async with AsyncMemoryClient.from_env() as mi:
|
|
164
|
+
results = await mi.umo.search(query, user_ulid="01ABC...")
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Error Handling
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from memoryintelligence import (
|
|
173
|
+
MIError, AuthenticationError, NotFoundError, RateLimitError, ValidationError,
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
try:
|
|
177
|
+
hits = mi.ask(query)
|
|
178
|
+
except AuthenticationError:
|
|
179
|
+
... # API key invalid or expired
|
|
180
|
+
except NotFoundError:
|
|
181
|
+
... # no memory with that id
|
|
182
|
+
except RateLimitError:
|
|
183
|
+
... # the client already retried with backoff
|
|
184
|
+
except ValidationError as e:
|
|
185
|
+
... # request shape was wrong
|
|
186
|
+
except MIError as e:
|
|
187
|
+
print(e.status, e) # any API error carries its status
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Typed Everywhere
|
|
193
|
+
|
|
194
|
+
Full Pydantic models. Type hints on every method. No `dict` soup.
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from memoryintelligence import Memory, Match, Proof
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Examples & Docs
|
|
203
|
+
|
|
204
|
+
- **[Getting Started Guide](https://github.com/memoryintelligence/memoryintelligence-python-sdk/tree/main/docs/GETTING-STARTED.md)** — Full walkthrough
|
|
205
|
+
- **[FastAPI Integration](https://github.com/memoryintelligence/memoryintelligence-python-sdk/tree/main/examples/fastapi_app.py)** — Complete example
|
|
206
|
+
- **[Advanced Usage](https://github.com/memoryintelligence/memoryintelligence-python-sdk/tree/main/docs/ADVANCED.md)** — Batch processing, retry logic, custom configs
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Support
|
|
211
|
+
|
|
212
|
+
- **Docs:** [memoryintelligence.io/docs](https://memoryintelligence.io/docs)
|
|
213
|
+
- **Issues:** [github.com/memoryintelligence/memoryintelligence-python-sdk/issues](https://github.com/memoryintelligence/memoryintelligence-python-sdk/issues)
|
|
214
|
+
- **Beta:** [memoryintelligence.io/beta](https://memoryintelligence.io/beta)
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
**Memory Intelligence™** — Setting the standard for memory.
|
|
219
|
+
|
|
220
|
+
Built by [somewhere](https://somewheremedia.com)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
memoryintelligence/__init__.py,sha256=wUVGDGp02yRrbb7U5BeZhaucW0hwCjc1Q_NHtrmeBfI,1579
|
|
2
|
+
memoryintelligence/_auth.py,sha256=zvgI2Fo5WjxiAckP9lRIYYitqzJhOAPL6wspo881Nuo,8664
|
|
3
|
+
memoryintelligence/_errors.py,sha256=-GxVqZkc7FdU8s_GKfB7mc8kmCOVPHTEIPTpKpqcxMM,6168
|
|
4
|
+
memoryintelligence/_http.py,sha256=RhPTV024dRL1J_PxsvcJE0iA__N_EGhXmxohrjQFr8M,14462
|
|
5
|
+
memoryintelligence/_simple.py,sha256=GAX-qYJH3TtFVcqbqC_bdP8vIrGGL9e549zRF3J42uo,11815
|
|
6
|
+
memoryintelligence/_version.py,sha256=q5Y7I3-OKUvbx6WVmu60NV9BiRldLC0gNt5dRvt93x4,62
|
|
7
|
+
memoryintelligence/py.typed,sha256=tipAbxnkxwswNZuJUzl8r0GLJZ8YN4aU5SieSXdwxkM,61
|
|
8
|
+
memoryintelligence-0.1.0.dist-info/licenses/LICENSE,sha256=2mzz0DJdCoNdgUXVcDxIr1o1LMnNdkJEIQj7HSNnsrw,1537
|
|
9
|
+
memoryintelligence-0.1.0.dist-info/METADATA,sha256=VEe92bBuGQT3AzJGC58nJNxGLwDSsrSUoBQj-rovvNs,7460
|
|
10
|
+
memoryintelligence-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
11
|
+
memoryintelligence-0.1.0.dist-info/top_level.txt,sha256=jQxLND_7L23jp0FCpvuTv-Pf9qw64yMBkUsovU1WGpk,19
|
|
12
|
+
memoryintelligence-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
MIT License with Attribution Requirement
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Memory Intelligence
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. Applications using this SDK MUST display "Powered by Memory Intelligence"
|
|
16
|
+
attribution in their user interface or documentation.
|
|
17
|
+
|
|
18
|
+
3. This SDK may only be used to interact with official Memory Intelligence API
|
|
19
|
+
services. No reverse engineering of the API or unauthorized replication of
|
|
20
|
+
the service is permitted.
|
|
21
|
+
|
|
22
|
+
4. API access credentials (API keys) are non-transferable and may not be
|
|
23
|
+
resold or sublicensed.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
memoryintelligence
|