erictik / midjourney-api

MidJourney client. Unofficial Node.js client
Apache License 2.0
1.69k stars 283 forks source link

Imagine() does not throw error if prompt is against MJ standards #214

Open manhhailua opened 1 year ago

manhhailua commented 1 year ago

the code that reproduces this issue or a replay of the bug

try {
      const imagine = await this.client.Imagine(
        jobData.prompt,
        async (uri, progress) => {
          console.debug("imagine in progress", uri, progress);
        },
      );
      if (imagine) {
        console.info("imagine successfully", imagine);
        return imagine;
      }
    } catch (e) {
      console.error("imagine failed", e);

      if (e.message.includes("against our community standards")) {
        // Error message might contain:
        //
        // Sorry! Our AI moderator thinks this prompt is probably against our community standards.
        //
        // Please review our current community standards:
        //
        // **ALLOWED**
        // - Any image up to PG-13 rating involving fiction, fantasy, mythology.
        // - Real images that may be seen as respectful or light-hearted parodies, satire, caricatures
        // - Imaginary or exaggerated real-life scenarios, including absurd or humorous situations.
        //
        // **NOT ALLOWED**
        // - Disrespectful, harmful, misleading public figures/events portrayals or potential to mislead.
        // - Hate speech, explicit or real-world violence.
        // - Nudity or unconsented overtly sexualized public figures.
        // - Imagery that might be considered culturally insensitive
        //
        // This AI system isn't perfect. If you find it rejecting something innocent please press the **Notify Developers** button and we will review it and try to further improve our performance. Thank you for your help!"
      }

      return null;
    }

Describe the bug

Describe the bug

  1. Enter the prompt which is to draw porn or weapon or anything might against MJ standards
  2. Submit the prompt successfully and receive an error model show that the prompt is against MJ community standards
  3. client.Imagine() does not throw any error

Expected behavior

Screenshots The weird thing, If I put a break point at line 633 of src/discord.ws.ts, client.Imagine() throws error correctly. image image

But if I remove the break point, got the log of error modal but no error is thrown. image

error log

Error: Sorry! Our AI moderator thinks this prompt is probably against our community standards. Please review our current community standards: ALLOWED - Any image up to PG-13 rating involving fiction, fantasy, mythology. - Real images that may be seen as respectful or light-hearted parodies, satire, caricatures - Imaginary or exaggerated real-life scenarios, including absurd or humorous situations. NOT ALLOWED - Disrespectful, harmful, misleading public figures/events portrayals or potential to mislead. - Hate speech, explicit or real-world violence. - Nudity or unconsented overtly sexualized public figures. - Imagery that might be considered culturally insensitive This AI system isn't perfect. If you find it rejecting something innocent please press the Notify Developers button and we will review it and try to further improve our performance. Thank you for your help! at WsMessage.messageCreate (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:132:39) at WsMessage.onMessageCreate (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:237:14) at D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:464:31 at Array.forEach () at WsMessage.emit (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:464:14) at WsMessage.emitSystem (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:483:14) at WsMessage.parseMessage (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:277:22) at WebSocket. (D:\Chatbot\midreborn\modules\mj_workers\node_modules\midjourney\libs\discord.ws.js:83:18) at callListener (D:\Chatbot\midreborn\modules\mj_workers\node_modules\ws\lib\event-target.js:290:14) at WebSocket.onMessage (D:\Chatbot\midreborn\modules\mj_workers\node_modules\ws\lib\event-target.js:209:9)