Fix rate limit handler, incomplete (#293)

This commit is contained in:
cybermaggedon 2025-01-29 21:13:17 +00:00 committed by GitHub
parent 701ec1e27e
commit d1e9577e7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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}")