Browse Source

refactor: simplify mapFalCategory with lookup map

Replace 3 if-statements mapping fal audio categories to a single
record lookup, making it easier to add new audio categories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
5843edac8a
  1. 16
      src/app/api/models/route.ts

16
src/app/api/models/route.ts

@ -802,15 +802,15 @@ async function fetchWaveSpeedModels(apiKey: string): Promise<ProviderModel[]> {
// ============ Fal.ai Helpers ============ // ============ Fal.ai Helpers ============
const FAL_AUDIO_CATEGORIES: Record<string, ModelCapability> = {
"text-to-speech": "text-to-audio",
"text-to-music": "text-to-audio",
"text-to-sound-effects": "text-to-audio",
};
function mapFalCategory(category: string): ModelCapability | null { function mapFalCategory(category: string): ModelCapability | null {
if (category === "text-to-speech") { if (category in FAL_AUDIO_CATEGORIES) {
return "text-to-audio"; return FAL_AUDIO_CATEGORIES[category];
}
if (category === "text-to-music") {
return "text-to-audio";
}
if (category === "text-to-sound-effects") {
return "text-to-audio";
} }
if (RELEVANT_CATEGORIES.includes(category)) { if (RELEVANT_CATEGORIES.includes(category)) {
return category as ModelCapability; return category as ModelCapability;

Loading…
Cancel
Save