Assume you're supposed to defeat a horde that materializes after you pick up an item. Now: leaving aside everything else, does the quality of the item depend in part on the number and level of enemies?
Item quality is completely random. However, the deeper you go in the dungeon, the better the 'artifact' bonuses are.
Actually, both item quality and artifact quality vary by dungeon level. If item quality was completely random, you might get a Katana on DL1 -- that's not going to happen.
So, just to be clear: if you face 2 enemies or 10 enemies on level 8, this will not affect the quality of the artifact?
No, it won't. Just retreat and face them one at a time - unless they're named animals while you're playing an underdeveloped vegan, they're nothing tough.