[feat]: Custom categories added
Potential fix: #1863 Feature replicating: https://docs.mem0.ai/features/custom-categories
Could be tested using: Filter: "restrict"
# Initialize Memory with the configuration
m = Memory.from_config(config)
custom_categories = {
"categories" : [
{"financial": "Includes content related to personal finance, investing strategies, saving tips, market trends, and financial planning."},
{"programming": "For users interested in programming, including tutorials, coding tips, language-specific content, and software development best practices."}
],
"filter": "restrict"
}
m.add("Alice enjoys hiking, favors using Python for backend development, and prefers budgeting apps to manage her finances.", user_id="alice1", custom_categories=custom_categories)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice1", custom_categories=custom_categories)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice1", custom_categories=custom_categories)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice1", custom_categories=custom_categories)
memories=m.get_all(user_id="alice1")
Output:
#memories
Passionate about front-end development with React
Alice excels in writing efficient Python scripts
Prefers budgeting apps to manage her finances
Name is Alice
Favors using Python for backend development
Filter: "omit"
custom_categories = {
"categories" : [
{"financial": "Includes content related to personal finance, investing strategies, saving tips, market trends, and financial planning."},
{"programming": "For users interested in programming, including tutorials, coding tips, language-specific content, and software development best practices."}
],
"filter": "omit"
}
m.add("Alice enjoys hiking, favors using Python for backend development, and prefers budgeting apps to manage her finances.", user_id="alice3", custom_categories=custom_categories)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice3", custom_categories=custom_categories)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice3", custom_categories=custom_categories)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice3", custom_categories=custom_categories)
memories=m.get_all(user_id="alice3")
Output
#memories
Alice is passionate about front-end development with React
Alice loves reading historical fiction
Alice is an avid traveler
Alice is a fan of indie films
Alice enjoys practicing yoga
Alice spends her weekends exploring new restaurants
Alice enjoys hiking
Filter: "extend"
custom_categories = {
"categories" : [
{"financial": "Includes content related to personal finance, investing strategies, saving tips, market trends, and financial planning."},
{"programming": "For users interested in programming, including tutorials, coding tips, language-specific content, and software development best practices."}
],
"filter": "extend"
}
m.add("Alice enjoys hiking, favors using Python for backend development, and prefers budgeting apps to manage her finances.", user_id="alice1", custom_categories=custom_categories)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice1", custom_categories=custom_categories)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice1", custom_category=custom_categories=custom_categories)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice1", custom_categories=custom_categories)
Output:
Alice excels in writing efficient Python scripts
Alice spends her weekends exploring new restaurants
Alice favors using Python for backend development
Alice is a fan of indie films
Alice is passionate about front-end development with React
Alice enjoys practicing yoga
Alice enjoys hiking
Alice loves reading historical fiction
Alice prefers budgeting apps to manage her finances
Alice is an avid traveler
Hi @Dev-Khant Let me know if I want to change prompt or add something.
Hi @deshraj @prateekchhikara Let me know if we need any improvements. Will work on TCs post finalisations of prompts and flow.
Hi @deshraj @prateekchhikara, I have done the validation using pydantic for CustomCategories. The changes seems better. Please review. Thanks
Closing this PR as it's not required right now.