Handle the list of models without allow/block

This commit is contained in:
Owen
2026-08-14 12:23:07 -04:00
parent 954dc8d1d9
commit 193f6da8d1
4 changed files with 25 additions and 41 deletions
+11 -17
View File
@@ -26,7 +26,7 @@ export type BlueprintAiProviderInput = {
provider: string;
accessMode: AccessMode;
enabled: boolean;
models: BlueprintAiModelInput[];
models: string[];
};
async function resolveProviderNiceIds(
@@ -99,12 +99,12 @@ async function resolveModelKeys(
for (const provider of providers) {
const providerId = providerIdByNiceId.get(provider.provider)!;
for (const m of provider.models) {
const modelId = byProviderAndKey.get(`${providerId}::${m.model}`);
const modelId = byProviderAndKey.get(`${providerId}::${m}`);
if (modelId === undefined) {
missing.push(`${provider.provider}/${m.model}`);
missing.push(`${provider.provider}/${m}`);
continue;
}
modelIdByEntryKey.set(`${provider.provider}::${m.model}`, modelId);
modelIdByEntryKey.set(`${provider.provider}::${m}`, modelId);
}
}
@@ -117,7 +117,7 @@ async function resolveModelKeys(
async function validateModelEntries(input: {
orgId: string;
entries: { modelId: number; listType: ModelListType }[];
entries: { modelId: number }[];
selectProviderIds: number[];
trx: Transaction;
}): Promise<void> {
@@ -157,13 +157,10 @@ async function validateModelEntries(input: {
`Model ${entry.modelId} does not exist or does not belong to a select-mode attached provider`
);
}
if (catalog.listType !== entry.listType) {
throw new Error(
`Model ${entry.modelId} must use list-type "${catalog.listType}" to match the provider catalog entry`
);
}
if (!catalog.enabled) {
throw new Error(`Model ${entry.modelId} is disabled on its provider`);
throw new Error(
`Model ${entry.modelId} is disabled on its provider`
);
}
}
}
@@ -238,8 +235,7 @@ export async function syncInferenceAiConfig(
const modelEntries = input.providers.flatMap((p) =>
p.models.map((m) => ({
modelId: modelIdByEntryKey.get(`${p.provider}::${m.model}`)!,
listType: m.listType
modelId: modelIdByEntryKey.get(`${p.provider}::${m}`)!
}))
);
@@ -262,8 +258,7 @@ export async function syncInferenceAiConfig(
await trx.insert(resourceAiModels).values(
modelEntries.map((m) => ({
resourceId: input.resourceId,
modelId: m.modelId,
listType: m.listType
modelId: m.modelId
}))
);
}
@@ -277,8 +272,7 @@ export async function syncInferenceAiConfig(
await trx.insert(siteResourceAiModels).values(
modelEntries.map((m) => ({
siteResourceId: input.siteResourceId,
modelId: m.modelId,
listType: m.listType
modelId: m.modelId
}))
);
}
+2 -8
View File
@@ -363,10 +363,7 @@ export async function updatePrivateResources(
provider: p.provider,
accessMode: p["access-mode"],
enabled: p.enabled,
models: p.models.map((m) => ({
model: m.model,
listType: m["list-type"]
}))
models: p.models
}))
});
@@ -672,10 +669,7 @@ export async function updatePrivateResources(
provider: p.provider,
accessMode: p["access-mode"],
enabled: p.enabled,
models: p.models.map((m) => ({
model: m.model,
listType: m["list-type"]
}))
models: p.models
}))
});
+2 -8
View File
@@ -708,10 +708,7 @@ export async function updatePublicResources(
provider: p.provider,
accessMode: p["access-mode"],
enabled: p.enabled,
models: p.models.map((m) => ({
model: m.model,
listType: m["list-type"]
}))
models: p.models
})
)
});
@@ -1288,10 +1285,7 @@ export async function updatePublicResources(
provider: p.provider,
accessMode: p["access-mode"],
enabled: p.enabled,
models: p.models.map((m) => ({
model: m.model,
listType: m["list-type"]
}))
models: p.models
}))
});
+10 -8
View File
@@ -188,11 +188,6 @@ export const HeaderSchema = z.object({
value: z.string().min(1)
});
export const AiProviderModelEntrySchema = z.object({
model: z.string().min(1),
"list-type": z.enum(["allow", "block"])
});
export const AiProviderAttachmentSchema = z
.object({
provider: z.string().min(1),
@@ -201,7 +196,7 @@ export const AiProviderAttachmentSchema = z
.optional()
.default("inherit"),
enabled: z.boolean().optional().default(true),
models: z.array(AiProviderModelEntrySchema).optional().default([])
models: z.array(z.string()).optional().default([])
})
.refine(
(provider) => {
@@ -598,7 +593,10 @@ export const PrivateResourceSchema = z
machines: z.array(z.string()).optional().default([]),
labels: z.array(z.string().min(1)).optional().default([]),
"auth-daemon": AuthDaemonSchema.optional(),
"ai-providers": z.array(AiProviderAttachmentSchema).optional().default([]),
"ai-providers": z
.array(AiProviderAttachmentSchema)
.optional()
.default([]),
"ai-budget": AiBudgetListSchemaWithDefault
})
.refine(
@@ -608,7 +606,11 @@ export const PrivateResourceSchema = z
data.mode === "ssh" &&
(data["auth-daemon"] === undefined ||
data["auth-daemon"].mode === "native");
if (data.mode !== "inference" && !isNativeSSH && !data.destination) {
if (
data.mode !== "inference" &&
!isNativeSSH &&
!data.destination
) {
return false;
}
return true;