I upgraded the generativeai dependency from 0.2.2 to 0.9.0 and now it works. Give that a try 👍
generativeai