-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eric
committed
Jun 25, 2023
1 parent
987e2db
commit f43eb7b
Showing
4 changed files
with
194 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import "dotenv/config"; | ||
import { Midjourney } from "../src"; | ||
/** | ||
* | ||
* a simple example of how to use the options with ws command | ||
* ``` | ||
* npx tsx example/options.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, | ||
}); | ||
await client.Connect(); | ||
const Imagine = await client.Imagine("a cool cat, blue ears, yellow hat"); | ||
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); | ||
}, | ||
}); | ||
const zoomout = Upscale?.options?.find((o) => o.label === "Zoom Out 2x"); | ||
if (!zoomout) { | ||
console.log("no zoomout"); | ||
return; | ||
} | ||
const zoomout2x = client.Custom({ | ||
msgId: <string>Imagine.id, | ||
flags: Imagine.flags, | ||
customId: zoomout.custom, | ||
loading: (uri: string, progress: string) => { | ||
console.log("loading", uri, "progress", progress); | ||
}, | ||
}); | ||
console.log("zoomout2x", zoomout2x); | ||
|
||
client.Close(); | ||
} | ||
main().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import "dotenv/config"; | ||
import { Midjourney } from "../src"; | ||
/** | ||
* | ||
* a simple example of how to use the zoomout with ws command | ||
* ``` | ||
* npx tsx example/zoomout.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, | ||
}); | ||
await client.Connect(); | ||
const Imagine = await client.Imagine("a cool cat, blue ears, yellow hat"); | ||
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); | ||
}, | ||
}); | ||
console.log(Upscale); | ||
const Zoomout = await client.ZoomOut({ | ||
level: "2x", | ||
msgId: <string>Imagine.id, | ||
hash: <string>Imagine.hash, | ||
flags: Imagine.flags, | ||
loading: (uri: string, progress: string) => { | ||
console.log("loading", uri, "progress", progress); | ||
}, | ||
}); | ||
console.log(Zoomout); | ||
|
||
client.Close(); | ||
} | ||
main().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters