erictik / midjourney-api

MidJourney client. Unofficial Node.js client
Apache License 2.0
1.64k stars 269 forks source link

Fetch issue when working with the Describe function #270

Closed Slushbanq closed 2 months ago

Slushbanq commented 2 months ago

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

I got two functions, one for generating image and one for describing an image. The one that works looks like this

async function generateImage() { //Some code in between... const prompt = ${imageLink} ( ${type} ${style} print design of a ${enDescription}, in ${style} style, ${type} type art, 2D design --ar 200:200 --v ${vInput} --s ${sInput} --iw ${iwInput} ${negativeprompt};

    console.log("Current Prompt:", prompt);

    // Initialize Midjourney client
    const client = new Midjourney({
        ServerId: "SVID",
        ChannelId: "CHID",
        SalaiToken: "my Token",
        fetch: fetch, 
        Ws: true,
    });
    await client.init(); 

    // Call Imagine method to generate image
    const imageResponse = await client.imagine(prompt, (uri, progress) => {
        console.log("Loading", uri, "Progress", progress);
    });

This Part works. The problem is with the describe function. And it looks like almost identical to the Imagine function

async function describeImage() {

try {

    let imageLink = $w("#image1").link;
    console.log(imageLink);

    const client = new Midjourney({
        ServerId: "same Server",
        ChannelId: "same ID",
        SalaiToken: "same token",
        fetch: fetch, 

    });
    await client.init();

    const Describe = await client.Describe(
        imageLink
         );
            console.log(Describe);
            if (!Describe) {
            console.log("failed to describe");
            }

Describe the bug

I don't understand how I can get connection issues with only one particular function. The other commands seem to be working fine.

error log

I connect to midjourney and get this message at first: 🎊 ws ready!!! Hi: Slushbanq But then the error log comes in. Error generating image: TypeError: NetworkError when attempting to fetch resource.