Exception: Parse::Embeddings::SpendCap::Exceeded
- Inherits:
-
StandardError
- Object
- StandardError
- Parse::Embeddings::SpendCap::Exceeded
- Defined in:
- lib/parse/embeddings/spend_cap.rb
Overview
Raised when a tenant would exceed its token cap. Carries the
limit, the already-used count (within the window), and a
retry_after hint (seconds until enough of the window rolls off
to admit the rejected charge — nil if the charge can never fit).
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#requested ⇒ Object
readonly
Returns the value of attribute requested.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#used ⇒ Object
readonly
Returns the value of attribute used.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
-
#initialize(tenant_id:, limit:, used:, requested:, window:, retry_after:) ⇒ Exceeded
constructor
A new instance of Exceeded.
Constructor Details
#initialize(tenant_id:, limit:, used:, requested:, window:, retry_after:) ⇒ Exceeded
Returns a new instance of Exceeded.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/parse/embeddings/spend_cap.rb', line 47 def initialize(tenant_id:, limit:, used:, requested:, window:, retry_after:) @tenant_id = tenant_id @limit = limit @used = used @requested = requested @window = window @retry_after = retry_after super( "Embedding spend cap exceeded for tenant #{tenant_id.inspect}: " \ "#{used}+#{requested} tokens would exceed #{limit}/#{window}s." \ "#{retry_after ? " Retry after #{retry_after.round(1)}s." : " Request exceeds the cap outright."}" ) end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def limit @limit end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def requested @requested end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def retry_after @retry_after end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def tenant_id @tenant_id end |
#used ⇒ Object (readonly)
Returns the value of attribute used.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def used @used end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
45 46 47 |
# File 'lib/parse/embeddings/spend_cap.rb', line 45 def window @window end |