Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PhilipAD
Copy link

@PhilipAD PhilipAD commented May 7, 2025

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

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

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.

## Changes
- Modified the embed model selection logic to prioritize user-defined models with the embed role
- Only fall back to Transformers.js when no other embed models are defined
- Updated model initialization to select the first non-Transformers.js model by default when available

## Testing
- Tested with a custom embed model in config.yaml and confirmed it's automatically selected on startup
@PhilipAD PhilipAD requested a review from a team as a code owner May 7, 2025 10:43
@PhilipAD PhilipAD requested review from sestinj and removed request for a team May 7, 2025 10:43
Copy link

netlify bot commented May 7, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 18bc7a5
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/681b49777f73ce000800cb88

Philip D'Souza added 2 commits May 7, 2025 12:36
…up logic into a separate helper function. This brings the complexity score of configYamlToContinueConfig below the maximum threshold of 36.
@sestinj
Copy link
Contributor

sestinj commented May 10, 2025

Nice find! I want to make sure we are able to test this, but I also understand that the work required to do that would probably blow up the scope of this PR. I'm going to make an attempt at doing this before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants