mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-06 03:42:11 +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)
|
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(
|
# Leave rate limit retries to the base handler
|
||||||
error=Error(
|
raise TooManyRequests()
|
||||||
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)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
# Apart from rate limits, treat all exceptions as unrecoverable
|
||||||
|
|
||||||
print(type(e))
|
print(type(e))
|
||||||
print(f"Exception: {e}")
|
print(f"Exception: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue