mem0ai / mem0

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

Custom Categories example from docs does not work #1863

Open uahmad235 opened 3 weeks ago

uahmad235 commented 3 weeks ago

🐛 Describe the bug

I am trying to reuse this example from docs in order to create custom categories but it throws error. Here's my code:

custom_categories = [
    {"cooking": "For users interested in cooking, including recipes, cooking tips, and culinary experiences."},
    {"fitness": "Includes content related to fitness, such as workouts, exercises, and fitness tips."}
]

messages = [
    {"role" : "user", "content" : "Hi, my name is Alice. I love to play badminton."},
    {"role" : "assistant", "content" : "Hello Alice! It's nice to meet you. Badminton is such an amazing sport. How can I assist you today?"},
    {"role" : "user", "content" : "I am a fitness freak, I go to gym daily."},
    {"role" : "assistant", "content" : "That's great! Regular exercise is very beneficial for health."},
    {"role" : "user", "content" : "Because of my gym plan, I mostly cook at home."},
    {"role" : "assistant", "content" : "Cooking at home is a good way to ensure you have a balanced diet."}
]
config = {
"llm":  # defining secrets for llm
"embedder":  # secrets for embedder
}

from mem0 import Memory
m = Memory.from_config(config)
m.add(messages, user_id="alice", custom_categories=custom_categories)

Here's the error I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-4-615dd71b2dd0>](https://localhost:8080/#) in <cell line: 1>()
----> 1 m.add(messages, user_id="alice", custom_categories=custom_categories)

TypeError: Memory.add() got an unexpected keyword argument 'custom_categories'
ketangangal commented 3 weeks ago

Hello @uahmad235 ,

Mem0 add method does not support this key, docs need updates.

FYI @deshraj @Dev-Khant if this feature is required or in pipeline i can work on it.

uahmad235 commented 3 weeks ago

Hey @ketangangal Is this completely deprecated or moved to a different API?

Dev-Khant commented 3 weeks ago

Hey @uahmad235, The doc refers to use custom_categories for the platform and not OSS package. So you can switch to platform by passing api_key in order to use custom_categories.