From d0b8c45b8a2fff0fac2c782fa57e0b715c793e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Tue, 25 Mar 2025 21:42:51 +0400 Subject: [PATCH] Use same logic for carrying over requestOptions for completion and chat models. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Dywicki --- core/config/load.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 4c98e77285..6c7c03bf07 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -225,6 +225,20 @@ function isModelDescription( return (llm as ModelDescription).title !== undefined; } +// 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 { @@ -318,15 +332,7 @@ 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) @@ -380,6 +386,7 @@ 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