Add feature to unlist a model (#625)
Browse filesFiles changed (6)
64 unmodified lines6566676869707185 unmodified lines15715815915916016116216364 unmodified lines .passthrough() .optional(), multimodal: z.boolean().default(false), unlisted: z.boolean().default(false),});
const modelsRaw = z.array(modelConfig).parse(JSON.parse(MODELS));85 unmodified lines defaultModel : defaultModel;
export type BackendModel = Optional<typeof defaultModel, "preprompt" | "parameters" | "multimodal">;export type BackendModel = Optional< typeof defaultModel, "preprompt" | "parameters" | "multimodal" | "unlisted">;13 unmodified lines141516171813 unmodified lines | "datasetUrl" | "preprompt" | "multimodal" | "unlisted">;26 unmodified lines272829303132333435363738394041424356 unmodified lines10010110210310410510626 unmodified lines }); }
// if the model is unlisted, set the active model to the default model if ( settings?.activeModel && models.find((m) => m.id === settings?.activeModel)?.unlisted === true ) { settings.activeModel = defaultModel.id; await collections.settings.updateOne(authCondition(locals), { $set: { activeModel: defaultModel.id }, }); }
// get the number of messages where `from === "assistant"` across all conversations. const totalMessages = (56 unmodified lines parameters: model.parameters, preprompt: model.preprompt, multimodal: model.multimodal, unlisted: model.unlisted, })), oldModels, user: locals.user && {38 unmodified lines39404142434445464748495051525338 unmodified lines }
const model = models.find((m) => m.name === values.model);
if (!model) { throw error(400, "Invalid model"); }
if (model.unlisted) { throw error(400, "Can't start a conversation with an unlisted model"); }
// Use the model preprompt if there is no conversation/preprompt in the request body preprompt = preprompt === undefined ? model?.preprompt : preprompt;
47 unmodified lines484950515152535447 unmodified lines <div class="col-span-1 flex flex-col overflow-y-auto whitespace-nowrap max-md:-mx-4 max-md:h-[160px] max-md:border md:pr-6" > {#each data.models as model} {#each data.models.filter((el) => !el.unlisted) as model} <a href="{base}/settings/{model.id}" class="group flex h-11 flex-none items-center gap-3 pl-3 pr-2 text-gray-500 hover:bg-gray-100 md:rounded-xl {model.id ===3 unmodified lines45677891011123 unmodified linesexport async function load({ parent, params }) { const data = await parent();
if (!data.models.map(({ id }) => id).includes(params.model)) { const model = data.models.find(({ id }) => id === params.model);
if (!model || model.unlisted) { throw redirect(302, `${base}/settings`); }
src/lib/server/models.ts+5-1
src/lib/types/Model.ts+1
src/routes/+layout.server.ts+12
src/routes/conversation/+server.ts+9
src/routes/settings/+layout.svelte+1-1
src/routes/settings/[...model]/+page.ts+3-1