mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Fix rate limit handler, incomplete (#293)
This commit is contained in:
parent
701ec1e27e
commit
d1e9577e7f
1 changed files with 6 additions and 16 deletions
|
|
@ -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}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue