createProviderSafely<P>  method 
Helper method for creating provider instances with error handling
Implementation
T createProviderSafely<P>(
  LLMConfig config,
  P Function() configFactory,
  T Function(P) providerFactory,
) {
  try {
    validateConfigWithDetails(config);
    final providerConfig = configFactory();
    return providerFactory(providerConfig);
  } catch (e) {
    if (e is LLMError) {
      rethrow;
    }
    throw GenericError(
        'Failed to create $displayName provider: ${e.toString()}');
  }
}