Skip to content

Conversation

@ron-42
Copy link
Contributor

@ron-42 ron-42 commented Oct 19, 2025

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

  • Bug fix (non-breaking change which fixes an issue)
  • 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)
  • 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-..."
          }
        }
      }
    }
…gpt-4o-mini

- Fixed hardcoded model issue in openmemory categorization
- Categorization now reads LLM config from database
- Supports custom base_url for OpenAI-compatible providers (SiliconFlow, etc.)
- Added SiliconFlowConfig class for proper configuration
- Updated factory to use SiliconFlowConfig
- Added SiliconFlow documentation with usage examples

Fixes issue where SiliconFlow users got 'Model does not exist' error
because categorization was hardcoded to use gpt-4o-mini instead of
the configured model like deepseek-ai/DeepSeek-R1.

Resolves: mem0ai#3574
@CLAassistant
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants