Skip to content

Conversation

fridayL
Copy link
Collaborator

@fridayL fridayL commented Jul 26, 2025

  • Add user manager factory pattern with SQLite and MySQL backends
  • Add user manager configuration to MOSConfig
  • Add product API router and configuration
  • Add DingDing notification integration
  • Add notification service utilities
  • Update OpenAPI documentation

Summary: (summary)

Fix: #(issue)

Docs Issue/PR: (docs-issue-or-pr-link)

Reviewer: @(reviewer)

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

- Add user manager factory pattern with SQLite and MySQL backends
- Add user manager configuration to MOSConfig
- Add product API router and configuration
- Add DingDing notification integration
- Add notification service utilities
- Update OpenAPI documentation
@fridayL fridayL requested a review from Ki-Seki July 26, 2025 02:10
@Ki-Seki Ki-Seki requested a review from Copilot July 26, 2025 03:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds user manager factory pattern with multiple database backends, product API enhancements for DingDing notifications, and improved streaming functionality. The PR introduces a flexible user management system supporting both SQLite and MySQL backends through factory patterns.

  • Implementation of user manager factory pattern with SQLite and MySQL backends
  • Integration of DingDing notification service with chat reporting
  • Addition of user manager configuration to MOSConfig system

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/memos/mem_user/persistent_factory.py Factory for creating persistent user managers with SQLite/MySQL backends
src/memos/mem_user/mysql_user_manager.py Complete MySQL user management implementation with SQLAlchemy models
src/memos/mem_user/mysql_persistent_user_manager.py MySQL persistent user manager with configuration storage
src/memos/mem_user/factory.py Basic user manager factory without persistence features
src/memos/mem_os/utils/notification_utils.py Utility functions for DingDing bot notifications
src/memos/mem_os/product.py Enhanced product class with notification integration
src/memos/configs/mem_user.py Configuration models for user manager backends
src/memos/configs/mem_os.py Added user manager configuration to MOSConfig
src/memos/api/tools/notification_service.py Service for loading DingDing bot functions
src/memos/api/tools/dinding_report_bot.py Complete DingDing bot implementation with OSS integration
src/memos/api/routers/product_router.py Updated router with notification integration and streaming fixes
src/memos/api/config.py Added DingDing bot configuration support
examples/mem_user/user_manager_factory_example.py Usage examples for user manager factories
docs/openapi.json Updated OpenAPI schema with new user manager configuration
Comments suppressed due to low confidence (1)

src/memos/api/config.py:459

  • This code block appears to be commented out or removed, but the context suggests it might be accidentally deleted. The internet retriever configuration logic seems incomplete.
            )

Comment on lines 36 to 51
config = config_factory.config

if backend == "sqlite":
return user_manager_class(db_path=config.db_path, user_id=config.user_id)
elif backend == "mysql":
return user_manager_class(
user_id=config.user_id,
host=config.host,
port=config.port,
username=config.username,
password=config.password,
database=config.database,
charset=config.charset,
)
else:
raise ValueError(f"Unsupported backend: {backend}")
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

The conditional logic checking backend twice (lines 32 and 38) creates redundant validation. Consider removing the elif/else block at lines 40-51 since the initial validation at line 32-33 already ensures the backend is valid.

Suggested change
config = config_factory.config
if backend == "sqlite":
return user_manager_class(db_path=config.db_path, user_id=config.user_id)
elif backend == "mysql":
return user_manager_class(
user_id=config.user_id,
host=config.host,
port=config.port,
username=config.username,
password=config.password,
database=config.database,
charset=config.charset,
)
else:
raise ValueError(f"Unsupported backend: {backend}")
config = config_factory.config.__dict__
return user_manager_class(**config)

Copilot uses AI. Check for mistakes.

return user.user_id
except IntegrityError:
session.rollback()
logger.info(f"failed to create user with name '{user_name}' already exists")
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

The log message has grammatical errors. It should read 'Failed to create user with name '{user_name}' - user already exists' for clarity.

Suggested change
logger.info(f"failed to create user with name '{user_name}' already exists")
logger.info(f"Failed to create user with name '{user_name}' - user already exists")

Copilot uses AI. Check for mistakes.

Comment on lines 108 to 109
from datetime import datetime

Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

The datetime import is already at the top of the file (line 9). This redundant import inside the function should be removed.

Suggested change
from datetime import datetime

Copilot uses AI. Check for mistakes.

Comment on lines 38 to 51
if backend == "sqlite":
return user_manager_class(db_path=config.db_path, user_id=config.user_id)
elif backend == "mysql":
return user_manager_class(
user_id=config.user_id,
host=config.host,
port=config.port,
username=config.username,
password=config.password,
database=config.database,
charset=config.charset,
)
else:
raise ValueError(f"Unsupported backend: {backend}")
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Same issue as in persistent_factory.py - the conditional logic checking backend twice creates redundant validation. The elif/else block at lines 40-51 should be removed.

Suggested change
if backend == "sqlite":
return user_manager_class(db_path=config.db_path, user_id=config.user_id)
elif backend == "mysql":
return user_manager_class(
user_id=config.user_id,
host=config.host,
port=config.port,
username=config.username,
password=config.password,
database=config.database,
charset=config.charset,
)
else:
raise ValueError(f"Unsupported backend: {backend}")
return user_manager_class(**config)

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,422 @@
"""dingding_report_bot.py"""
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

The filename in the docstring has a typo. It should be 'dingding_report_bot.py' instead of 'dinding_report_bot.py'.

Suggested change
"""dingding_report_bot.py"""
"""dinding_report_bot.py"""

Copilot uses AI. Check for mistakes.

@fridayL fridayL requested a review from Ki-Seki July 26, 2025 10:33
Copy link
Member

@Ki-Seki Ki-Seki left a comment

Choose a reason for hiding this comment

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

Fix Copilot's suggestions, mostly about typos. Once the changes are complete, I'll merge it.

@fridayL
Copy link
Collaborator Author

fridayL commented Jul 26, 2025

Fix Copilot's suggestions, mostly about typos. Once the changes are complete, I'll merge it.

Done, I have fix it by coplit

@fridayL fridayL requested a review from Ki-Seki July 26, 2025 13:24
@Ki-Seki Ki-Seki merged commit 1d71884 into MemTensor:dev Jul 26, 2025
20 checks passed
tangg555 pushed a commit to tangg555/MemOS that referenced this pull request Jul 29, 2025
…emTensor#166)

* feat: add user manager factory pattern and product API enhancements

- Add user manager factory pattern with SQLite and MySQL backends
- Add user manager configuration to MOSConfig
- Add product API router and configuration
- Add DingDing notification integration
- Add notification service utilities
- Update OpenAPI documentation

* fix: change py to meos_tools

* fix: code reorganize
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.

2 participants