From 21051160aab0761af7591eab7883be9ef9b5984d Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 17 Jul 2023 03:51:01 -0700 Subject: [PATCH] Change default wait interval from 250 to 1000 milliseconds --- index.js | 6 +++--- lib/predictions.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index ce97fcf..73d2187 100644 --- a/index.js +++ b/index.js @@ -78,7 +78,7 @@ class Replicate { * @param {object} options * @param {object} options.input - Required. An object with the model inputs * @param {object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false - * @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250 + * @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 1000 * @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit * @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output * @param {string[]} [options.webhook_events_filter] - You can change which events trigger webhook requests by specifying webhook events (`start`|`output`|`logs`|`completed`) @@ -192,7 +192,7 @@ class Replicate { * @async * @param {object} prediction - Prediction object * @param {object} options - Options - * @param {number} [options.interval] - Polling interval in milliseconds. Defaults to 250 + * @param {number} [options.interval] - Polling interval in milliseconds. Defaults to 1000 * @param {number} [options.maxAttempts] - Maximum number of polling attempts. Defaults to no limit * @throws {Error} If the prediction doesn't complete within the maximum number of attempts * @throws {Error} If the prediction failed @@ -218,7 +218,7 @@ class Replicate { const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); let attempts = 0; - const interval = options.interval || 250; + const interval = options.interval || 1000; const maxAttempts = options.maxAttempts || null; while ( diff --git a/lib/predictions.js b/lib/predictions.js index ba46ef8..ca87eaa 100644 --- a/lib/predictions.js +++ b/lib/predictions.js @@ -5,7 +5,7 @@ * @param {string} options.version - Required. The model version * @param {object} options.input - Required. An object with the model inputs * @param {boolean|object} [options.wait] - Whether to wait for the prediction to finish. Defaults to false - * @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 250 + * @param {number} [options.wait.interval] - Polling interval in milliseconds. Defaults to 1000 * @param {number} [options.wait.maxAttempts] - Maximum number of polling attempts. Defaults to no limit * @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output * @param {string[]} [options.webhook_events_filter] - You can change which events trigger webhook requests by specifying webhook events (`start`|`output`|`logs`|`completed`) @@ -33,7 +33,7 @@ async function createPrediction(options) { // eslint-disable-next-line no-promise-executor-return const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); - await sleep(interval || 250); + await sleep(interval || 1000); return this.wait(await prediction, { maxAttempts, interval }); }