-
Notifications
You must be signed in to change notification settings - Fork 4
feat(memory_collection): support AsyncMemory and add vector dimension… #38
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
Conversation
… configuration Change-Id: I715f9c34f82bd49bd56611ca16d21b9dd0eee953 Co-developed-by: Cursor <noreply@cursor.com> Signed-off-by: 久氢 <mapenghui.mph@alibaba-inc.com>
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 adds support for AsyncMemory in the memory collection module and introduces vector dimension configuration for embedders. The changes enable asynchronous memory operations and proper configuration of embedding dimensions from vector store settings.
Changes:
- Updated
agentrun-mem0aidependency from version 0.0.6 to 0.0.10 - Added
AsyncMemorysupport alongside existingMemoryfunctionality with proper async/await patterns - Implemented automatic vector dimension propagation from vector store config to embedder config
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Bumped agentrun-mem0ai dependency to 0.0.10 |
| agentrun/memory_collection/memory_collection.py | Auto-generated file with AsyncMemory support and vector dimension config |
| agentrun/memory_collection/__memory_collection_async_template.py | Source template with AsyncMemory conversion and vector dimension extraction logic |
| codegen/codegen.py | Added AsyncMemory -> Memory string replacement for sync code generation |
| examples/memory_collection_example.py | Added async_mem0_memory_example function demonstrating AsyncMemory usage |
| tests/unittests/memory_collection/test_memory_collection.py | Added test class for to_mem0_memory and to_mem0_memory_async methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mock_control_api_class.return_value = mock_control_api | ||
|
|
||
| # Mock import 失败 | ||
| with patch("builtins.__import__", side_effect=ImportError("No module")): |
Copilot
AI
Jan 20, 2026
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.
The test is using patch("builtins.__import__") to mock import failures, but the actual code uses a try-except block with from agentrun_mem0 import Memory. This approach won't work because the from X import Y statement is not the same as calling __import__. The test should instead patch the module agentrun_mem0.Memory or use patch.dict('sys.modules') to simulate the module not being available.
| mock_control_api_class.return_value = mock_control_api | ||
|
|
||
| # Mock import 失败 | ||
| with patch("builtins.__import__", side_effect=ImportError("No module")): |
Copilot
AI
Jan 20, 2026
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.
The test is using patch("builtins.__import__") to mock import failures, but the actual code uses a try-except block with from agentrun_mem0 import AsyncMemory. This approach won't work because the from X import Y statement is not the same as calling __import__. The test should instead patch the module agentrun_mem0.AsyncMemory or use patch.dict('sys.modules') to simulate the module not being available.
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) | ||
| import asyncio |
Copilot
AI
Jan 20, 2026
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.
The module asyncio is already imported at the top of the file (line 8), so this re-import is redundant and should be removed.
| import asyncio |
| embedder_config_dict = { | ||
| "model": embedder_config.config.model, | ||
| "openai_base_url": base_url, | ||
| "api_key": api_key, | ||
| } | ||
|
|
||
| # 从 vector_store_config 中获取向量维度 | ||
| if ( | ||
| memory_collection.vector_store_config | ||
| and memory_collection.vector_store_config.config | ||
| and memory_collection.vector_store_config.config.vector_dimension | ||
| ): | ||
| embedder_config_dict["embedding_dims"] = ( | ||
| memory_collection.vector_store_config.config.vector_dimension | ||
| ) |
Copilot
AI
Jan 20, 2026
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.
The new vector dimension configuration logic (lines 623-637 and 747-761) that extracts vector_dimension from vector_store_config and adds it as embedding_dims to the embedder configuration is not covered by tests. Consider adding test cases to verify that this configuration is correctly passed to the mem0 config when vector_dimension is present.
… configuration
Change-Id: I715f9c34f82bd49bd56611ca16d21b9dd0eee953
Co-developed-by: Cursor noreply@cursor.com
Fix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update