Catch rate limit

This commit is contained in:
Cyber MacGeddon 2024-10-25 00:00:52 +01:00
parent 7954e863cc
commit 420e0282de

View file

@ -6,6 +6,7 @@ Input is prompt, output is response.
import google.generativeai as genai import google.generativeai as genai
from google.generativeai.types import HarmCategory, HarmBlockThreshold from google.generativeai.types import HarmCategory, HarmBlockThreshold
from google.api_core.exceptions import ResourceExhausted
from prometheus_client import Histogram from prometheus_client import Histogram
import os import os
@ -139,7 +140,7 @@ class Processor(ConsumerProducer):
# FIXME: Wrong exception, don't know what this LLM throws # FIXME: Wrong exception, don't know what this LLM throws
# for a rate limit # for a rate limit
except TooManyRequests: except ResourceExhausted as e:
print("Send rate limit response...", flush=True) print("Send rate limit response...", flush=True)