Repository navigation
feat!: rewrite to the current Mnemo API contract (0.2.0) - #2
Merged
Merged
Conversation
The published 0.1.2 predates the container-scoped API and every request it
sends is rejected: POST /v1/memories got {content} instead of
{containerTag, items:[...]}, POST /v1/search got {query} instead of {q},
and responses were parsed as hits/workspaceId which no longer exist.
- Containers are now first-class: default_container_tag on the client
(env GETMNEMO_CONTAINER_TAG) or container_tag per call, format <type>:<id>
- add() posts {containerTag, items:[{content, metadata?}]} and returns the
typed AddResponse (items, stats, receipt); new add_many() for 1-100 items
- search() posts {q, containerTag, limit?} and returns list[SearchHit]
with the real response fields (resultType, score, scopeKey, polarity, ...)
- search() treats 404 'Container not found' as empty results and tolerates
the upcoming empty-array response shape
- workspace_id is deprecated-optional: identity comes from the API key;
the x-workspace-id header is only sent when explicitly configured
- actor_id removed everywhere (no longer part of the API)
- update/delete/list thread the container as query params
- canonical import is now 'getmnemo' (matches the install name and the
LangChain adapter); 'mnemo' remains as a back-compat alias module
- tests pin the wire shapes: bodies carry ONLY API-accepted keys
(unknown-key regression), 404->[] on search, env fallbacks, both clients
3 of 4 tasks
…n retried writes - search (sync + async) returns [] only when a 404 body message says 'Container not found'; any other 404 raises MnemoHTTPError - add/add_many generate a per-item uuid4 idempotencyKey when the caller gave none and retries are enabled; the payload is built once, so every retry carries the same key (no duplicate writes on 5xx/429/transport retries)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Rewrites the Python SDK to the live API contract, mirroring the TS
getmnemo0.6 surface in Pythonic form. Breaking release: 0.1.2 → 0.2.0.Why
The published 0.1.2 is incompatible with the API — every call fails:
POST /v1/memoriessent{content}; the API wants{containerTag|scope, items:[{content, metadata?}]}and the global ValidationPipe 400s unknown keysPOST /v1/searchsent{query}; the API wants{q, containerTag, limit?}and returns{results: [...]}, nothitsworkspace_idwas required and models expectedworkspaceId/actorId, which no longer exist (identity comes from the API key)Changes
Mnemo(api_key, *, default_container_tag=None, workspace_id=None (deprecated, header only when given), base_url=None, ...); env fallbacksGETMNEMO_API_KEY/GETMNEMO_CONTAINER_TAG/GETMNEMO_WORKSPACE_IDadd(content, *, container_tag=None, metadata=None)→AddResponse(items/stats/receipt); newadd_many(items, *, container_tag=None)for 1–100 items with client-side unknown-key rejectionsearch(q, *, container_tag=None, limit=None)→list[SearchHit]typed from the realSearchResultDtofields; 404 "Container not found" →[](and tolerates the in-flight empty-array change)"<type>:<id>"formatactor_iddropped everywhere;update/delete/listthread the container as query paramsgetmnemo(matches the install name, the LangChain adapter, and the docs);mnemostays as a back-compat alias module — note the published 0.1.2 wheel only shippedmnemo, sofrom getmnemo import ...was broken until nowTest plan
pytest— 16 passed (Python 3.9.6, the floor ofrequires-python)ruff check src tests— cleanmypy src(strict) — clean[]covered sync + async; future 200+empty-results shape coveredDeferred
scopeobject form ({type, id, tags}) — containerTag covers the SDK surface for nowsecrets.PYPI_TOKENvia twine on tagv*; left untouched)Do not merge/tag/publish — release prep only.