TUI: filter model picker to allowlisted models

This commit is contained in:
Vignesh Natarajan
2026-02-21 19:03:05 -08:00
parent 853ae626fa
commit 4550a52007
3 changed files with 106 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
import { DEFAULT_PROVIDER } from "../../agents/defaults.js";
import { buildAllowedModelSet } from "../../agents/model-selection.js";
import { loadConfig } from "../../config/config.js";
import {
ErrorCodes,
errorShape,
@@ -20,7 +23,14 @@ export const modelsHandlers: GatewayRequestHandlers = {
return;
}
try {
const models = await context.loadGatewayModelCatalog();
const catalog = await context.loadGatewayModelCatalog();
const cfg = loadConfig();
const { allowedCatalog } = buildAllowedModelSet({
cfg,
catalog,
defaultProvider: DEFAULT_PROVIDER,
});
const models = allowedCatalog.length > 0 ? allowedCatalog : catalog;
respond(true, { models }, undefined);
} catch (err) {
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, String(err)));