jan/web-client/app/_services/controlnet.ts
hiento09 86f0ffc7d1
Chore/disable submodule (#56)
* Chore disable git submodule for web-client and app-backend

* Chore add newest source code of app-backend and web-client

---------

Co-authored-by: Hien To <tominhhien97@gmail.com>
2023-09-05 16:29:07 +07:00

43 lines
931 B
TypeScript

export const controlNetRequest = async (
token: string,
prompt: string,
negPrompt: string,
fileInput: any
): Promise<Record<string, unknown> | undefined> => {
const formData = new FormData();
const advancedPrompt: AdvancedPrompt = {
prompt: prompt,
neg_prompt: negPrompt ?? "",
control_net_model: "controlnet_canny",
seed: 1024,
steps: 20,
control_scale: 1.0,
};
formData.append("file", fileInput);
formData.append("data", JSON.stringify(advancedPrompt));
const res = await fetch("https://sd-inference.jan.ai/controlnet_inference", {
method: "POST",
body: formData,
});
if (!res.ok) {
console.error("fetchConversations error", res);
return;
}
const body = await res.json();
return body.url;
};
export type AdvancedPrompt = {
prompt: string;
neg_prompt: string;
control_net_model: string;
seed: number;
steps: number;
control_scale: number;
};