(model: RawModel, type: Model["type"])
| 77 | } |
| 78 | |
| 79 | function apiModelToModel(model: RawModel, type: Model["type"]): Model | null { |
| 80 | const id = modelId(model); |
| 81 | if (!id) return null; |
| 82 | |
| 83 | if (typeof model === "string") { |
| 84 | return { |
| 85 | id, |
| 86 | name: id, |
| 87 | title: id, |
| 88 | type, |
| 89 | hasImageInput: false, |
| 90 | hasAudioOutput: false, |
| 91 | hasVideoOutput: false, |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | return { |
| 96 | id, |
| 97 | name: id, |
| 98 | title: model.title || model.description?.split(" - ")[0]?.trim() || id, |
| 99 | description: model.description, |
| 100 | type, |
| 101 | hasImageInput: model.input_modalities?.includes("image") || false, |
| 102 | hasAudioOutput: model.output_modalities?.includes("audio") || false, |
| 103 | hasVideoOutput: model.output_modalities?.includes("video") || false, |
| 104 | inputModalities: model.input_modalities, |
| 105 | outputModalities: model.output_modalities, |
| 106 | voices: model.voices, |
| 107 | paid_only: model.paid_only, |
| 108 | }; |
| 109 | } |
| 110 | |
| 111 | async function fetchJson(url: string, headers?: Record<string, string>) { |
| 112 | const response = await fetch(url, { headers }); |
no test coverage detected