mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-25 08:32:11 +03:00
Retargetado para release/v3.8.51 (release/v3.8.50 está congelada — freeze issue #11439). Resolvido um conflito de merge não-relacionado em src/shared/utils/wsPath.ts (originado de um refactor já mergeado nessa branch depois do fork deste PR; o diff real deste PR — scripts/dev/sync-env.mjs + tests/unit/sync-env.test.ts — ficou intacto) e revalidado: typecheck:core limpo, 13/13 testes focados passando. Segue o precedente correto do #1622 (STORAGE_ENCRYPTION_KEY) para os dois secrets restantes que a postinstall preenchia por engano, defeituando o mecanismo de ensureSecrets(). Obrigado pela contribuição!
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
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" };
|
|
}
|