I had this error too, but replaced "gemini-1.5-flash" with the following code. It works fine now.
modelName = "gemini-2.5-pro"