continue icon indicating copy to clipboard operation
continue copied to clipboard

Fix: Prioritize user-defined embed models over Transformers.js built-in

Open PhilipAD opened this issue 5 months ago • 3 comments

Description

When defining an embed model with roles: [embed] in the YAML config file, the extension defaults to using the built-in Transformers.js embedder instead of the user-defined model. This PR fixes this issue by ensuring user-configured embed models in config.yaml are prioritized over the built-in Transformers.js model.

Changes Made

  1. Updated core/config/yaml/loadYaml.ts to:
    • Only add the Transformers.js embedder when no other embed models exist
    • Explicitly initialize the selected embed model to prioritize non-Transformers.js models
  2. Enhanced core/config/selectedModels.ts to prioritize non-Transformers.js models when selecting the initial embed model

Testing

I've tested these changes with a custom OpenAI-compatible embed model defined in config.yaml with roles: [embed], and confirmed that:

  • The custom model is now automatically selected on startup
  • The built-in Transformers.js model is still available as a fallback
  • The changes don't affect other model roles

Checklist

  • [x] I've read the contributing guide
  • [x] The relevant docs, if any, have been updated or created
  • [x] The relevant tests, if any, have been updated or created

PhilipAD avatar May 07 '25 10:05 PhilipAD