lfnovo/open-notebook · error · ConfigurationError

Model is not a LanguageModel: {model}. Please check that the

Error message

Model is not a LanguageModel: {model}. Please check that the model configured for '{default_type}' is a language model, not an embedding or speech model.

What it means

provision_langchain_model() found a model but isinstance(model, LanguageModel) failed — the slot configured for language generation actually holds an embedding or speech-to-text model. The code refuses to call to_langchain() on a non-chat model to avoid runtime type errors downstream in LangChain.

Source

Thrown at open_notebook/ai/provision.py:56

    if model is None:
        logger.error(
            f"Model provisioning failed: No model found. "
            f"Selection reason: {selection_reason}. "
            f"model_id={model_id}, default_type={default_type}. "
            f"Please check Settings → Models and ensure a default model is configured for '{default_type}'."
        )
        raise ConfigurationError(
            f"No model configured for {selection_reason}. "
            f"Please go to Settings → Models and configure a default model for '{default_type}'."
        )

    if not isinstance(model, LanguageModel):
        logger.error(
            f"Model type mismatch: Expected LanguageModel but got {type(model).__name__}. "
            f"Selection reason: {selection_reason}. "
            f"model_id={model_id}, default_type={default_type}."
        )
        raise ConfigurationError(
            f"Model is not a LanguageModel: {model}. "
            f"Please check that the model configured for '{default_type}' is a language model, not an embedding or speech model."
        )

    return model.to_langchain()

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Open Settings → Models and set the '{default_type}' slot to an actual language/chat model
  2. Check the model row's type field in the database matches 'language' for that slot
  3. If configuring via API/script, validate model.type == 'language' before saving it as default

Example fix

// before
defaults.default_language_model = embedding_model.id
// after
defaults.default_language_model = language_model.id  # model.type == 'language'
Defensive patterns

Strategy: type-guard

Validate before calling

defaults = await model_manager.get_defaults()
m = await model_manager.get_model(defaults.default_language_model)
if not m or m.type != 'language':
    raise ConfigurationError('default language model slot must hold a language model')

Type guard

def is_language_model(m) -> bool:
    return getattr(m, 'type', None) == 'language' or isinstance(m, LanguageModel)

Try / catch

try:
    model = await provision_langchain_model(...)
except ConfigurationError as e:
    if 'not a LanguageModel' in str(e):
        return JSONResponse(409, 'Wrong model type in default slot')
    raise

Prevention

When it happens

Trigger: Assigning an embedding model (e.g. OpenAI text-embedding-3) as the default language model in Settings → Models; programmatic updates to DefaultModels that store the wrong model id in default_language_model.

Common situations: Users pasting/configuring model ids quickly and mixing up slots; bulk-importing model configs; provider UIs listing all model types in one picker so an embedding model gets selected as the chat default.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/2cdf3ec625d28269. Report an issue: GitHub.