INNER CODE UNIT · JavaScript

createChatGPTAPI

kxxt/chatgpt-action · chatgpt.js:3

async function createChatGPTAPI(sessionToken) {
  // To use ESM in CommonJS, you can use a dynamic import
  const { ChatGPTAPI } = await import("chatgpt");

  const api = new ChatGPTAPI({ sessionToken });

  // ensure the API is properly authenticated
  await api.ensureAuth();

  return api;
}

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

async function callChatGPT(api, content, retryOn503) {
  let cnt = 0;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…