Install Mem0 and the three pieces it needs
Mem0 is one install, and behind it are three moving parts. Knowing which is which makes every error message in this course readable.
pip install mem0ai langchain langchain-coremem0ai is the library. The two langchain packages are not a dependency of it; they are how this course puts its own model and embedder in, which lesson 7 explains.
The three pieces
All three are swappable and all three have defaults. The defaults are the problem: the model and the embedder are both OpenAI, so a bare Memory() wants an API key before it will do anything at all.
Seeing the defaults
from mem0.configs.base import MemoryConfig
config = MemoryConfig()
print("model ", config.llm.provider)
print("embedder ", config.embedder.provider)
print("store ", config.vector_store.provider)Two of the three want a key. The store is Qdrant, which is the one piece that already runs locally, so it is the one piece this course does not have to replace.
What we are replacing
The model and the embedder, with about forty lines of Python between them. Not with a mock: with real implementations of the interfaces Mem0 calls, so everything downstream behaves exactly as it would with a paid model behind it.
Before writing them, it is worth finding out what Mem0 actually asks a model for. That is the next lesson, and the answer is more interesting than you would expect.
- Run the snippet above and note the three provider names.
- Run
python -c "from mem0 import Memory; Memory()"with no key set and read the error. - Find
mem0/configs/base.pyin your site-packages and look at what elseMemoryConfigholds.
Slow is fine. Stopping is the only problem.