affa6f5c3d
Add DEFAULT_{TEXT,VISION,MEAL_PLAN}_{PROVIDER,MODEL} site settings,
editable from Settings -> Admin (new AdminDefaultModelForm, mirroring
the per-user model-prefs UI). getDefaultProviderWithKey now accepts
the use case and checks the admin default (after the user's own BYOK
key, before the old "first configured site key" heuristic) so admins
can pin a specific provider/model per feature instead of it being
whichever key happens to exist.
Wired into scale/substitute/batch-cook/meal-plan generation routes,
which previously called getDefaultProviderWithKey() without a use
case and so never had visibility into per-feature routing at all.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { getAllSiteSettings, isSignupsDisabled } from "@/lib/site-settings";
|
|
import { AdminSettingsForm } from "@/components/admin/admin-settings-form";
|
|
import { AdminDefaultModelForm } from "@/components/admin/admin-default-model-form";
|
|
import { SignupsToggle } from "@/components/admin/signups-toggle";
|
|
|
|
export const metadata: Metadata = {};
|
|
|
|
const SETTING_GROUPS = [
|
|
{
|
|
title: "AI Provider Keys",
|
|
description: "Override the environment variable API keys at runtime. Values are encrypted at rest.",
|
|
keys: ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"] as const,
|
|
},
|
|
{
|
|
title: "AI Configuration",
|
|
description: "Provider routing and model defaults.",
|
|
keys: ["OPENROUTER_DEFAULT_MODEL", "OLLAMA_BASE_URL"] as const,
|
|
},
|
|
{
|
|
title: "Push Notifications (VAPID)",
|
|
description: "Keys for web push notifications. Generate with: npx web-push generate-vapid-keys",
|
|
keys: ["NEXT_PUBLIC_VAPID_PUBLIC_KEY", "VAPID_PRIVATE_KEY"] as const,
|
|
},
|
|
];
|
|
|
|
export default async function AdminSettingsPage() {
|
|
const settings = await getAllSiteSettings();
|
|
const signupsDisabled = await isSignupsDisabled();
|
|
|
|
return (
|
|
<div className="space-y-8">
|
|
<div>
|
|
<h1 className="text-2xl font-bold tracking-tight">Site Settings</h1>
|
|
<p className="text-muted-foreground text-sm mt-1">
|
|
Override .env values at runtime. DB values take precedence over environment variables.
|
|
Clear a value to fall back to the environment variable.
|
|
</p>
|
|
</div>
|
|
|
|
<SignupsToggle initialDisabled={signupsDisabled} />
|
|
|
|
{SETTING_GROUPS.map((group) => (
|
|
<AdminSettingsForm key={group.title} group={group} settings={settings} />
|
|
))}
|
|
|
|
<AdminDefaultModelForm
|
|
initialValues={{
|
|
DEFAULT_TEXT_PROVIDER: settings["DEFAULT_TEXT_PROVIDER"]?.value ?? null,
|
|
DEFAULT_TEXT_MODEL: settings["DEFAULT_TEXT_MODEL"]?.value ?? null,
|
|
DEFAULT_VISION_PROVIDER: settings["DEFAULT_VISION_PROVIDER"]?.value ?? null,
|
|
DEFAULT_VISION_MODEL: settings["DEFAULT_VISION_MODEL"]?.value ?? null,
|
|
DEFAULT_MEAL_PLAN_PROVIDER: settings["DEFAULT_MEAL_PLAN_PROVIDER"]?.value ?? null,
|
|
DEFAULT_MEAL_PLAN_MODEL: settings["DEFAULT_MEAL_PLAN_MODEL"]?.value ?? null,
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|