add crud for adding providers and models to resources

This commit is contained in:
miloschwartz
2026-08-04 15:54:24 -04:00
parent ed8545f8a2
commit e38359c74f
39 changed files with 2343 additions and 438 deletions
@@ -66,8 +66,6 @@ export default function AiProviderAuthenticationPage() {
authType: (provider.authType as "bearer" | null) ?? "bearer",
routingMode: (provider.routingMode as "url" | "target") ?? "url",
skipTlsVerification: provider.skipTlsVerification,
budgetAmount: provider.budgetAmount,
budgetUnit: provider.budgetUnit as "usd" | "tokens" | null,
enabled: provider.enabled
}
});
@@ -96,8 +94,6 @@ export default function AiProviderAuthenticationPage() {
authType: (updated.authType as "bearer" | null) ?? "bearer",
routingMode: (updated.routingMode as "url" | "target") ?? "url",
skipTlsVerification: updated.skipTlsVerification,
budgetAmount: updated.budgetAmount,
budgetUnit: updated.budgetUnit as "usd" | "tokens" | null,
enabled: updated.enabled
});
toast({
@@ -75,8 +75,6 @@ export default function AiProviderNetworkPage() {
authType: (provider.authType as "bearer" | null) ?? "bearer",
routingMode: (provider.routingMode as "url" | "target") ?? "url",
skipTlsVerification: provider.skipTlsVerification,
budgetAmount: provider.budgetAmount,
budgetUnit: provider.budgetUnit as "usd" | "tokens" | null,
enabled: provider.enabled
}
});
@@ -120,8 +118,6 @@ export default function AiProviderNetworkPage() {
authType: (updated.authType as "bearer" | null) ?? "bearer",
routingMode: (updated.routingMode as "url" | "target") ?? "url",
skipTlsVerification: updated.skipTlsVerification,
budgetAmount: updated.budgetAmount,
budgetUnit: updated.budgetUnit as "usd" | "tokens" | null,
enabled: updated.enabled
});
@@ -79,8 +79,6 @@ export default function CreateAiProviderPage() {
authType: "bearer",
routingMode: "url",
skipTlsVerification: false,
budgetAmount: null,
budgetUnit: null,
enabled: true
}
});
-30
View File
@@ -26,8 +26,6 @@ export const aiProviderFormSchema = z
authType: z.enum(["bearer"]).optional().nullable(),
routingMode: z.enum(["url", "target"]).optional(),
skipTlsVerification: z.boolean().optional(),
budgetAmount: z.number().positive().nullable().optional(),
budgetUnit: z.enum(["usd", "tokens"]).optional().nullable(),
enabled: z.boolean().optional()
})
.superRefine((data, ctx) => {
@@ -78,20 +76,6 @@ export const aiProviderFormSchema = z
path: ["authType"]
});
}
const hasAmount =
data.budgetAmount !== undefined && data.budgetAmount !== null;
const hasUnit =
data.budgetUnit !== undefined && data.budgetUnit !== null;
if (hasAmount !== hasUnit) {
ctx.addIssue({
code: "custom",
message:
"budgetAmount and budgetUnit must both be set or both omitted",
path: hasAmount ? ["budgetUnit"] : ["budgetAmount"]
});
}
});
export type AiProviderFormValues = z.infer<typeof aiProviderFormSchema>;
@@ -145,11 +129,6 @@ export function toAiProviderCreatePayload(values: AiProviderFormValues) {
? upstreamRaw
: null;
const hasBudget =
values.budgetAmount !== undefined &&
values.budgetAmount !== null &&
values.budgetUnit;
return {
name: values.name.trim(),
type: values.type,
@@ -161,8 +140,6 @@ export function toAiProviderCreatePayload(values: AiProviderFormValues) {
? (values.authType ?? "bearer")
: (values.authType ?? undefined),
skipTlsVerification: values.skipTlsVerification,
budgetAmount: hasBudget ? values.budgetAmount : null,
budgetUnit: hasBudget ? values.budgetUnit : null,
enabled: values.enabled ?? true
};
}
@@ -178,11 +155,6 @@ export function toAiProviderUpdatePayload(values: AiProviderFormValues) {
? upstreamRaw
: null;
const hasBudget =
values.budgetAmount !== undefined &&
values.budgetAmount !== null &&
values.budgetUnit;
const payload: Record<string, unknown> = {
name: values.name.trim(),
routingMode: values.type === "custom" ? routingMode : "url",
@@ -192,8 +164,6 @@ export function toAiProviderUpdatePayload(values: AiProviderFormValues) {
? (values.authType ?? "bearer")
: (values.authType ?? null),
skipTlsVerification: values.skipTlsVerification ?? false,
budgetAmount: hasBudget ? values.budgetAmount : null,
budgetUnit: hasBudget ? values.budgetUnit : null,
enabled: values.enabled ?? true
};