Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] multiple connections #277

Open
GabrieleRisso opened this issue Jul 3, 2024 · 0 comments
Open

[suggestion] multiple connections #277

GabrieleRisso opened this issue Jul 3, 2024 · 0 comments

Comments

@GabrieleRisso
Copy link

Hello, thanks for the exellent api. I am using every feature of the api (version 5.2) and face swap consistently without issues. In my codebase I am running multiple istances of the same program using cluster workers and I have the feeling some of those istances are having toruble to conenct, resulting in a failure.
I was wandering if you could suggest a better way of implementing the connection setup or config parameters to tune it in order to have 16 parallel connections.
here is my current implementation:

import { ImIDnfigParam, Midjourney } from "midjourney";

const ImIDnfig: ImIDnfigParam = {
SalaiToken: process.env.SALAI_TOKEN,
ChannelId: process.env.CHANNEL_ID,
ServerId: process.env.SERVER_ID,
HuggingFaceToken: "hf_XXXXXXXXXXXXXXXXXXXXXX",
//Debug: true,
Ws: true,
//Limit: 200
};

const midclient = new Midjourney(ImIDnfig);

await midclient
.init()
.then(() => {
console.log("[OK] MidClient initialized successfully.");
})
.catch((error) => {
console.error("[XX] Failed to initialize MidClient:", error);
});

const msg = await midclient
.Imagine(${prompt} --quality ${quality}, (uri: string, progress: string) => {
console.log("Imagine.loading", uri, "progress", progress);
})
.catch((error) => {
console.error("Error in midclient.Imagine:", error);
throw error; // Rethrow the error to propagate it further
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant