forked from erictik/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvary.ts
71 lines (70 loc) · 1.77 KB
/
vary.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import "dotenv/config";
import { Midjourney } from "../src";
/**
*
* a simple example of how to use the vary
* ```
* npx tsx example/vary.ts
* ```
*/
async function main() {
const client = new Midjourney({
ServerId: <string>process.env.SERVER_ID,
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
Debug: true,
Ws: true, //enable ws is required for custom zoom
});
await client.init();
const prompt =
"Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration";
const Imagine = await client.Imagine(
prompt,
(uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
console.log(Imagine);
if (!Imagine) {
console.log("no message");
return;
}
const Upscale = await client.Upscale({
index: 2,
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
if (!Upscale) {
console.log("no message");
return;
}
console.log(Upscale);
const vary = Upscale?.options?.find((o) => o.label === "Vary (Strong)");
if (!vary) {
console.log("no zoomout");
return;
}
const varyCustom = await client.Custom({
msgId: <string>Upscale.id,
flags: Upscale.flags,
content: `${prompt} --zoom 2`,
customId: vary.custom,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
console.log("vary (Strong)", varyCustom);
client.Close();
}
main()
.then(() => {
console.log("done");
})
.catch((err) => {
console.error(err);
process.exit(1);
});