Closed lordmen99 closed 1 year ago
imagine too, some time get url but some time show this issue =
2023-04-30 06:43:07 Info: follow message completion ready /Users/macpro/Downloads/FullStack-MERN-AI-Image-main/server/demo.ts:8 console.log("you can your result here: ", msg.attachments[0].url); ^
TypeError: Cannot read properties of undefined (reading 'url')
That can happen if your computer clock is off by more than 5 seconds to discord times. I need to find a way to sync times.
To prove that this is the issue, update your local copy of the module and replace all instances like:
new SnowflakeObj(-5 * 1000).encode()
by
new SnowflakeObj(-180 * 1000).encode()
The message confirmation will be checked 3 min back instead of 5 sec or double-check your time sync.
The next version will get improved error messages.
forgot, add upscale by message id please, some after generate we have several images not scale, so add upscale by message id/image id
For now check _sample.ts
it contains some upscale and variance working code sample.
I tested the doc gen sample:
import Midjourney, { DiscordMessageHelper } from "./mod.ts";
const client = new Midjourney("interaction.txt");
const msg: DiscordMessageHelper = await client.imagine(
"A photo of an astronaut riding a horse",
);
console.log("you can find your result here: ", msg.attachments[0].url);
2023-04-30 07:48:18 Info: First request in waitMessage gets 0 messages
2023-04-30 07:48:19 Info: waitMessage for prompt message found 1234567890123456789 **A photo of an astronaut riding a horse --v 5** - <@1097071082203303187> (Waiting to start)
2023-04-30 07:48:19 Info: wait for the prompt in Queue
2023-04-30 07:48:30 Info: follow message completion: (0%)
2023-04-30 07:48:38 Info: follow message completion: (15%)
2023-04-30 07:48:44 Info: follow message completion: (31%)
2023-04-30 07:48:50 Info: follow message completion: (46%)
2023-04-30 07:48:58 Info: follow message completion: (62%)
2023-04-30 07:49:04 Info: follow message completion: (78%)
2023-04-30 07:49:12 Info: follow message completion: (93%)
2023-04-30 07:49:19 Info: follow message completion ready
you can find the result here: https://cdn.discordapp.com/attachments/1097071082203303187/1234567890123456789/XXXXXX_None_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.png
My Upscale interface is currently terrible, sorry about that, reverse the value of the boolean you pass. 0 is probably the number of images already upscaled ...
or provide the code your type, so I will update the doc, or refactor all this.
just get message id and hash (b9a02257-abe3-4361-b73a-4c8ded3d29d2) from "custom_id": "MJ::JOB::upsample::1::b9a02257-abe3-4361-b73a-4c8ded3d29d2". after get generate image, then after that use that message id to check in all message in channel like this : $id = $data[0]["message_reference"]["message_id"]; //echo $id;
if($idget == $id){
$urlimg = $data[0]["attachments"][0]["url"];
message id if same with message_reference"]["message_id"] then we can get url image upscale. based on per image by message id
so you do not use my built-in function there is the sample code:
{
const upscale = msg.getComponents(false, "U"); // Extract all non done Upscale
logger.info(`${upscale.length} Upscale can be generated`);
if (upscale.length > 0) { // is at least one Upscale can be generate process it.
logger.info(`Generating upscale ${upscale[0].label}`);
const msg2 = await client.callCustomComponents(upscale[0]);
logger.info(`upscale Ready from`, msg2.attachments[0].url);
} else {
logger.warn(
`No move upscale available in result label:`,
msg.components.map((a) => a.label).join(", "),
);
}
}
you should use the function callCustomComponents
so you do not use my built-in function there is the sample code:
{ const upscale = msg.getComponents(false, "U"); // Extract all non done Upscale logger.info(`${upscale.length} Upscale can be generated`); if (upscale.length > 0) { // is at least one Upscale can be generate process it. logger.info(`Generating upscale ${upscale[0].label}`); const msg2 = await client.callCustomComponents(upscale[0]); logger.info(`upscale Ready from`, msg2.attachments[0].url); } else { logger.warn( `No move upscale available in result label:`, msg.components.map((a) => a.label).join(", "), ); } }
you should use the function
callCustomComponents
try this reference =
https://github.com/erictik/midjourney-api/blob/main/src/midjourney.message.ts#L58
what i am talk last, from there. after generate its will get some response = message id, hash, and url image before upscale. then if want upscale will use that
In my version, works from the Custom Components provided by midjourney bot, I do not parse those values.
I do not understand what is your issue.
this issue i get now :
file:///Users/macpro/Downloads/FullStack-MERN-AI-Image-main/server/node_modules/midjourney-discord-api/esm/src/Midjourney.js:268
throw new Error(failed to extract prompt from ${msg.content}
);
^
Error: failed to extract prompt from painting of a girl wearing a dress walking to the beach, in the style of andreas rocha, light bronze and --seed 6894 - Upscaled by <@1099895049405353985> (fast) at follow (file:///Users/macpro/Downloads/FullStack-MERN-AI-Image-main/server/node_modules/mid
thx I can add a new Unit Test:
Deno.test(function ParseMidJourneyUpscaled() {
const p1 = extractPrompt(
"**a view of Paris drawn by Kanagawa --v 5 --seed 6894** - Upscaled by <@1097074882203303911> (fast)",
);
assertExists(p1);
assertEquals(p1.prompt, "a view of Paris drawn by Kanagawa --v 5 --seed 6894");
assertEquals(p1.id, "1097074882203303911");
assertEquals(p1.completion, 1);
assertEquals(p1.type, "variations");
});
will be fix soon.
Can you confirm me that this message means that the image is ready?
ok
Can you confirm for me that this message means that the image is ready? and that is the result of un upscale ?
or this is a variation of an upscale.
V0.1.0 is out.
main changes:
import Midjourney from "midjourney-discord-api";
const client = new Midjourney("interaction.txt");
const msg = await client.imagine(
"A photo of an astronaut riding a horse",
);
if (msg.canUpscale()) {
const result = msg.upscale(2);
console.log(`upscale U2 Ready from`, result.attachments[0].url);
}
import Midjourney from "midjourney-discord-api";
const client = new Midjourney("interaction.txt");
const msg = await client.imagine(
"A photo of an astronaut riding a horse",
);
if (msg.canVariant()) {
const result = msg.variant(2);
console.log(`upscale V2 Ready from`, result.attachments[0].url);
}
import Midjourney from "midjourney-discord-api";
const client = new Midjourney("interaction.txt");
const msg = await client.imagine(
"A photo of an astronaut riding a horse",
);
if (msg.canReroll()) {
const result = msg.reroll();
console.log(`upscale V2 Ready from`, result.attachments[0].url);
}
ok, but its i can use latest if download now with npm i ?
stuck, not count message and cant uspcale
Upscaling is working, but when I tried it earlier, the upscaling was still done for the previous generated result, not the current one
fixed....
creating more samples in process.
new code sample:
import { Midjourney } from "../mod.ts";
/**
* Upscale the first none upscaled images in chat, searching from the newest to the oldest images
*/
const client = new Midjourney("interaction.txt");
const msgs = await client.getMessages();
main:
for (const msg of msgs) {
if (!msg.canUpscale()) {
continue;
}
for (let i = 1; i <= 4; i++) {
if (msg.canUpscale(i)) {
console.log(`Upscaling image ${i} from ${msg.id}: ${msg.prompt?.prompt}`);
const result = await msg.upscale(i);
await result.download(0, "images");
break main;
}
}
}
V0.1.1 is out.
I saw 1 star on the project so I can close the issue. Open a new one whenever you want/need to.
.js:508 throw Error("Wait for describe response failed"); ^
Error: Wait for describe response failed