INNER CODE UNIT · JavaScript

is503or504Error

kxxt/chatgpt-action · chatgpt.js:15

function is503or504Error(err) {
  return err.message.includes("503") || err.message.includes("504");
}

async function callChatGPT(api, content, retryOn503) {
  let cnt = 0;
  while (cnt++ <= retryOn503) {
    try {
      const response = await api.sendMessage(content);
      return response;
    } catch (err) {
      if (!is503or504Error(err)) throw err;
    }
  }
}

function startConversation(api, retryOn503) {
  const conversation = api.getConversation();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…