"use strict"; const { Axios } = require("../Utils"); const { PrivateWorkerApiItsrose } = require("../Constant");

class Diffusion { #queue = 0; example = "beatiful girl, looking to viewer, warm smile,"; advanceExample = "SamDoesArt, a girl, brown hair, blue eyes, black hoodie, piercing, tattoos, day, sunny, cars, city, HDRI, masterpiece, sharp focus, smooth, illustration, golden ratio,";

add() {
    this.#queue++;
}

remove() {
    this.#queue--;
}

async stable(prompt, seed = false) {
    if (this.#queue >= 5) {
        return {
            error: true,
            message: "Please wait, you are in position " + (this.#queue + 1),
        };
    }

    try {
        this.add();

        if (!seed) {
            seed = Math.random().toString().substring(2, 11);
        }

        const { data } = await Axios.request({
            baseURL: PrivateWorkerApiItsrose,
            url: "/api/stableDiffusion",
            method: "POST",
            data: new URLSearchParams({ prompt, seed: String(seed) }),
        }).catch((e) => e?.response);

        this.remove();
        return data;
    } catch (e) {
        return {
            error: true,
            message: String(e),
        };
    }
}

}

module.exports.diffusion = new Diffusion()

ubah kode berikut menjadi javascript type cjsuse strict;var __classPrivateFieldSet = this && this__classPrivateFieldSet function receiver state value kind f if kind === m throw new TypeErrorPriva

原文地址: http://www.cveoy.top/t/topic/g1y2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录