mem0
mem0 copied to clipboard
fix: Use configured LLM model in categorization instead of hardcoded gpt-4o-mini
Description
This PR fixes a critical issue in OpenMemory's categorization function where the model was hardcoded to gpt-4o-mini, causing failures when users configured alternative LLM providers like SiliconFlow.
The Problem:
- The categorization function in
openmemory/api/app/utils/categorization.pyused a hardcodedgpt-4o-minimodel - Users configuring SiliconFlow or other OpenAI-compatible providers with different models (e.g.,
deepseek-ai/DeepSeek-R1) received "Model does not exist" errors - The categorization logic was disconnected from user's LLM configuration
The Solution:
- Modified categorization to dynamically read LLM configuration from the database
- Added support for custom
openai_base_urlparameter (enables SiliconFlow.cndomain and other custom endpoints) - Created
SiliconFlowConfigclass for proper type-safe configuration - Updated
LlmFactoryto useSiliconFlowConfiginstead of genericBaseLlmConfig - Added comprehensive documentation for SiliconFlow usage with code examples
Dependencies:
- Existing
openaiPython package (no new dependencies)
Fixes #3576
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style improvements, linting)
- [x] Documentation update
How Has This Been Tested?
Manual Testing:
- Configured OpenMemory with SiliconFlow provider:
{ "mem0": { "llm": { "provider": "openai", "config": { "model": "deepseek-ai/DeepSeek-R1", "openai_base_url": "https://api.siliconflow.cn/v1", "api_key": "sk-..." } } } }
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
Ronak Bhalgami seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.