-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat: multiple context injection modes mem0 #6850
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
base: main
Are you sure you want to change the base?
feat: multiple context injection modes mem0 #6850
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6850 +/- ##
==========================================
+ Coverage 79.92% 79.94% +0.01%
==========================================
Files 233 233
Lines 18108 18126 +18
==========================================
+ Hits 14473 14491 +18
Misses 3635 3635
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
chore: Export ContextInjectionMode enum fix: tests fix: format chore: remove mem0 deps to fix tests fix: patch of memory client fix: check we are dealing with a FunctionCall before accessing attributes fix: use public constructor fix: add empty line at end of file
d3c7e8b
to
61fafca
Compare
class ContextInjectionMode(Enum): | ||
"""Enum for context injection modes.""" | ||
|
||
SYSTEM_MESSAGE = "system_message" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add USER_MESSAGE
? Because it is naturally a choice if the model doesn't support system message in the middle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with adding a USER_MESSAGE
mode is that I think we'd then require a more opinionated message format to tell the LLM to use the memory retrieved but also don't reply as if the user actually sent them in a message.
"""Enum for context injection modes.""" | ||
|
||
SYSTEM_MESSAGE = "system_message" | ||
FUNCTION_CALL = "function_call" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description for each mode enum. Also, note that using the function call mode may cause problem with models that requires the tool definition to be available when calling the model.
Why are these changes needed?
Currently the mem0 memory implementation works by adding a system message to the context, however not all LLM support multiple non consecutive system messages.
This PR maintains the current behavior while adding a parameter to the constructor of the mem0 implementation that mocks an LLM making a tool call and mem0 returning relevant memories.
In other words, the system message in the conversation history is replaced by an AssistantMessage and a FunctionExecutionResultMessage.
Related issue number
Checks