mem0ai / mem0

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

How to save and load a database from local in mem0? #1643

Open lemon-little opened 1 month ago

lemon-little commented 1 month ago

Issue with current documentation:

Like embedchain reuse a vector database reuse embeddding

My code:

config = {
    "llm": {
        "provider": "openai",
        },
    "embedder": {
        "provider": "openai" 
        },
    "history_db_path": "/home/lcy/.mem0/history.db",
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "host": "localhost",
            "path": "/tmp/qdrant",
            "collection_name": "mem0",
        }
    }
}
memory = Memory().from_config(config)
all_memories = memory.get_all()

I can't reuse the local memory with the same code when I run the code.

zhurou603 commented 1 month ago

same problem as mine.https://github.com/mem0ai/mem0/issues/1623

Dev-Khant commented 1 month ago

Hey @lemon-little You actually can reuse the local memory but make sure the Memory is not initialized again, because that will recreate a new collection. @zhurou603 You can also try the same approach.

Let me know if you still face any issues.

zhurou603 commented 1 month ago

lemon-little

I can not understand 'local memory' means, I want to save my collections into disk(instead of memory), and close current process, maybe another process can load this collection.

lemon-little commented 1 month ago

Hey @lemon-little You actually can reuse the local memory but make sure the Memory is not initialized again, because that will recreate a new collection. @zhurou603 You can also try the same approach.嘿,@lemon小你实际上可以重用本地内存,但请确保内存不会再次初始化,因为这将重新创建一个新的集合。@zhurou603您也可以尝试相同的方法。

Let me know if you still face any issues.如果您仍然遇到任何问题,请告诉我。

How to reuse the local memory?

lemon-little commented 1 month ago

lemon-little 柠檬小

I can not understand 'local memory' means, I want to save my collections into disk(instead of memory), and close current process, maybe another process can load this collection.我无法理解“本地内存”的意思,我想将我的集合保存到磁盘(而不是内存)中,并关闭当前进程,也许另一个进程可以加载此集合。

But another process can't load the collection.

Dev-Khant commented 4 weeks ago

@lemon-little Please visit this doc and set on_disk param to True for persistent storage.

lishaozheng commented 2 weeks ago

https://github.com/mem0ai/mem0/pull/1677 这个就是本地存储的解决方案