Inspired by First AI to not follow a command?, I was wondering when the first positive depictions of AI appeared? Fiction is littered with rebellious robots from HAL 9000 to Skynet to Ultron, negative portrayals are the most common trope from the beginnings of science fiction. 19th century authors such as Samuel Butler and George Elliot anticipated that an evolutionary AI might supplant us.
From Erewhon (1872):
Assume for the sake of argument that conscious beings have existed for some twenty million years: see what strides machines have made in the last thousand! May not the world last twenty million years longer? If so, what will they not in the end become? Is it not safer to nip the mischief in the bud and to forbid them further progress?
(The Butlerian Jihad in the Dune Universe, the crusade against thinking machines, is named after Samuel Butler).
The classical Greek Talos perhaps doesn't quite qualify. While it is certainly obedient to its creator it doesn't exhibit any kind of independent action or personality.
Frakenstein's Creature (1818), arguably the first AI in fiction, certainly has the capacity for empathy and compassion:
“I saw no cause for their unhappiness, but I was deeply affected by it. If such lovely creatures were miserable, it was less strange that I, an imperfect and solitary being, should be wretched.”
“The gentle manners and beauty of the cottagers greatly endeared them to me: when they were unhappy, I felt depressed; when they rejoiced, I sympathized in their joys.”
The Creature also rescues a child from drowning in a river but he is shot through the shoulder by the child's father, who assumes he means harm. It's this incident and his earlier rejections that causes the Creature to reject humanity and go on a murderous rampage. Although the Creature does ultimately repent its actions this disqualifies it.