fix(models): normalize media endpoint metadata (#11397)

Validado em lote combinado (batch-0824g) contra o tip de release/v3.8.50: typecheck:core limpo, gates estáticos OK, 62/62 testes focados passando (endpoint/parser/schema/static-model + catálogo).

Canonicaliza metadados de endpoint legados (video/audio) para IDs específicos por operação, mantendo compatibilidade retroativa via `normalizeModelSupportedEndpoints` (valores antigos `audio`/`video` continuam válidos como entrada e são normalizados na escrita). Obrigado pela contribuição, primeira PR bem-vinda!
This commit is contained in:
Marcelo Karval
2026-08-24 17:23:48 -03:00
committed by GitHub
parent f93fecd86b
commit 11cbd7d4e0
11 changed files with 233 additions and 55 deletions

View File

@@ -0,0 +1,54 @@
export const MODEL_SUPPORTED_ENDPOINT_VALUES = [
"chat",
"embeddings",
"rerank",
"images",
"videos",
"audio-speech",
"audio-transcriptions",
"images-generations",
// Persisted legacy values remain valid input and normalize on write/edit.
"video",
"audio",
] as const;
export type ModelSupportedEndpoint = (typeof MODEL_SUPPORTED_ENDPOINT_VALUES)[number];
export function normalizeModelSupportedEndpoints(endpoints: readonly string[]): string[] {
const normalized: string[] = [];
const add = (endpoint: string) => {
if (!normalized.includes(endpoint)) normalized.push(endpoint);
};
for (const endpoint of endpoints) {
if (endpoint === "video") {
add("videos");
} else if (endpoint === "audio") {
add("audio-speech");
add("audio-transcriptions");
} else {
add(endpoint);
}
}
return normalized;
}
export function classifyModelSupportedEndpoints(endpoints: readonly string[]): {
type?: "embedding" | "rerank" | "image" | "video" | "audio";
subtype?: "speech" | "transcription";
} {
if (endpoints.includes("embeddings")) return { type: "embedding" };
if (endpoints.includes("rerank")) return { type: "rerank" };
if (endpoints.includes("images")) return { type: "image" };
if (endpoints.includes("videos") || endpoints.includes("video")) return { type: "video" };
const supportsSpeech = endpoints.includes("audio-speech");
const supportsTranscription =
endpoints.includes("audio-transcriptions") || endpoints.includes("audio");
if (!supportsSpeech && !supportsTranscription) return {};
if (supportsSpeech && !supportsTranscription) return { type: "audio", subtype: "speech" };
if (supportsTranscription && !supportsSpeech) {
return { type: "audio", subtype: "transcription" };
}
return { type: "audio" };
}