mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

fix: Use configured LLM model in categorization instead of hardcoded gpt-4o-mini

Open ron-42 opened this issue 1 month ago • 1 comments

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.py used a hardcoded gpt-4o-mini model
  • 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_url parameter (enables SiliconFlow .cn domain and other custom endpoints)
  • Created SiliconFlowConfig class for proper type-safe configuration
  • Updated LlmFactory to use SiliconFlowConfig instead of generic BaseLlmConfig
  • Added comprehensive documentation for SiliconFlow usage with code examples

Dependencies:

  • Existing openai Python 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:

  1. 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-..."
          }
        }
      }
    }
    

ron-42 avatar Oct 19 '25 15:10 ron-42

CLA assistant check
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.

CLAassistant avatar Oct 19 '25 15:10 CLAassistant