midjourney-api
midjourney-api copied to clipboard
Please pass the seed as a parameter.
async Imagine(prompt: string, loading?: LoadingHandler,customSeed:number) {
prompt = prompt.trim();
if (!this.wsClient) {
const seed = CustomSeed ?? random(1000000000, 9999999999);
prompt = `[${seed}] ${prompt}`;
}
const nonce = nextNonce();
this.log(`Imagine`, prompt, "nonce", nonce);
const httpStatus = await this.MJApi.ImagineApi(prompt, nonce);
if (httpStatus !== 204) {
throw new Error(`ImagineApi failed with status ${httpStatus}`);
}
if (this.wsClient) {
return await this.wsClient.waitImageMessage(nonce, loading);
} else {
this.log(`await generate image`);
const msg = await this.WaitMessage(prompt, loading);
this.log(`image generated`, prompt, msg?.uri);
return msg;
}
}
// The following two functions also need to add a timestamp 🙏🙏
WaitUpscaledMessage(content: string,index: number,loading?: LoadingHandler,timestamp: number)
WaitOptionMessage(content: string,options: string,loading?: LoadingHandler,timestamp: number)
WaitUpscaledMessage & WaitOptionMessage deprecated
recommend using Ws:true,huggingface:"token",
Ws:false may be baned.
I also want to use ws, but I can't use it, because my SCF persistent connection will have problems, so I can only split it to poll WaitMessage through the client
I’ll fork a copy and make some adjustments.