fix: preserve AtlasCloud model aliases
This commit is contained in:
parent
1a91b8ada9
commit
6ccf04a786
@ -1,6 +1,9 @@
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { NextResponse } from "next/server";
|
||||
import { fetchAtlasCloudImagePresets } from "@/lib/ai/atlascloud-models";
|
||||
import {
|
||||
fetchAtlasCloudImagePresets,
|
||||
resolveAtlasCloudDisplayName,
|
||||
} from "@/lib/ai/atlascloud-models";
|
||||
import { db } from "@/lib/db";
|
||||
import { getAiProviderById } from "@/lib/db/queries";
|
||||
import { type AiModel, aiModel } from "@/lib/db/schema";
|
||||
@ -75,7 +78,11 @@ export async function POST(request: Request) {
|
||||
),
|
||||
});
|
||||
const values = {
|
||||
displayName: preset.displayName,
|
||||
displayName: resolveAtlasCloudDisplayName(
|
||||
existing?.displayName,
|
||||
preset.displayName,
|
||||
preset.modelId
|
||||
),
|
||||
avatarUrl: preset.avatarUrl || null,
|
||||
description: preset.description,
|
||||
supportsVision: preset.supportsVision,
|
||||
|
||||
@ -95,6 +95,17 @@ type JsonRecord = Record<string, any>;
|
||||
|
||||
export type AtlasCloudMediaKind = "image" | "video" | "3d";
|
||||
|
||||
export function resolveAtlasCloudDisplayName(
|
||||
existingDisplayName: unknown,
|
||||
catalogDisplayName: unknown,
|
||||
modelId: string
|
||||
) {
|
||||
const existing = String(existingDisplayName || "").trim();
|
||||
if (existing) return existing;
|
||||
|
||||
return String(catalogDisplayName || "").trim() || modelId;
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): JsonRecord {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as JsonRecord)
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { fetchAtlasCloudImagePresets } from "../lib/ai/atlascloud-models";
|
||||
import {
|
||||
fetchAtlasCloudImagePresets,
|
||||
resolveAtlasCloudDisplayName,
|
||||
} from "../lib/ai/atlascloud-models";
|
||||
import { db } from "../lib/db";
|
||||
import { aiModel, aiProvider } from "../lib/db/schema";
|
||||
|
||||
@ -36,7 +39,11 @@ async function main() {
|
||||
),
|
||||
});
|
||||
const values = {
|
||||
displayName: preset.displayName,
|
||||
displayName: resolveAtlasCloudDisplayName(
|
||||
existing?.displayName,
|
||||
preset.displayName,
|
||||
preset.modelId
|
||||
),
|
||||
avatarUrl: preset.avatarUrl || null,
|
||||
description: preset.description,
|
||||
supportsVision: preset.supportsVision,
|
||||
|
||||
@ -2,6 +2,7 @@ import { expect, test } from "@playwright/test";
|
||||
import {
|
||||
createAtlasCloudImagePreset,
|
||||
inferAtlasCloudMediaKind,
|
||||
resolveAtlasCloudDisplayName,
|
||||
} from "@/lib/ai/atlascloud-models";
|
||||
import { createAtlasCloudRequestBody } from "@/lib/ai/atlascloud-request";
|
||||
import {
|
||||
@ -19,6 +20,23 @@ const atlasHunyuan3D = {
|
||||
};
|
||||
|
||||
test.describe("AI model media classification", () => {
|
||||
test("preserves administrator-defined AtlasCloud display names", () => {
|
||||
expect(
|
||||
resolveAtlasCloudDisplayName(
|
||||
"视觉 Flux Kontext Pro",
|
||||
"Flux Kontext Pro",
|
||||
"black-forest-labs/flux-kontext-pro"
|
||||
)
|
||||
).toBe("视觉 Flux Kontext Pro");
|
||||
expect(
|
||||
resolveAtlasCloudDisplayName(
|
||||
"",
|
||||
"Flux Kontext Pro",
|
||||
"black-forest-labs/flux-kontext-pro"
|
||||
)
|
||||
).toBe("Flux Kontext Pro");
|
||||
});
|
||||
|
||||
test("keeps multi-reference BananaImage models classified as image models", () => {
|
||||
const descriptor = {
|
||||
providerType: "bananaimage",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user