( apiConfiguration: ProviderSettings, routerModels?: RouterModels, organizationAllowList?: OrganizationAllowList, )
| 265 | * This is used to show model errors specifically in the model selector components. |
| 266 | */ |
| 267 | export function getModelValidationError( |
| 268 | apiConfiguration: ProviderSettings, |
| 269 | routerModels?: RouterModels, |
| 270 | organizationAllowList?: OrganizationAllowList, |
| 271 | ): string | undefined { |
| 272 | const modelId = isProviderName(apiConfiguration.apiProvider) |
| 273 | ? getModelIdForProvider(apiConfiguration, apiConfiguration.apiProvider) |
| 274 | : apiConfiguration.apiModelId |
| 275 | |
| 276 | const configWithModelId = { |
| 277 | ...apiConfiguration, |
| 278 | apiModelId: modelId || "", |
| 279 | } |
| 280 | |
| 281 | const orgError = validateProviderAgainstOrganizationSettings(configWithModelId, organizationAllowList) |
| 282 | |
| 283 | if (orgError && orgError.code === "MODEL_NOT_ALLOWED") { |
| 284 | return orgError.message |
| 285 | } |
| 286 | |
| 287 | return validateDynamicProviderModelId(configWithModelId, routerModels) |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Validates API configuration but excludes model-specific errors. |
no test coverage detected