Skip to content

Commit

Permalink
add reroll & add flags & fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed Jun 18, 2023
1 parent 8a37f13 commit dcf81c6
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 284 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Node.js Package
env:
APPVERSION: v2.7.${{ github.run_number }}
APPVERSION: v3.0.${{ github.run_number }}
on:
workflow_dispatch:
push:
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ import { Midjourney } from "midjourney";
Debug: true,
Ws:true,
});
await client.init();
await client.Connect();
const Imagine = await client.Imagine("A little pink elephant", (uri: string, progress:string) => {
onsole.log("Imagine", uri, "progress", progress);
});
console.log({ Imagine });

const Variation = await client.Variation(
Imagine.content,
2,
<string>Imagine.id,
<string>Imagine.hash,
(uri: string, progress:string) => {
onsole.log("Imagine", uri, "progress", progress);
}
);
const Variation = await client.Variation({
index: 2,
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("Variation.loading", uri, "progress", progress);
},
});
console.log({ Variation });
const Upscale = await client.Upscale(
Variation.content,
2,
<string>Variation.id,
<string>Variation.hash,
(uri: string, progress: string) => {
console.log("Upscale", uri, "progress", progress);
}
);
const Upscale = await client.Upscale({
index: 2,
msgId: <string>Variation.id,
hash: <string>Variation.hash,
flags: Variation.flags,
loading: (uri: string, progress: string) => {
console.log("Upscale.loading", uri, "progress", progress);
},
});
console.log({ Upscale });

```
Expand Down Expand Up @@ -101,7 +101,7 @@ npx tsx example/imagine-ws.ts
```

## route-map
- [x] `/imagine` `variation` `upscale`
- [x] `/imagine` `variation` `upscale` `reroll`
- [x] websocket get message
- [x] callback error
- [x] verify human
Expand Down
2 changes: 1 addition & 1 deletion example/describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
const msg = await client.Describe(
"https://img.ohdat.io/midjourney-image/1b74cab8-70c9-474e-bfbb-093e9a3cfd5c/0_1.png"
);
Expand Down
2 changes: 1 addition & 1 deletion example/fast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
await client.Fast();
const msg = await client.Info();
console.log({ msg });
Expand Down
2 changes: 1 addition & 1 deletion example/imagine-dm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
const msg = await client.Imagine(
"A little white dog",
(uri: string, progress: string) => {
Expand Down
2 changes: 1 addition & 1 deletion example/imagine-err.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
Ws: true,
});

