withBestProvider<R> method
Future<R?>
withBestProvider<R>(
- Set<
LLMCapability> required, - Future<
R> action(- String providerId,
- dynamic provider
- Set<
LLMCapability> ? preferred,
Execute action with the best available provider
Implementation
Future<R?> withBestProvider<R>(
Set<LLMCapability> required,
Future<R> Function(String providerId, dynamic provider) action, {
Set<LLMCapability>? preferred,
}) async {
final providerId = findBestProvider(required, preferred: preferred);
if (providerId == null) return null;
final provider = _providers[providerId];
if (provider == null) return null;
return await action(providerId, provider);
}