Skip to content

Commit

Permalink
imagine use ws
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed May 30, 2023
1 parent 09ee3b3 commit 99054ff
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@vercel/analytics": "^1.0.1",
"axios": "^1.3.6",
"eventsource-parser": "^1.0.0",
"midjourney": "^2.2.33",
"midjourney": "^2.3.42",
"next": "^13.1.1"
},
"keywords": [
Expand Down
17 changes: 9 additions & 8 deletions pages/api/imagine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ export const config = {
runtime: "edge",
};

const client = new Midjourney({
ServerId: <string>process.env.SERVER_ID,
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
Debug: true,
MaxWait: 600,
});

const handler = async (req: Request) => {
const { prompt } = await req.json();
console.log("imagine.handler", prompt);
const client = new Midjourney({
ServerId: <string>process.env.SERVER_ID,
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
Debug: true,
MaxWait: 600,
Ws: true,
});
await client.init();
const encoder = new TextEncoder();
const readable = new ReadableStream({
start(controller) {
Expand Down
26 changes: 22 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@
resolved "https://registry.npmjs.org/@eslint/js/-/js-8.39.0.tgz"
integrity sha512-kf9RB0Fg7NZfap83B3QOqOGg9QmD9yBudqQXzzOtn3i4y7ZUXe5ONeW34Gwi+TxhH4mvj72R1Zc300KUMa9Bng==

"@huggingface/inference@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@huggingface/inference/-/inference-2.5.0.tgz#8e14ee6696e91aecb132c90d3b07be8373e70338"
integrity sha512-X3NSdrWAKNTLAsEKabH48Wc+Osys+S7ilRcH1bf9trSDmJlzPVXDseXMRBHCFPCYd5AAAIakhENO4zCqstVg8g==

"@humanwhocodes/config-array@^0.11.8":
version "0.11.8"
resolved "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz"
Expand Down Expand Up @@ -2046,6 +2051,11 @@ isexe@^2.0.0:
resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==

isomorphic-ws@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf"
integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==

jiti@^1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.18.2.tgz#80c3ef3d486ebf2450d9335122b32d121f2a83cd"
Expand Down Expand Up @@ -2184,12 +2194,15 @@ micromatch@^4.0.4, micromatch@^4.0.5:
braces "^3.0.2"
picomatch "^2.3.1"

midjourney@^2.2.33:
version "2.2.33"
resolved "https://registry.yarnpkg.com/midjourney/-/midjourney-2.2.33.tgz#8da761b03fdc738816a87d817070d152e6da5bfa"
integrity sha512-6bbO/vVqYnnSHSUx7AswqH5wXRHVPlu/RS8Lt8eJ4qySdarP9jSvhcx6fK7wrSw44UOTEAX2AICehheTzi2Q/A==
midjourney@^2.3.42:
version "2.3.42"
resolved "https://registry.yarnpkg.com/midjourney/-/midjourney-2.3.42.tgz#e414a9707efcc4214674afc77b6bf57396e3c717"
integrity sha512-RUuhVQ8aipAPhIlKUzU2Px4eCcZVYcGUAJ363bABX+m3ozUCZB8vZAUbdZGcKhQBYPvc4Ym8T24VLny8mmWEgg==
dependencies:
"@huggingface/inference" "^2.5.0"
isomorphic-ws "^5.0.0"
p-queue "^6.6.2"
snowyflake "^2.0.0"
throat "^6.0.2"
tslib "^2.5.0"
ws "^8.13.0"
Expand Down Expand Up @@ -3143,6 +3156,11 @@ slash@^4.0.0:
resolved "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz"
integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==

snowyflake@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/snowyflake/-/snowyflake-2.0.0.tgz#9514fb3540b290b71fec8efb6a737d32c4dc8105"
integrity sha512-BxeqV0KJxJASu6EBJGUkX194Zhh37AEa0ow/JRK39icWbLTG9Wl/7LAL6a/ZMSjNm4O9pZk6QoLcWP7f/YKmtA==

source-map-js@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz"
Expand Down

0 comments on commit 99054ff

Please sign in to comment.