engineHuggingFaceResolvers static method
The Hugging Face resolvers contributed by engines that implement
HuggingFaceResolverSource (e.g. LiteRtLmEngine → LitertlmManifestResolver).
initialize registers these AFTER the explicit huggingFaceResolvers:
list, so an app's explicit resolver wins the equal-priority tie. An engine
that does not implement HuggingFaceResolverSource contributes nothing.
Extracted so the derivation is unit-testable without a full initialize.
Implementation
@visibleForTesting
static List<HuggingFaceResolver> engineHuggingFaceResolvers(
List<InferenceEngineProvider> engines,
) {
final resolvers = <HuggingFaceResolver>[];
for (final e in engines) {
// Bind via pattern: HuggingFaceResolverSource is not a subtype of
// InferenceEngineProvider, so a plain `is` check would not promote `e`.
if (e case final HuggingFaceResolverSource source) {
resolvers.add(source.huggingFaceResolver);
}
}
return resolvers;
}