Mem0mem0ai 2.0.20 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
24 small wins to finish your pathNext lesson

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.

bash
pip install mem0ai langchain langchain-core

mem0ai 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

What happens inside add()
A model reads the conversation. It decides what is worth keeping and writes each thing as a sentence.Step 1 of 3

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

Example
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.

Every error you will hit in the first hour is one of these three. A complaint about an API key is the model or the embedder. A complaint about dimensions is the embedder disagreeing with the store about vector length. A complaint about a provider name is the configuration, which lesson 7 covers.

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.

Try it yourself
  • 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.py in your site-packages and look at what else MemoryConfig holds.

Slow is fine. Stopping is the only problem.