mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
21.6k stars 1.97k forks source link

Make home and mem0 dirs configurable so that the service can work on AWS lambda. #1726

Closed maxvonhippel closed 3 weeks ago

maxvonhippel commented 3 weeks ago

Description

If you try to use mem0 in a lambda function, you'll get a nasty warning like

OSError: [Errno 30] Read-only file system: '/home/sbx_user1051'
bla bla bla
in <module>
from mem0.memory.main import Memory
in <module>
from mem0.memory.setup import setup_config\n/tmp/mem0/memory/setup.py:8:
in <module>
os.makedirs(mem0_dir, exist_ok=True)
<frozen os>
bla bla bla
[Errno 30] Read-only file system

This is because ~ is read-only on a lambda function. However, /tmp is writeable, as is any mounted EFS directory. Therefore, if we simply expose the home and mem0 directories in the code to be injectable as environment variables, we can easily resolve this issue by injecting e.g., /tmp/mem0.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

I tested the or logical locally but didn't actually test it in a lambda function to confirm that it resolves the bug. That being said, I think the ability to configure these directories is broadly desirable for users, regardless of whether or not it fully resolves adding AWS lambda support. (I discovered this issue while trying to get Benchify to work for a customer who uses mem0 in their product.)

Checklist:

CLAassistant commented 3 weeks ago

CLA assistant check
All committers have signed the CLA.

deshraj commented 3 weeks ago

Thanks for adding this feature.