await client.init();
await client.Connect();
const msg = await client.Imagine(
"https://edge-runtime.vercel.app/features/available-apis",
(uri: string, progress: string) => {
Expand Down
17 changes: 9 additions & 8 deletions example/imagine-uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ async function main() {
console.log("no message");
return;
}
const msg2 = await client.Upscale(
msg.content,
2,
msg.id,
msg.hash,
(uri: string, progress: string) => {
const msg2 = await client.Upscale({
index: 2,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
content: msg.content,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
},
});
console.log({ msg2 });
}
main().catch((err) => {
Expand Down
3 changes: 1 addition & 2 deletions example/imagine-ws-m.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ async function main() {
SalaiToken: <string>process.env.SALAI_TOKEN,
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN,
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
client
.Imagine("A little pink elephant", (uri) => {
console.log("loading123---", uri);
Expand Down
38 changes: 0 additions & 38 deletions example/imagine-ws-proxy.ts

This file was deleted.

45 changes: 28 additions & 17 deletions example/imagine-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
const Imagine = await client.Imagine(
"Red hamster smoking a cigaret, https://media.discordapp.net/attachments/1108515696385720410/1118385339732590682/DanielH_A_giant_hamster_monster._Friendly_in_a_business_suit_si_d4be1836-a4e1-41a8-b1d7-99eebc521220.png?width=1878&height=1878 ",
(uri: string, progress: string) => {
Expand All @@ -27,30 +27,41 @@ async function main() {
if (!Imagine) {
return;
}
const Variation = await client.Variation(
Imagine.content,
2,
<string>Imagine.id,
<string>Imagine.hash,
(uri: string, progress: string) => {
const reroll = await client.Reroll({
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("Reroll.loading", uri, "progress", progress);
},
});
console.log({ reroll });

const Variation = await client.Variation({
index: 2,
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("Variation.loading", uri, "progress", progress);
}
);
},
});

console.log({ Variation });
if (!Variation) {
return;
}
const Upscale = await client.Upscale(
Variation.content,
2,
<string>Variation.id,
<string>Variation.hash,
(uri: string, progress: string) => {
const Upscale = await client.Upscale({
index: 2,
msgId: <string>Variation.id,
hash: <string>Variation.hash,
flags: Variation.flags,
loading: (uri: string, progress: string) => {
console.log("Upscale.loading", uri, "progress", progress);
}
);
},
});
console.log({ Upscale });

client.Close();
}
main()
Expand Down
2 changes: 1 addition & 1 deletion example/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
const msg = await client.Info();
console.log({ msg });
client.Close();
Expand Down
2 changes: 1 addition & 1 deletion example/relax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
await client.Relax();
const msg = await client.Info();
console.log({ msg });
Expand Down
19 changes: 10 additions & 9 deletions example/upscale-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
await client.Connect();
const msg = await client.Imagine("a cool cat, blue ears, yellow hat");
console.log({ msg });
if (!msg) {
console.log("no message");
return;
}
const msg2 = await client.Upscale(
msg.content,
2,
<string>msg.id,
<string>msg.hash,
(uri: string, progress: string) => {
const msg2 = await client.Upscale({
index: 2,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
},
});
console.log({ msg2 });
client.Close();
}
main().catch((err) => {
console.error(err);
Expand Down
17 changes: 9 additions & 8 deletions example/upscale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ async function main() {
console.log("no message");
return;
}
const msg2 = await client.Upscale(
msg.content,
2,
<string>msg.id,
<string>msg.hash,
(uri: string, progress: string) => {
const msg2 = await client.Upscale({
index: 2,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
content: msg.content,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
},
});
console.log({ msg2 });
}
main().catch((err) => {
Expand Down
47 changes: 25 additions & 22 deletions example/variation-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,39 @@ async function main() {
Debug: true,
Ws: true,
});
await client.init();
const msg = await client.Imagine("a dog, blue ears, and a red nose");
console.log({ msg });
if (!msg) {
await client.Connect();
const Imagine = await client.Imagine(
"the queen of the underworld, race: vampire, appearance: delicate features with detailed portrayal, super exquisite facial features, silver long hair reaching ankles, silver pupils, fair skin with a hint of melancholy in the eyes, beautiful and noble, clothing: wearing a blood-red rose on the hair, skirt with layers of lace, sitting in a (pose), captured in ultra-high resolution, film-like realism, 8k for the best visual quality, super clear and finely drawn. --ar 9:16 --v 5"
);
console.log({ Imagine });
if (!Imagine) {
console.log("no message");
return;
}

client
.Variation(
msg.content,
2,
<string>msg.id,
<string>msg.hash,
(uri: string) => {
console.log("loading2", uri);
}
)
.Variation({
index: 2,
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("Variation2.loading", uri, "progress", progress);
},
})
.then((msg2) => {
console.log({ msg2 });
});
client
.Variation(
msg.content,
3,
<string>msg.id,
<string>msg.hash,
(uri: string) => {
console.log("loading3", uri);
}
)
.Variation({
index: 3,
msgId: <string>Imagine.id,
hash: <string>Imagine.hash,
flags: Imagine.flags,
loading: (uri: string, progress: string) => {
console.log("Variation3.loading", uri, "progress", progress);
},
})
.then((msg3) => {
console.log({ msg3 });
});
Expand Down
Loading

0 comments on commit dcf81c6

Please sign in to comment.