HAEMA memory framework built on ChromaDB
Project description
HAEMA
HAEMA is a memory framework for agents built on ChromaDB.
It manages three memory modes behind one simple API:
core memory: stable high-impact information (get_core)latest memory: recent memory slices by timestamp (get_latest)long-term memory: semantic search (search)
You only write through add(contents). HAEMA updates all layers automatically.
Features
- Single write API (
add) for all memory layers - ChromaDB-backed long-term memory (
collection="memory") - Core memory kept as human-readable markdown (
core.md) - LLM/Embedding provider abstraction via client interfaces
- Automatic merge-and-replace behavior for related memories
- Conservative core updates with structured schema outputs
Installation
pip install haema
Development install:
pip install -e ".[dev]"
Quick Start
from haema import Memory
m = Memory(
path="./haema_store", # directory root; creates ./haema_store/db and ./haema_store/core.md
output_dimensionality=1536,
embedding_client=..., # your EmbeddingClient implementation
llm_client=..., # your LLMClient implementation
)
m.add([
"The user prefers concise and actionable responses.",
"The user is building HAEMA on top of ChromaDB.",
])
print(m.get_core()) # str
print(m.get_latest(begin=1, count=5)) # list[str]
print(m.search("user preference", 3)) # list[str]
For a real provider integration example, see:
examples/google_genai_example.py
Public API
Constructor
Memory(path, output_dimensionality, embedding_client, llm_client, merge_top_k=5, merge_distance_cutoff=0.25)
path: storage root directoryoutput_dimensionality: embedding output dimensionembedding_client: user-implemented embedding adapterllm_client: user-implemented structured LLM adaptermerge_top_k: max candidates to consider as related memorymerge_distance_cutoff: related-memory threshold for cosine distance
Methods
get_core() -> strget_latest(begin: int, count: int) -> list[str]search(content: str, n: int) -> list[str]add(contents: list[str]) -> None
Client Interfaces
You implement both abstract clients:
EmbeddingClient.embed(texts, output_dimensionality) -> np.ndarrayLLMClient.generate_structured(system_prompt, user_prompt, response_model) -> dict[str, Any]
Embedding contract:
- return 2D
numpy.ndarray - dtype
float32 - shape
(len(texts), output_dimensionality)
LLM contract:
- return a JSON-like
dictparseable byresponse_model - HAEMA retries structured parsing up to 3 attempts
- fallback path is applied after repeated parsing failure
Storage Layout
Given path="./haema_store":
- long-term vector DB:
./haema_store/db - core markdown:
./haema_store/core.md
Long-term memory metadata includes:
timestamp(UTC ISO8601, e.g.2026-02-21T03:20:00Z)timestamp_ms(Unix epoch milliseconds)
How add() Works
- Normalize input strings and batch-embed contents
- Query related memories with
top_k + distance cutoff - If related memories exist:
- synthesize updated memories via LLM
- upsert synthesized memories
- delete previous related memories
- If no related memories exist:
- reconstruct one or more memories from new content
- upsert reconstructed memories
- Update
core.mdonce after processing all input contents
Documentation
docs/index.md- docs entrypointdocs/usage.md- usage and provider integration patternsdocs/api.md- API behavior and edge casesdocs/architecture.md- internal memory flowdocs/release.md- GitHub Actions + PyPI release flow
Release
PyPI publishing is automated by:
.github/workflows/publish-pypi.yml
Trigger by pushing a tag like v0.1.0.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haema-0.1.0.tar.gz.
File metadata
- Download URL: haema-0.1.0.tar.gz
- Upload date:
- Size: 66.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d3b2fc2700048709159a96f3ad835d86b138bf131df8fe0f4da14be437e11d5
|
|
| MD5 |
841cd7b0c633502f7a6e6ebd801adfed
|
|
| BLAKE2b-256 |
b0be9b6b64b8ad3c60bfa441fa2238eded558d4e03bd7713a058928e52b0e38e
|
Provenance
The following attestation bundles were made for haema-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on smturtle2/haema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
haema-0.1.0.tar.gz -
Subject digest:
6d3b2fc2700048709159a96f3ad835d86b138bf131df8fe0f4da14be437e11d5 - Sigstore transparency entry: 975610952
- Sigstore integration time:
-
Permalink:
smturtle2/haema@c1606ed4ea4cc501fec6244e8cd307221d459621 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c1606ed4ea4cc501fec6244e8cd307221d459621 -
Trigger Event:
push
-
Statement type:
File details
Details for the file haema-0.1.0-py3-none-any.whl.
File metadata
- Download URL: haema-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ac9cbc16e5b6c9524bdafcb9e7cc24e8ecada8200bc4a1cb525ed45f7e4ce8
|
|
| MD5 |
c03794a8ddd86a59e1d7627dc0288a4e
|
|
| BLAKE2b-256 |
3596089a270f1b7f404da7fee0e00977bad98193f0897b70e613232a324fad2c
|
Provenance
The following attestation bundles were made for haema-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on smturtle2/haema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
haema-0.1.0-py3-none-any.whl -
Subject digest:
21ac9cbc16e5b6c9524bdafcb9e7cc24e8ecada8200bc4a1cb525ed45f7e4ce8 - Sigstore transparency entry: 975610954
- Sigstore integration time:
-
Permalink:
smturtle2/haema@c1606ed4ea4cc501fec6244e8cd307221d459621 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/smturtle2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c1606ed4ea4cc501fec6244e8cd307221d459621 -
Trigger Event:
push
-
Statement type: