ask-core 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/ask/errors.rb +34 -7
- data/lib/ask/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b573cb0709bd479e2a888becc0ce41cacafcf5f2e48afee24b2d6af1a7b99d5
|
|
4
|
+
data.tar.gz: c690b789d00985df0d9723c4f436c6b4a51e62f1857479af9ff2f652b59cd7d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4506564311573fcd2a43d277eef97157d1abafa7add2968bc336551ad1f6e4133f87b1aa2d47607963e2c0b3d0fdfb92ad332c6ff55eddb3a927276cee647a3e
|
|
7
|
+
data.tar.gz: ec2c10ed1152e01783272fffc16ff0695334c53bae829d9a0ebb7077317c084b3587490d6bc80820e2c78fd10e19e676dfe319147f667a4a453f763fb08782a7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [0.2.4] — 2026-07-17
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **Rich error categories** — `RateLimitError` now carries `category` (`RateLimitCategory::VENDOR` or `::LOCAL`), `rate_limit_type` (`RateLimitType::REQUESTS`, `::TOKENS`, `::CONCURRENT`, `::BUDGET`), and `retry_after` (seconds) for intelligent error handling. Inspired by LiteLLM's error hierarchy.
|
|
6
|
+
|
|
1
7
|
## [0.2.3] — 2026-07-14
|
|
2
8
|
|
|
3
9
|
### Changed
|
data/lib/ask/errors.rb
CHANGED
|
@@ -28,9 +28,6 @@ module Ask
|
|
|
28
28
|
# Raised when the context window is exceeded.
|
|
29
29
|
class ContextLengthExceeded < Error; end
|
|
30
30
|
|
|
31
|
-
# Raised when the API rate limit is hit.
|
|
32
|
-
class RateLimitError < Error; end
|
|
33
|
-
|
|
34
31
|
# Raised when authentication fails.
|
|
35
32
|
class Unauthorized < Error; end
|
|
36
33
|
|
|
@@ -40,11 +37,41 @@ module Ask
|
|
|
40
37
|
# Raised when the service is unavailable.
|
|
41
38
|
class ServiceUnavailable < Error; end
|
|
42
39
|
|
|
40
|
+
# Categories for {RateLimitError} — tells you who rate-limited the request.
|
|
41
|
+
module RateLimitCategory
|
|
42
|
+
VENDOR = :vendor # upstream LLM provider (OpenAI, Anthropic, etc.)
|
|
43
|
+
LOCAL = :local # ask-rb's own limiter (ask-auth thresholds)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Rate limit dimension that was exceeded — orthogonal to {RateLimitCategory}.
|
|
47
|
+
module RateLimitType
|
|
48
|
+
REQUESTS = :requests # requests-per-minute ceiling
|
|
49
|
+
TOKENS = :tokens # tokens-per-minute ceiling
|
|
50
|
+
CONCURRENT = :concurrent # max parallel requests
|
|
51
|
+
BUDGET = :budget # spend budget cap
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Raised when the API rate limit is hit.
|
|
55
|
+
# Carries optional category, type, and retry_after for intelligent handling.
|
|
56
|
+
class RateLimitError < Error
|
|
57
|
+
# @return [Symbol, nil] who rate-limited (:vendor, :local)
|
|
58
|
+
attr_reader :category
|
|
59
|
+
|
|
60
|
+
# @return [Symbol, nil] which limit was hit (:requests, :tokens, :concurrent, :budget)
|
|
61
|
+
attr_reader :rate_limit_type
|
|
62
|
+
|
|
63
|
+
# @return [Integer, Float, nil] suggested seconds to wait before retrying
|
|
64
|
+
attr_reader :retry_after
|
|
65
|
+
|
|
66
|
+
def initialize(message, category: nil, rate_limit_type: nil, retry_after: nil)
|
|
67
|
+
@category = category
|
|
68
|
+
@rate_limit_type = rate_limit_type
|
|
69
|
+
@retry_after = retry_after
|
|
70
|
+
super(message)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
43
74
|
# Raised when a provider's API returns an unexpected response.
|
|
44
|
-
# @!attribute [r] status_code
|
|
45
|
-
# @return [Integer, nil] the HTTP status code
|
|
46
|
-
# @!attribute [r] response_body
|
|
47
|
-
# @return [String, nil] the raw response body
|
|
48
75
|
class ProviderError < Error
|
|
49
76
|
attr_reader :status_code, :response_body
|
|
50
77
|
|
data/lib/ask/version.rb
CHANGED