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

Support Custom Prompt for Memory Action Decision #2371

Merged
merged 7 commits into from
Mar 18, 2025

Conversation

rst0070
Copy link
Contributor

@rst0070 rst0070 commented Mar 13, 2025

Description

The feature allows customizing the prompt used to determine memory actions - (whether to ADD, UPDATE, DELETE, or NONE).

Motivation and context

  • Currently, the prompt that decides which memory action to take(ADD, UPDATE, DELETE, NONE) is fixed and cannot be customized.
  • In some use cases, the default behavior may not fit the developer's needs.

Summary of changes

  • config for memory initialization to set custom_update_memory_prompt which is the prompt determining memory action
  • mem0.configs.prompts.get_update_memory_messages function and related codes to it

In my work, the code appends a suffix to custom_update_memory_prompt to force structured output, but it can be done another way if maintainers think that's more appropriate.

Fixes #2366

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

Copy link

vercel bot commented Mar 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
multimodal-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 18, 2025 3:55am

@rst0070
Copy link
Contributor Author

rst0070 commented Mar 13, 2025

@Dev-Khant Could you please take a look at this change? I'd love to hear your thoughts on this

Copy link
Member

@Dev-Khant Dev-Khant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rst0070 We should change the name of custom_prompt to custom_fact_extraction_prompt and a doc for it on how it works. Because the current names custom_prompt and custom_update_memory_prompt would be confusing to users.

@rst0070
Copy link
Contributor Author

rst0070 commented Mar 18, 2025

Hey @rst0070 We should change the name of custom_prompt to custom_fact_extraction_prompt and a doc for it on how it works. Because the current names custom_prompt and custom_update_memory_prompt would be confusing to users.

Thanks for the review! I will apply the change soon!

Copy link
Member

@Dev-Khant Dev-Khant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rst0070 Thanks for quickly making the changes! PR looks good to me.

@Dev-Khant Dev-Khant merged commit 66d3f9b into mem0ai:main Mar 18, 2025
7 of 9 checks passed
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.

Support Custom Prompt for Memory Action Decision
2 participants