(model: CatalogModelEntry)
| 118 | |
| 119 | /** Normalizes one catalog model entry into a {@link CatalogModel}; skips invalid entries. */ |
| 120 | export function catalogModelToCapability(model: CatalogModelEntry): CatalogModel | undefined { |
| 121 | if (typeof model.id !== 'string' || model.id.length === 0) return undefined; |
| 122 | const context = model.limit?.context; |
| 123 | if (typeof context !== 'number' || !Number.isInteger(context) || context <= 0) return undefined; |
| 124 | if (!isUsableChatModel(model)) return undefined; |
| 125 | const inputs = model.modalities?.input ?? []; |
| 126 | const output = model.limit?.output; |
| 127 | return { |
| 128 | id: model.id, |
| 129 | name: typeof model.name === 'string' && model.name.length > 0 ? model.name : undefined, |
| 130 | maxOutputSize: typeof output === 'number' && output > 0 ? output : undefined, |
| 131 | reasoningKey: catalogReasoningKey(model.interleaved), |
| 132 | capability: { |
| 133 | image_in: inputs.includes('image'), |
| 134 | video_in: inputs.includes('video'), |
| 135 | audio_in: inputs.includes('audio'), |
| 136 | thinking: Boolean(model.reasoning), |
| 137 | tool_use: model.tool_call ?? true, |
| 138 | max_context_tokens: context, |
| 139 | }, |
| 140 | }; |
| 141 | } |
| 142 | |
| 143 | function catalogReasoningKey(interleaved: CatalogModelEntry['interleaved']): string | undefined { |
| 144 | // models.dev allows `interleaved: true` as "general support" — read it as |
no test coverage detected