Skip to content

Commit

Permalink
.env add ws
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed Jun 15, 2023
1 parent 67a10c3 commit d03f56e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ SALAI_TOKEN="Token of the Account from which you paid MidJourney"
SERVER_ID="Server id here"
CHANNEL_ID="Channel in which commands are sent"
NEXT_PUBLIC_IMAGE_PREFIX="/"
HUGGINGFACE_TOKEN="huggingface token here https://huggingface.co/docs/hub/security-tokens"
HUGGINGFACE_TOKEN="huggingface token here https://huggingface.co/docs/hub/security-tokens"
WS=true
4 changes: 3 additions & 1 deletion pages/api/imagine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const handler = async (req: Request) => {
SalaiToken: <string>process.env.SALAI_TOKEN,
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN,
Debug: true,
Ws: true,
Ws: process.env.WS === "true",
});
await client.init();
const encoder = new TextEncoder();
Expand All @@ -30,10 +30,12 @@ const handler = async (req: Request) => {
.then((msg) => {
console.log("imagine.done", msg);
controller.enqueue(encoder.encode(JSON.stringify(msg)));
client.Close();
controller.close();
})
.catch((err: ResponseError) => {
console.log("imagine.error", err);
client.Close();
controller.close();
});
},
Expand Down
4 changes: 3 additions & 1 deletion pages/api/upscale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function handler(req: Request) {
SalaiToken: <string>process.env.SALAI_TOKEN,
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN,
Debug: true,
Ws: true,
Ws: process.env.WS === "true",
});
await client.init();
const encoder = new TextEncoder();
Expand All @@ -37,10 +37,12 @@ export default async function handler(req: Request) {
.then((msg) => {
console.log("upscale.done", msg);
controller.enqueue(encoder.encode(JSON.stringify(msg)));
client.Close();
controller.close();
})
.catch((err: ResponseError) => {
console.log("upscale.error", err);
client.Close();
controller.close();
});
},
Expand Down
4 changes: 3 additions & 1 deletion pages/api/variation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function handler(req: Request) {
SalaiToken: <string>process.env.SALAI_TOKEN,
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN,
Debug: true,
Ws: true,
Ws: process.env.WS === "true",
});
await client.init();
const encoder = new TextEncoder();
Expand All @@ -36,10 +36,12 @@ export default async function handler(req: Request) {
.then((msg) => {
console.log("variation.done", msg);
controller.enqueue(encoder.encode(JSON.stringify(msg)));
client.Close();
controller.close();
})
.catch((err: ResponseError) => {
console.log("variation.error", err);
client.Close();
controller.close();
});
},
Expand Down

1 comment on commit d03f56e

@vercel
Copy link

@vercel vercel bot commented on d03f56e Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.