Compare commits

...

2 Commits

Author SHA1 Message Date
5b2d33411e Merge pull request 'fix: auxiliary switch reads provider from cfg registry' (#3) from fix/models-review-feedback into main 2026-04-21 03:32:52 +00:00
8074e4cfc3 fix: auxiliary switch reads provider from cfg registry
Auxiliary model switching now looks up provider details from cfg
registry (base_url, api_key) and adds custom: prefix automatically,
matching the behavior of main provider switching.

— 小糯
2026-04-21 11:27:12 +08:00

View File

@ -344,15 +344,33 @@ function switchConfig(opts: SwitchOptions) {
// Switch auxiliary tasks
if (!config.auxiliary) config.auxiliary = {} as Record<string, AuxiliaryEntry>;
// Look up provider from cfg registry to get base_url & api_key
const registryProvider = findProviderFromRegistry(opts.provider);
const providerValue = registryProvider ? `custom:${registryProvider.name}` : opts.provider;
// Ensure custom_providers in config.yaml contains this provider
if (registryProvider) {
if (!config.custom_providers) config.custom_providers = [];
const existing = config.custom_providers.find((p) => p.name === registryProvider.name);
if (!existing) {
config.custom_providers.push(registryProvider);
}
}
for (const task of opts.auxTasks) {
if (!config.auxiliary[task]) {
config.auxiliary[task] = { provider: "", model: "", timeout: 30 };
}
config.auxiliary[task].provider = opts.provider;
config.auxiliary[task].provider = providerValue;
if (registryProvider) {
config.auxiliary[task].base_url = registryProvider.base_url;
const apiKey = getProviderApiKey(registryProvider);
if (apiKey) config.auxiliary[task].api_key = apiKey;
}
if (opts.model) {
config.auxiliary[task].model = opts.model;
}
console.log(` auxiliary.${task} → provider=${opts.provider}${opts.model ? ` model=${opts.model}` : ""}`);
console.log(` auxiliary.${task} → provider=${providerValue}${opts.model ? ` model=${opts.model}` : ""}`);
}
} else {
// Switch main provider — look up from cfg registry