mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

feat: enable independent configuration for categorization, LLM, and embedding models

Open code-with-Anson opened this issue 5 months ago โ€ข 4 comments

Description

feat: add customizable model configuration options for categorization and memory modules

  • Provide customizable configuration options for categorization.py and memory.py
  • Enable direct model configuration modification through environment variables
  • Add reference implementations and corresponding comments in template files
  • Display current custom third-party OpenAI-compatible baseURL and models via console output
  • Support independent configuration for categorization model, LLM model, and embedding model
  • Allow flexible integration with various OpenAI-compatible API providers

Type of change

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested by configuring different environment variables and running docker compose to verify functionality.

Test Configuration:

  • Configured various environment variables for different API providers (DeepSeek API, SiliconFlow embedding, etc.)
  • Started services using docker compose up
  • Verified console output displays correct custom configuration information
  • Tested categorization functionality works properly with custom configurations
  • Validated memory and embedding modules use the specified custom configurations
  • Confirmed all modules can independently use different API providers

Test Environment:

  • Docker Compose setup

  • Multiple OpenAI-compatible API configurations

  • Environment variable-based configuration testing

  • [x] Test Script (manual testing via docker compose)

Checklist:

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

code-with-Anson avatar Jun 08 '25 06:06 code-with-Anson

"Dear Project Manager, Hello! Your project's categorization file still has obvious issues that need to be addressed. For OpenAI compatibility, the LLM model used for memory categorization should not use openai_client.responses.parse when processing memories. Instead, it should use openai_client.chat.completions.create. Otherwise, when using third-party models that comply with OpenAI standards (such as DeepSeek) for memory categorization, a 404 endpoint not found error will occur. Please review my PR as soon as possible. I will open a PR for the specific branch with the fixed categorization file immediately after this PR is approved. I hope OpenMemory can become better and better! Best regards"

code-with-Anson avatar Jun 08 '25 08:06 code-with-Anson

โœ… Update: Fixed the categorization API compatibility issue in the latest commit. No separate PR needed - the fix is now included in this PR.

code-with-Anson avatar Jun 08 '25 14:06 code-with-Anson

๐Ÿ”„ Update: Added MySQL Compatibility Enhancement

Hi! I've just pushed additional improvements to this branch that enhance database compatibility:

๐Ÿš€ New Features Added

  • Full MySQL Compatibility: Fixed VARCHAR length requirements and data type issues
  • Optimized UUID Storage: Implemented 32-character hyphen-free UUID format for better performance
  • Auto-conversion System: Added SQLAlchemy event listeners for seamless UUID format handling

๐Ÿ”ง Technical Details

  • All String fields now specify explicit lengths for MySQL compatibility
  • Large content fields (content, vector, description) converted to Text type
  • UUID Format Optimization: Converted UUIDs to 32-character hyphen-free format for MySQL storage while maintaining compatibility with existing query and modification logic
  • Minimal intrusive solution - existing code works without changes through automatic conversion

๐Ÿงช Testing Status

  • โœ… MySQL 8.0 compatibility verified and working perfectly
  • โœ… Automatic table creation working on MySQL
  • โœ… UUID conversion tested for various input scenarios
  • โœ… Existing query and modification operations work seamlessly with new UUID format

This enhancement makes the project accessible to MySQL users with a robust, production-ready solution. The UUID format change is completely transparent to application code thanks to the auto-conversion system.

Ready for review! ๐ŸŽ‰


These changes build upon the flexible LLM configuration features in this PR, creating a more robust solution for MySQL deployments.

code-with-Anson avatar Jun 09 '25 03:06 code-with-Anson

๐Ÿ“ Issue Note: Foreign Key Constraint with MySQL Deletion There's currently a known issue where deleted memories cannot be directly removed from the MySQL database due to foreign key constraints. However, this doesn't affect the user experience - deleted memories are properly filtered out in both the UI interface and query operations, so they won't appear in any user-facing results. Current Status:

โœ… UI properly hides deleted memories โœ… Query operations exclude deleted records โœ… No impact on normal usage โš ๏ธ Database cleanup requires additional work

This is a non-blocking issue that will be addressed in a future update with proper foreign key handling and cascading deletion logic.

code-with-Anson avatar Jun 09 '25 11:06 code-with-Anson

@code-with-Anson Can you resolve conflicts?

parshvadaftari avatar Aug 16 '25 13:08 parshvadaftari

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 17 '25 08:08 CLAassistant

@code-with-Anson Can you resolve conflicts?

Alright, I have commented out the unnecessary print statements as you suggested, and resolved the merge conflicts. You can try to perform the CI/CD now๐Ÿ•Š๏ธ๐Ÿ•Š๏ธ

code-with-Anson avatar Aug 17 '25 08:08 code-with-Anson