Prism Memory for Python
Persistent context, semantic recall and the vector-store contract. The Python
port of particle-academy/prism-memory.
Zero runtime dependencies. Python 3.10+.
pip install prism-ai-memory
from prism_memory import (
InMemoryVectorStore,
RecallSettings,
Vector,
VectorRecord,
Weighting,
recall,
)
store = InMemoryVectorStore()
store.upsert(
[
VectorRecord(
id="m-1",
collection="user:7",
content="Billing address is 12 Harbour Road.",
created_at=1_789_000_000,
vector=Vector.of(embedding),
embedding_model="text-embedding-3-small",
),
]
)
found = recall(
store,
["user:7"],
Vector.of(query_embedding),
RecallSettings(limit=5, weighting=Weighting(relevance=0.8, recency=0.2)),
now=1_789_100_000,
)
for memory in found.memories:
print(memory.score, memory.record.content)
The package does not call an embedding model. Pass the vectors your provider returns.
Vectors
Vector.of() validates every component. An empty vector, a value that is not a
number, a NaN or infinity, a zero vector, or one too large to score is refused
with MemoryError code invalid_vector, when the vector is built rather than
when something first scores against it.
to_storage() and from_storage() use base64 of little-endian 64-bit floats,
byte for byte the format the PHP reference writes. A PHP, Python or TypeScript
application can read the others' rows.
Recall
recall() asks the store for limit × overfetch candidates by similarity, then
rescores them with the Weighting and returns the top limit.
Weighting(relevance, recency, half_life_seconds)mixes similarity with an exponential recency decay. The default is relevance alone. Weights are normalised, somin_scoremeans the same thing whatever the mix.- Every
similaritya caller sees is an exact cosine. filtermatches metadata keys by equality; a list means any of.
BinarySignature turns a vector into a short bit signature (256 bits by
default) for picking candidates without reading the full vectors. The planes are
deterministic, so every process computes the same signature for the same vector.
Stores
VectorStore is a Protocol: upsert, search, forget, purge,
purge_observed_before, count, unembedded and durability.
InMemoryVectorStore keeps records in this process and reports itself
volatile. It refuses to mix vectors from two embedding models in one
collection, with code embedding_space_mismatch. For a real deployment,
implement VectorStore over your database and declare its durability().
Errors
Every failure is a MemoryError with a stable code: invalid_vector,
dimension_mismatch, embedding_space_mismatch,
unsafe_memory_configuration, unstorable_memory. Match on the code, not the
message.
Parity
prism-parity's memory-vector-storage corpus pins the storage format and scoring
against the PHP reference and the TypeScript port.
License
MIT. See LICENSE.
Metadata
Release files for prism-ai-memory 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| prism_ai_memory-0.1.0.tar.gz | 10.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prism_ai_memory-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.3 kB
Release files / prism_ai_memory-0.1.0.tar.gz
| Download URL | prism_ai_memory-0.1.0.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5465e34acb9e786adf900f81fb287dbbd7b90aa05f5e8e35634798c34f59036
|
|
BLAKE2b-256 checksum How to use checksums |
e94ebd415ed2d4cac4b3c01c73a8db734702a9985ffccb7a09b9ab15f559fd30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / prism_ai_memory-0.1.0-py3-none-any.whl
| Download URL | prism_ai_memory-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71350ffa67dbc128e717131eb40bd2ca5759417777433701bc5479496d33b6d0
|
|
BLAKE2b-256 checksum How to use checksums |
1d772ba080cccccbfa2d8d27760bc9b5de63adb2537942073fd968dfa900abe0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency log