@nomyx/assistant
Version:
A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)
21 lines (20 loc) • 796 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExponentialBackoffRetryStrategy = void 0;
class ExponentialBackoffRetryStrategy {
constructor(maxRetries = 3, baseDelay = 1000) {
this.maxRetries = maxRetries;
this.baseDelay = baseDelay;
}
shouldRetry(error, attemptNumber) {
// Implement logic to determine if a retry should be attempted
// For example, retry on network errors or rate limiting
return attemptNumber < this.maxRetries;
}
getDelay(attemptNumber) {
// Implement exponential backoff
return Math.min(this.baseDelay * Math.pow(2, attemptNumber), 30000 // Max delay of 30 seconds
);
}
}
exports.ExponentialBackoffRetryStrategy = ExponentialBackoffRetryStrategy;