( apiConfiguration: ProviderSettings, routerModels?: RouterModels, )
| 235 | } |
| 236 | |
| 237 | function validateDynamicProviderModelId( |
| 238 | apiConfiguration: ProviderSettings, |
| 239 | routerModels?: RouterModels, |
| 240 | ): string | undefined { |
| 241 | const provider = apiConfiguration.apiProvider ?? "" |
| 242 | |
| 243 | // We only validate model ids from dynamic providers. |
| 244 | if (!isDynamicProvider(provider)) { |
| 245 | return undefined |
| 246 | } |
| 247 | |
| 248 | const modelId = getModelIdForProvider(apiConfiguration, provider) |
| 249 | |
| 250 | if (!modelId) { |
| 251 | return i18next.t("settings:validation.modelId") |
| 252 | } |
| 253 | |
| 254 | const models = routerModels?.[provider] |
| 255 | |
| 256 | if (models && Object.keys(models).length > 1 && !Object.keys(models).includes(modelId)) { |
| 257 | return i18next.t("settings:validation.modelAvailability", { modelId }) |
| 258 | } |
| 259 | |
| 260 | return undefined |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Extracts model-specific validation errors from the API configuration. |
no test coverage detected