Module: OpenAICompatibleErrors
- Defined in:
- lib/openai_compatible_errors.rb,
lib/openai_compatible_errors/sse.rb,
lib/openai_compatible_errors/error.rb,
lib/openai_compatible_errors/retry.rb,
lib/openai_compatible_errors/headers.rb,
lib/openai_compatible_errors/version.rb,
lib/openai_compatible_errors/normalize.rb,
lib/openai_compatible_errors/redaction.rb
Defined Under Namespace
Modules: Headers, Normalizer, Redaction, Retry
Classes: ApiError, RetryContext, RetryPlan, RetryPolicy, SSEInspector, StreamState
Constant Summary
collapse
- CATEGORIES =
%i[
authentication
permission
rate_limit
quota
conflict
validation
not_found
payload_too_large
timeout
network
upstream
server
schema
endpoint
aborted
stream
unknown
].freeze
- SOURCES =
%i[http httpx openai_sdk sse unknown].freeze
- SAFE_MESSAGES =
{
authentication: "The API request could not be authenticated.",
permission: "The API request was not permitted.",
rate_limit: "The API rate limit was reached.",
quota: "The API quota is unavailable or exhausted.",
conflict: "The API request conflicted with current server state.",
validation: "The API request was rejected as invalid.",
not_found: "The requested API resource was not found.",
payload_too_large: "The API request payload was too large.",
timeout: "The API request timed out.",
network: "The API request failed at the network boundary.",
upstream: "The upstream API was temporarily unavailable.",
server: "The API returned a server error.",
schema: "The API payload did not match the expected schema.",
endpoint: "The API endpoint was not found.",
aborted: "The API request was cancelled by the caller.",
stream: "The API stream ended with an error.",
unknown: "The API request failed for an unclassified reason."
}.freeze
- NormalizedError =
ApiError
- RETRY_ACTIONS =
%i[retry do_not_retry manual_decision].freeze
- RETRY_REASONS =
%i[
transient_and_replay_safe
partial_stream_output
request_completed
conflict_requires_resolution
replay_unsafe
caller_aborted
permanent_error
attempt_budget_exhausted
time_budget_exhausted
retry_after_exceeds_budget
unclassified_error
unknown_phase
unknown_replay_safety
invalid_context
].freeze
- REQUEST_PHASES =
%i[
before_send awaiting_headers http_error sse_before_output
sse_after_output completed unknown
].freeze
- REPLAY_SAFETY =
%i[safe unsafe unknown].freeze
- DELAY_SOURCES =
%i[server backoff].freeze
- VERSION =
"0.1.2"
Class Method Summary
collapse
Class Method Details
.decide_retry(error, context, **options) ⇒ Object
179
180
181
|
# File 'lib/openai_compatible_errors/retry.rb', line 179
def decide_retry(error, context, **options)
Retry.decide_retry(error, context, **options)
end
|
.normalize_error(input = nil, **options) ⇒ Object
Also known as:
normalize
249
250
251
|
# File 'lib/openai_compatible_errors/normalize.rb', line 249
def normalize_error(input = nil, **options)
Normalizer.normalize(input, **options)
end
|
.redact_sensitive_text(value, **options) ⇒ Object
14
15
16
|
# File 'lib/openai_compatible_errors.rb', line 14
def redact_sensitive_text(value, **options)
Redaction.redact_sensitive_text(value, **options)
end
|
.sanitize_for_log(value, **options) ⇒ Object
18
19
20
|
# File 'lib/openai_compatible_errors.rb', line 18
def sanitize_for_log(value, **options)
Redaction.sanitize_for_log(value, **options)
end
|