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 5 commits into
base: main
Choose a base branch
from

Conversation

spike-spiegel-21
Copy link
Collaborator

@spike-spiegel-21 spike-spiegel-21 commented Sep 22, 2024

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

@spike-spiegel-21
Copy link
Collaborator 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
Collaborator Author

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

@spike-spiegel-21
Copy link
Collaborator Author

Hi @deshraj @prateekchhikara, I have done the validation using pydantic for CustomCategories. The changes seems better. Please review. Thanks

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