Migrate from Mem0
Keep your Mem0 calls, switch one import, and bring your memories with you.
Switch one import
Method names, keyword arguments and return shapes follow Mem0 2.x. Pass a SQLite path, a store or a database URL, as for Memory.
# from mem0 import Memory
from llmslim.memory.compat import Mem0Memory as Memory
memory = Memory("memory.db")
memory.add([{"role": "user", "content": "I moved to Pune last month."}], user_id="asha")
hits = memory.search("Where does Asha live?", filters={"user_id": "asha"})
for hit in hits["results"]:
print(hit["score"], hit["memory"])
print(hits["context"]) # the selected turns, ready for a promptWhat it does differently
The differences are deliberate, and they fail loudly rather than silently:
- Nothing is extracted.
addstores turns verbatim; every returned event isADD. searchselects the turns that answer the question within a tokenbudget(an LLMSlim extension, default 2,000), returns them ranked by a lexical overlapscore, and also returns the prompt-ready text under"context".rerank=Trueuses LLMSlim's optional cross-encoder (llmslim[semantic]);thresholdandexplainare ignored.- Filters match
user_id,agent_idandrun_idexactly, and at least one is required. Any other filter key raisesValueErrorinstead of being ignored. Scope ids go insidefilters, as Mem0 2.x requires. expiration_dateandreference_datearen't supported and raise.get_allreturns the newesttop_k(default 20) of a scope;historyreturns a turn's current state only, since there is no extraction history;resetraises, rather than deleting every user's memory.from_configignores LLM, embedder and vector-store settings; a{"store": path}entry selects a SQLite file.
Bring your memories
0.12 has no importer: add your memories with memory.add, one per call, under their user_id. 1.0 adds llmslim import mem0, which reads a Mem0 export directly: see the 1.0 preview.
When you're ready, use Memory itself
Mem0Memory wraps llmslim.memory.Memory, which has the rest: per-call budgets and time windows, sections for standing requests, preferences and conflicts, and the stores. See the Python quickstart.
Questions
Does it call an LLM when I add memories?
No. add stores each turn word for word and makes no model call, so infer, prompt and memory_type are accepted and ignored.
Does it cover Mem0's hosted client?
No. Mem0Memory follows the interface of Mem0's Memory class, the open-source library, in its 2.x shape.