feat(clients): perplexity: Sonar, Search, Agent, embeddings, decisions, batches, skills, orchestrator
Package molo::perplexity covering all 39 operations of the five published OpenAPI documents, PerplexityChatModel, demo routes under /ai/perplexity, check_spec.py, SPEC.md, 46 unit cases and 111 route checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
// Perplexity error statuses and what to do about them. Sources: the OpenAPI
|
||||
// error responses, the FAQ ("Errors & Troubleshooting") and the Rate Limits
|
||||
// page. Waits are static advice; nothing here sleeps or retries on its own.
|
||||
// A 429 carries Retry-After, which llm::ApiError drops (src/llm gap): the
|
||||
// static floor below is used instead.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "llm/error.h"
|
||||
|
||||
namespace molo::perplexity {
|
||||
|
||||
enum class ErrorKind {
|
||||
kNone, kBadRequest, kAuth, kPayment, kForbidden, kNotFound, kConflict, kTooLarge,
|
||||
kInvalidParams, kRateLimit, kServer, kBadGateway, kOverloaded, kGatewayTimeout, kTransport, kOther,
|
||||
};
|
||||
|
||||
struct ErrorInfo {
|
||||
int status;
|
||||
ErrorKind kind;
|
||||
const char* name;
|
||||
const char* cause;
|
||||
const char* action;
|
||||
bool retryable; // wait and retry the same request
|
||||
int min_wait_seconds; // floor before a retry; 0 when not retryable
|
||||
};
|
||||
|
||||
class Errors {
|
||||
public:
|
||||
static std::size_t count();
|
||||
static const ErrorInfo& at(std::size_t index);
|
||||
static const ErrorInfo* find(int status);
|
||||
static ErrorKind kind_of(int status);
|
||||
static bool retryable(int status);
|
||||
// Static wait before a retry (0: do not retry). Hard cap kMaxWaitSeconds.
|
||||
static int wait_seconds(int status);
|
||||
static constexpr int kMaxWaitSeconds = 30;
|
||||
// The documented 429 error.type values.
|
||||
static bool is_rate_limit_type(const std::string& type);
|
||||
// One line for humans: "402 Payment Required: add credits ...".
|
||||
static std::string explain(const llm::ApiError& e);
|
||||
};
|
||||
|
||||
} // namespace molo::perplexity
|
||||
Reference in New Issue
Block a user