diff --git a/core/config/load.ts b/core/config/load.ts index c9ab18925..18c61ce93 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -203,6 +203,24 @@ async function serializedToIntermediateConfig( return config; } +// Merge request options set for entire config with model specific options +function applyRequestOptionsToModels( + models: BaseLLM[], + config: Config, + roles: ModelRole[] | undefined = undefined, +) { + // Prepare models + for (const model of models) { + model.requestOptions = { + ...model.requestOptions, + ...config.requestOptions, + }; + if (roles !== undefined) { + model.roles = model.roles ?? roles; + } + } +} + export function isContextProviderWithParams( contextProvider: CustomContextProvider | ContextProviderWithParams, ): contextProvider is ContextProviderWithParams { @@ -311,14 +329,12 @@ async function intermediateToFinalConfig({ }), ); - // Prepare models - for (const model of models) { - model.requestOptions = { - ...model.requestOptions, - ...config.requestOptions, - }; - model.roles = model.roles ?? ["chat", "apply", "edit", "summarize"]; // Default to chat role if not specified - } + applyRequestOptionsToModels(models, config, [ + "chat", + "apply", + "edit", + "summarize", + ]); // Default to chat role if not specified if (allowFreeTrial) { // Obtain auth token (iff free trial being used) @@ -372,6 +388,8 @@ async function intermediateToFinalConfig({ ).filter((x) => x !== undefined) as BaseLLM[]; } + applyRequestOptionsToModels(tabAutocompleteModels, config); + // These context providers are always included, regardless of what, if anything, // the user has configured in config.json