MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / validateDynamicProviderModelId

Function validateDynamicProviderModelId

webview-ui/src/utils/validate.ts:237–261  ·  view source on GitHub ↗
(
	apiConfiguration: ProviderSettings,
	routerModels?: RouterModels,
)

Source from the content-addressed store, hash-verified

235}
236
237function 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.

Callers 2

validateApiConfigurationFunction · 0.85
getModelValidationErrorFunction · 0.85

Calls 3

isDynamicProviderFunction · 0.90
getModelIdForProviderFunction · 0.70
keysMethod · 0.65

Tested by

no test coverage detected