How to set custom categories?

You can now create custom categories tailored to your specific needs, instead of using the default categories such as travel, sports, music, and more (see default categories below). When custom categories are provided, they will override the default categories.

There are two ways to set custom categories:

1. Project Level

You can set custom categories at the project level, which will be applied to all memories added within that project. Mem0 will automatically assign relevant categories from your custom set to new memories based on their content. Setting custom categories at the project level will override the default categories.

Here’s how to set custom categories:

from mem0 import MemoryClient

client = MemoryClient(api_key="<your_mem0_api_key>")

# Update custom categories
new_categories = [
    {"lifestyle_management_concerns": "Tracks daily routines, habits, hobbies and interests including cooking, time management and work-life balance"},
    {"seeking_structure": "Documents goals around creating routines, schedules, and organized systems in various life areas"},
    {"personal_information": "Basic information about the user including name, preferences, and personality traits"}
]

response = client.update_project(custom_categories = new_categories)
print(response)

This is how you will use these custom categories during the add API call:

messages = [
    {"role": "user", "content": "My name is Alice. I need help organizing my daily schedule better. I feel overwhelmed trying to balance work, exercise, and social life."},
    {"role": "assistant", "content": "I understand how overwhelming that can feel. Let's break this down together. What specific areas of your schedule feel most challenging to manage?"},
    {"role": "user", "content": "I want to be more productive at work, maintain a consistent workout routine, and still have energy for friends and hobbies."},
    {"role": "assistant", "content": "Those are great goals for better time management. What's one small change you could make to start improving your daily routine?"},
]

# Add memories with custom categories
client.add(messages, user_id="alice")

You can also retrieve the current custom categories:

# Get current custom categories
categories = client.get_project(fields=["custom_categories"])
print(categories)

These project-level categories will be automatically applied to all new memories added to the project.

2. During the add API call

You can also set custom categories during the add API call. This will override any project-level custom categories for that specific memory addition. For example, if you want to use different categories for food-related memories, you can provide custom categories like “food” and “user_preferences” in the add call. These custom categories will be used instead of the project-level categories when categorizing those specific memories.

from mem0 import MemoryClient

client = MemoryClient(api_key="<your_mem0_api_key>")

custom_categories = [
    {"seeking_structure": "Documents goals around creating routines, schedules, and organized systems in various life areas"},
    {"personal_information": "Basic information about the user including name, preferences, and personality traits"}
]

messages = [
    {"role": "user", "content": "My name is Alice. I need help organizing my daily schedule better. I feel overwhelmed trying to balance work, exercise, and social life."},
    {"role": "assistant", "content": "I understand how overwhelming that can feel. Let's break this down together. What specific areas of your schedule feel most challenging to manage?"},
    {"role": "user", "content": "I want to be more productive at work, maintain a consistent workout routine, and still have energy for friends and hobbies."},
    {"role": "assistant", "content": "Those are great goals for better time management. What's one small change you could make to start improving your daily routine?"},
]

client.add(messages, user_id="alice", custom_categories=custom_categories)
Providing more detailed and specific category descriptions will lead to more accurate and relevant memory categorization.

Default Categories

Here is the list of default categories. If you don’t specify any custom categories using the above methods, these will be used as default categories.

- personal_details
- family
- professional_details
- sports
- travel
- food
- music
- health
- technology
- hobbies
- fashion
- entertainment
- milestones
- user_preferences
- misc
from mem0 import MemoryClient

client = MemoryClient(api_key="<your_mem0_api_key>")

messages = [
    {"role": "user", "content": "Hi, my name is Alice."},
    {"role": "assistant", "content": "Hi Alice, what sports do you like to play?"},
    {"role": "user", "content": "I love playing badminton, football, and basketball. I'm quite athletic!"},
    {"role": "assistant", "content": "That's great! Alice seems to enjoy both individual sports like badminton and team sports like football and basketball."},
    {"role": "user", "content": "Sometimes, I also draw and sketch in my free time."},
    {"role": "assistant", "content": "That's cool! I'm sure you're good at it."}
]

# Add memories with default categories
client.add(messages, user_id='alice')

You can check whether default categories are being used by calling get_project(). If custom_categories returns None, it means the default categories are being used.

client.get_project(["custom_categories"])

If you have any questions, please feel free to reach out to us using one of the following methods: