()
| 56 | let catalogPromise: Promise<ModelsDevCatalog | null> | null = null; |
| 57 | |
| 58 | async function loadCatalog(): Promise<ModelsDevCatalog | null> { |
| 59 | if (!catalogPromise) { |
| 60 | catalogPromise = (async () => { |
| 61 | try { |
| 62 | const response = await fetch(MODELS_DEV_API_URL, { |
| 63 | signal: AbortSignal.timeout(FETCH_TIMEOUT_MS), |
| 64 | }); |
| 65 | if (!response.ok) { |
| 66 | return null; |
| 67 | } |
| 68 | return await response.json() as ModelsDevCatalog; |
| 69 | } catch { |
| 70 | return null; |
| 71 | } |
| 72 | })(); |
| 73 | } |
| 74 | return catalogPromise; |
| 75 | } |
| 76 | |
| 77 | async function getModelOptionsForProvider(providerKey: string): Promise<ModelOption[] | null> { |
| 78 | const catalog = await loadCatalog(); |
no outgoing calls
no test coverage detected