Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Custom categories added #1894

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

spike-spiegel-21
Copy link
Contributor

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_category  = [
        {"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."}     
]
custom_category_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_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
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_category  = [
        {"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."}     
]
custom_category_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_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice3", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice3", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice3", custom_category=custom_category, custom_category_filter=custom_category_filter)
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_category  = [
        {"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."}     
]
custom_category_filter =  "restrict"  # Can be "restrict", "extend", or "omit"
m.add("Alice enjoys hiking, favors using Python for backend development, and prefers budgeting apps to manage her finances.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is passionate about front-end development with React and spends her weekends exploring new restaurants.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice loves reading historical fiction, excels in writing efficient Python scripts, and is an avid traveler.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)
m.add("Alice is a fan of indie films and enjoys practicing yoga.", user_id="alice1", custom_category=custom_category, custom_category_filter=custom_category_filter)

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

@spike-spiegel-21
Copy link
Contributor Author

spike-spiegel-21 commented Sep 22, 2024

Hi @Dev-Khant Let me know if I want to change prompt or add something.

@spike-spiegel-21
Copy link
Contributor Author

Hi @deshraj @prateekchhikara Let me know if we need any improvements. Will work on TCs post finalisations of prompts and flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Categories example from docs does not work
1 participant