Add feature to unlist a model (#625)
Browse filesFiles changed (6)
64 unmodified lines65666768697085 unmodified lines15615715815964 unmodified lines.passthrough().optional(),multimodal: z.boolean().default(false),});const modelsRaw = z.array(modelConfig).parse(JSON.parse(MODELS));85 unmodified linesdefaultModel: defaultModel;export type BackendModel = Optional<typeof defaultModel, "preprompt" | "parameters" | "multimodal">;64 unmodified lines6566676869707185 unmodified lines15715815916016116216364 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 linesdefaultModel: defaultModel;export type BackendModel = Optional<typeof defaultModel,"preprompt" | "parameters" | "multimodal" | "unlisted">;
13 unmodified lines1415161713 unmodified lines| "datasetUrl"| "preprompt"| "multimodal">;13 unmodified lines141516171813 unmodified lines| "datasetUrl"| "preprompt"| "multimodal"| "unlisted">;
26 unmodified lines27282930313256 unmodified lines89909192939426 unmodified lines});}// get the number of messages where `from === "assistant"` across all conversations.const totalMessages =(56 unmodified linesparameters: model.parameters,preprompt: model.preprompt,multimodal: model.multimodal,})),oldModels,user: locals.user && {26 unmodified lines272829303132333435363738394041424356 unmodified lines10010110210310410510626 unmodified lines});}// if the model is unlisted, set the active model to the default modelif (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 linesparameters: model.parameters,preprompt: model.preprompt,multimodal: model.multimodal,unlisted: model.unlisted,})),oldModels,user: locals.user && {
38 unmodified lines39404142434438 unmodified lines}const model = models.find((m) => m.name === values.model);// Use the model preprompt if there is no conversation/preprompt in the request bodypreprompt = preprompt === undefined ? model?.preprompt : preprompt;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 bodypreprompt = preprompt === undefined ? model?.preprompt : preprompt;
47 unmodified lines4849505152535447 unmodified lines<divclass="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}<ahref="{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 ===47 unmodified lines4849505152535447 unmodified lines<divclass="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.filter((el) => !el.unlisted) as model}<ahref="{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 lines456789103 unmodified linesexport async function load({ parent, params }) {const data = await parent();if (!data.models.map(({ id }) => id).includes(params.model)) {throw redirect(302, `${base}/settings`);}3 unmodified lines4567891011123 unmodified linesexport async function load({ parent, params }) {const data = await parent();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