-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Hotfix mem0 #854
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
Hotfix mem0 #854
Conversation
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.
Please see inline comments
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.
Pull Request Overview
This pull request fixes the message role assignment in Mem0LongTermMemory's record_to_memory method. Previously, all recorded messages were hardcoded as "assistant" role. Now, when a user_id is provided during initialization, messages are correctly recorded with "user" role, otherwise they use "assistant" role.
Key Changes:
- Fixed role assignment logic in
record_to_memoryto dynamically set role based onuser_idpresence - Updated example to use text-embedding-v3 with explicit dimensions configuration
- Simplified and restructured README documentation for better clarity
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/agentscope/memory/_mem0_long_term_memory.py | Added conditional logic to set message role based on user_id presence |
| examples/functionality/long_term_memory/mem0/memory_example.py | Updated embedding model version, added vector store configuration, and improved system prompt |
| examples/functionality/long_term_memory/mem0/README.md | Restructured documentation to be more concise and user-friendly |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
LGTM
AgentScope Version
[The version of AgentScope you are working on, e.g.
import agentscope; print(agentscope.__version__)]Description
in Mem0LongTermMemoy, record_to_memory: if user_id is provided, the content will be stored as user's memory
if self.user_id is not None:
message_role = "user"
else:
message_role = "assistant"
# here set infer to False to force the memory to be recorded as is
results = await self._mem0_record(
[
{
"role": message_role,
"content": "\n".join(content),
"name": message_role,
},
],
**kwargs,
)
Checklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand