Fiz a resolução junto com o Prof. Fabrício mas retornou ERRO 429
Ao tentar resolver o problema com a IA, foi gerado o seguinte script como sugestão para a solução:
import time
summarized_emails = []
for email_body in email_bodies:
try:
# Chamando a API do Gemini para obter o resumo de cada email
resposta = client.models.generate_content(
model="gemini-2.5-flash",
contents=f"""I'll send you an email body. I want you to sum it up in just one line, by telling the purpose of the email.
Follows the email body: {email_body} """
)
summarized_emails.append(resposta.text)
print(f"Original email (first 50 chars): {email_body[:50]}...")
print(f"Summary: {resposta.text}")
print("-" * 50)
# Introduce a 2-second delay to avoid hitting the rate limit again
time.sleep(2)
except Exception as e:
print(f"Error summarizing email (first 50 chars): {email_body[:50]}...")
print(f"Error details: {e}")
print("-" * 50)
# Wait longer on error before continuing to give the quota a chance to reset
time.sleep(10)
print("\nAll summarized emails:")
for summary in summarized_emails:
print(summary)
Porém, o ERRO 429 ainda continua aparecendo. Tem como dar um auxílio, por favor?
