diff --git a/Libraries/MLXLMCommon/Registries/ModelTypeRegistry.swift b/Libraries/MLXLMCommon/Registries/ModelTypeRegistry.swift index d050b8077..ebe06f2a9 100644 --- a/Libraries/MLXLMCommon/Registries/ModelTypeRegistry.swift +++ b/Libraries/MLXLMCommon/Registries/ModelTypeRegistry.swift @@ -31,4 +31,12 @@ public actor ModelTypeRegistry { return try creator(configuration) } + /// Whether a creator is registered for `modelType` — i.e. this registry can + /// instantiate that architecture. Lets a caller check support without + /// attempting a (throwing, allocating) `createModel`, e.g. to decide before + /// a multi-GB download whether a Hub repo's `model_type` is runnable. + public func contains(_ modelType: String) -> Bool { + creators[modelType] != nil + } + }