Fix rate limit handler, incomplete

This commit is contained in:
Cyber MacGeddon 2025-01-29 21:12:34 +00:00
parent 701ec1e27e
commit 08e38d5891

View file

@ -258,27 +258,17 @@ class Processor(ConsumerProducer):
print("Done.", flush=True)
except self.bedrock.exceptions.ThrottlingException:
except self.bedrock.exceptions.ThrottlingException as e:
print("Send rate limit response...", flush=True)
print("Hit rate limit:", e, flush=True)
r = TextCompletionResponse(
error=Error(
type = "rate-limit",
message = str(e),
),
response=None,
in_token=None,
out_token=None,
model=None,
)
self.producer.send(r, properties={"id": id})
self.consumer.acknowledge(msg)
# Leave rate limit retries to the base handler
raise TooManyRequests()
except Exception as e:
# Apart from rate limits, treat all exceptions as unrecoverable
print(type(e))
print(f"Exception: {e}")