Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zcpua committed Jul 19, 2023
1 parent fab0746 commit 2c997d9
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 47 deletions.
74 changes: 56 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,37 +124,75 @@ To run the included example, you must have [Node.js](https://nodejs.org/en/) ins
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
Debug: true,
Ws: true,
Ws: true, //enable ws is required for remix mode (and custom zoom)
});
await client.Connect();
await client.init();
const prompt =
"Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration";
//imagine
const Imagine = await client.Imagine(
"A little pink elephant",
prompt,
(uri: string, progress: string) => {
console.log("Imagine", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
}
);
console.log({ Imagine });

const Variation = await client.Variation({
index: 2,
console.log(Imagine);
if (!Imagine) {
console.log("no message");
return;
}
//U1 U2 U3 U4 V1 V2 V3 V4 "Vary (Strong)" ...
const V1CustomID = Imagine.options?.find((o) => o.label === "V1")?.custom;
if (!V1CustomID) {
console.log("no V1");
return;
}
// Varition V1
const Varition = await client.Custom({
msgId: <string>Imagine.id,
flags: Imagine.flags,
customId: V1CustomID,
content: prompt, //remix mode require content
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
console.log(Varition);
const U1CustomID = Imagine.options?.find((o) => o.label === "U1")?.custom;
if (!U1CustomID) {
console.log("no U1");
return;
}
// Upscale U1
const Upscale = await client.Custom({
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
customId: U1CustomID,
loading: (uri: string, progress: string) => {
console.log("Variation.loading", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
},
});
console.log({ Variation });
const Upscale = await client.Upscale({
index: 2,
msgId: <string>Variation.id,
hash: <string>Variation.hash,
flags: Variation.flags,
if (!Upscale) {
console.log("no Upscale");
return;
}
console.log(Upscale);
const zoomout = Upscale?.options?.find((o) => o.label === "Custom Zoom");
if (!zoomout) {
console.log("no zoomout");
return;
}
// Custom Zoom
const CustomZoomout = await client.Custom({
msgId: <string>Upscale.id,
flags: Upscale.flags,
content: `${prompt} --zoom 2`, // Custom Zoom require content
customId: zoomout.custom,
loading: (uri: string, progress: string) => {
console.log("Upscale.loading", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
},
});
console.log({ Upscale });
console.log(CustomZoomout);
```

## route-map
Expand Down
74 changes: 56 additions & 18 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,37 +125,75 @@
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
Debug: true,
Ws: true,
Ws: true, //enable ws is required for remix mode (and custom zoom)
});
await client.Connect();
await client.init();
const prompt =
"Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration";
//imagine
const Imagine = await client.Imagine(
"A little pink elephant",
prompt,
(uri: string, progress: string) => {
console.log("Imagine", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
}
);
console.log({ Imagine });

const Variation = await client.Variation({
index: 2,
console.log(Imagine);
if (!Imagine) {
console.log("no message");
return;
}
// U1 U2 U3 U4 V1 V2 V3 V4 "Vary (Strong)" ...
const V1CustomID = Imagine.options?.find((o) => o.label === "V1")?.custom;
if (!V1CustomID) {
console.log("no V1");
return;
}
// Varition V1
const Varition = await client.Custom({
msgId: <string>Imagine.id,
flags: Imagine.flags,
customId: V1CustomID,
content: prompt, //remix mode require content
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
console.log(Varition);
const U1CustomID = Imagine.options?.find((o) => o.label === "U1")?.custom;
if (!U1CustomID) {
console.log("no U1");
return;
}
// Upscale U1
const Upscale = await client.Custom({
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
customId: U1CustomID,
loading: (uri: string, progress: string) => {
console.log("Variation.loading", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
},
});
console.log({ Variation });
const Upscale = await client.Upscale({
index: 2,
msgId: <string>Variation.id,
hash: <string>Variation.hash,
flags: Variation.flags,
if (!Upscale) {
console.log("no Upscale");
return;
}
console.log(Upscale);
const zoomout = Upscale?.options?.find((o) => o.label === "Custom Zoom");
if (!zoomout) {
console.log("no zoomout");
return;
}
// Custom Zoom
const CustomZoomout = await client.Custom({
msgId: <string>Upscale.id,
flags: Upscale.flags,
content: `${prompt} --zoom 2`, // Custom Zoom require content
customId: zoomout.custom,
loading: (uri: string, progress: string) => {
console.log("Upscale.loading", uri, "progress", progress);
console.log("loading", uri, "progress", progress);
},
});
console.log({ Upscale });
console.log(CustomZoomout);
```

## route-map
Expand Down
38 changes: 29 additions & 9 deletions example/customzoom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "dotenv/config";
import { Midjourney } from "../src";
import { sleep } from "../src/utls";
/**
*
* a simple example of how to use the (custom zoom) options with ws command
Expand All @@ -19,6 +18,7 @@ async function main() {
await client.init();
const prompt =
"Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration";
//imagine
const Imagine = await client.Imagine(
prompt,
(uri: string, progress: string) => {
Expand All @@ -30,28 +30,48 @@ async function main() {
console.log("no message");
return;
}
const Upscale = await client.Upscale({
index: 2,
//U1 U2 U3 U4 V1 V2 V3 V4 "Vary (Strong)" ...
const V1CustomID = Imagine.options?.find((o) => o.label === "V1")?.custom;
if (!V1CustomID) {
console.log("no V1");
return;
}
// Varition V1
const Varition = await client.Custom({
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
customId: V1CustomID,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
console.log(Varition);
const U1CustomID = Imagine.options?.find((o) => o.label === "U1")?.custom;
if (!U1CustomID) {
console.log("no U1");
return;
}
// Upscale U1
const Upscale = await client.Custom({
msgId: <string>Imagine.id,
flags: Imagine.flags,
customId: U1CustomID,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
if (!Upscale) {
console.log("no message");
console.log("no Upscale");
return;
}
console.log(Upscale);

const zoomout = Upscale?.options?.find((o) => o.label === "Custom Zoom");
if (!zoomout) {
console.log("no zoomout");
return;
}
await sleep(1400);
const zoomout2x = await client.Custom({
// Custom Zoom
const CustomZoomout = await client.Custom({
msgId: <string>Upscale.id,
flags: Upscale.flags,
content: `${prompt} --zoom 2`,
Expand All @@ -60,7 +80,7 @@ async function main() {
console.log("loading", uri, "progress", progress);
},
});
console.log("Custom Zoom", zoomout2x);
console.log("Custom Zoom", CustomZoomout);
client.Close();
}
main()
Expand Down
2 changes: 0 additions & 2 deletions example/vary.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "dotenv/config";
import { Midjourney } from "../src";
import { sleep } from "../src/utls";
/**
*
* a simple example of how to use the vary
Expand Down Expand Up @@ -50,7 +49,6 @@ async function main() {
console.log("no zoomout");
return;
}
await sleep(1400);
const varyCustom = await client.Custom({
msgId: <string>Upscale.id,
flags: Upscale.flags,
Expand Down

0 comments on commit 2c997d9

Please sign in to comment.