mem0
mem0 copied to clipboard
milvus cannot add to the database when passing the list message
🐛 Describe the bug
When using Milvus, it is unable to insert into the database when passing in List[Dict], but it works when using strings. Below is the reproduction example:
import os
from mem0 import Memory
os.environ["OPENAI_API_KEY"] = "xxxx-xxxx-xxxx"
config = {
"embedder": {
"provider": "huggingface",
"config": {"huggingface_base_url": "http://xx.xx.xx.xx:xx/v1"},
},
"llm": {
"provider": "openai",
"config": {
"model": "gpt-4o",
},
},
"vector_store": {
"provider": "milvus",
"config": {
"collection_name": "test",
"embedding_model_dims": "1024",
"url": "http://localhost:19530",
}
}
}
m = Memory.from_config(config)
messages = [
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
{"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."},
{"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})
print(m.get_all(user_id="alice"))
# Output:
# {'results': []}
for i in messages:
m.add(i["content"], user_id="alice", metadata={"category": "movies"})
print(m.get_all(user_id="alice"))
# Output:
# {'results': [{'id': '44fcb6e0-6387-4c8d-b3ee-67d2e47b7e56', 'memory': 'Loves sci-fi movies', 'hash': '1110b1af77367917ea2022355a16f187', 'metadata': {'category': 'movies'}, 'created_at': '2025-06-16T05:33:19.842249-07:00', 'updated_at': None, 'user_id': 'alice'}, {'id': '5273f81c-7ada-4dab-b6f8-f906cec75086', 'memory': 'Planning to watch a movie tonight', 'hash': 'bf55418607cfdca4afa311b5fd8496bd', 'metadata': {'category': 'movies'}, 'created_at': '2025-06-16T05:33:19.811694-07:00', 'updated_at': None, 'user_id': 'alice'}, {'id': 'f11f77ed-03d7-4f2c-815f-67d9844d36c3', 'memory': 'Not a big fan of thriller movies', 'hash': '028dfab4483f28980e292f62578d3293', 'metadata': {'category': 'movies'}, 'created_at': '2025-06-16T05:33:19.830723-07:00', 'updated_at': '2025-06-16T05:33:39.545126-07:00', 'user_id': 'alice'}]}