model.generate_content() is not returning any response.
google.generativeai.list_models() also not returning any response
Welcome to the forum. And yet, they both work. Please explain (with some code) under what conditions you are getting no response from these functions. That will likely get you some help.
At the moment it is WORKING. But it doesn’t respond for long durations in between randomly.
I’m using Google Colab. I have a dataset of around 750 records for each of which I need to run 2 sets of prompt to mimic a particular flow in a RAG pipeline.
But while running the following test code itself I wasn’t getting results.
Is there any specified downtime which I’m not aware of? I tried creating a new API_KEY and using it. Also are there any rate limits?
!pip install -q -U google-generativeai
----------------------------------
from google.colab import userdata
GOOGLE_API_KEY=userdata.get('GOOGLE_API_KEY")
----------------------------------
import google.generativeai as genai
genai.configure(api_key=GOOGLE_API_KEY)
for m in genai.list_models():
** if ‘generateContent’ in m.supported_generation_methods:**
** print(m.name)**
--------------------------------------------
#Test Run
import google.generativeai as genai
import os
genai.configure(api_key=GOOGLE_API_KEY)
model = genai.GenerativeModel(‘models/gemini-1.5-pro’)
response = model.generate_content(‘What is the meaning of life?’)
print(response.text)
------------------------------------------------------------
Typically when there are errors, there is at least some kind of response or exception. When you say it “doesn’t respond” - what exactly is happening?
No, there shouldn’t be.
If the API Key is in the same project, that probably won’t help. This doesn’t sound like an API Key problem if you’re sometimes getting responses.
Welcome to the forums!
Yes, there are rate limits.
See https://ai.google.dev/pricing for the official limits if you’re using the AI Studio API. But keep in mind that even those limits aren’t guaranteed.
Thank you for the information.
But, now while executing the same code above, it is taking too long to respond . I had stopped execution of one cell in colab which made a call to model.generate_content(). I think it happened after that. Getting timeout error. Attaching screenshot
You can try to extend the timeout from the 60 it currently defaults to. This example code shows how to use request_options
to specify a longer timeout: Prompting with media files | Gemini API | Google for Developers
Hope this helps!