Merge pull request #4813 from splatch/apply-request-options-for-completion-models

Carry over requestOptions from config to completion modles
This commit is contained in:
Nate Sesti 2025-04-29 12:59:21 -07:00 • committed by GitHub
commit dafb8d12e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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