I'm playing with stealthy type character and I wonder if I take companion ,will hostile NPC attack us if they see my companion?
I am playing a sneaking characters as well, and just as Konerak stated, they will auto sneak with you.
However, it's worthwhile to note that their sneak is as good as yours is, and they do not add any noise, just another body, so if you can stay hidden, the two of you won't be heard.
Also, even if your companions gets attacked, if you're still hidden, they won't find you (they'll look for you, but you'll be able to stay hidden) so you're not directly linked.
As far as friendly NPCs are concerned, they don't notice nor care about your companion, so if you're pickpocketing or something, your companion is essentially invisible.
Most every NPC will screw you over other than Cicero and whatever NPC's you can find that have changeable armor because then you could of course just outfit them with some sneak enchanted armor. But I wouldn't take any of the companions from Whiterun, they will always get you caught. The Companion with the best chance is the Huntress.
One of the best "stealth" companions are both the Dark Brotherhood Initiates, and Serena from the Dawnguard installment. The only problem I've encountered while sneaking is having to deal with when your character comes in close contact with your follower which will cause them to step back and occasionally compromise your location. With some practice, you'll be able to ghost multiple enemies before your follower even reaches you. More importantly, the Dark Brotherhood Initiates will more often than not use whatever you give them and they can reach level 100.