File size: 1,383 Bytes
38ceaf9
 
97369e8
38ceaf9
 
916c5da
38ceaf9
 
 
182af0c
38ceaf9
5d7708a
38ceaf9
 
 
 
 
 
182af0c
916c5da
 
 
 
 
 
 
 
182af0c
1db49be
 
 
 
 
 
 
 
 
182af0c
38ceaf9
916c5da
 
182af0c
916c5da
 
 
 
 
1db49be
182af0c
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use server"

import { ComfyDeployClient } from "comfydeploy"

const client = new ComfyDeployClient({
    apiBase: process.env.COMFY_API_URL,
    apiToken: process.env.COMFY_API_TOKEN!,
})

export async function generate(prompt: string) {
    return await client.run({
        deployment_id: process.env.COMFY_DEPLOYMENT_ID!,
        inputs: {
            "input_text": prompt
        }
    })
}

export async function generate_img(input_image: string) {
    return await client.run({
        deployment_id: process.env.COMFY_DEPLOYMENT_ID_IMG_2_IMG!,
        inputs: {
            "input_image": input_image
        }
    })
}

export async function generate_img_with_controlnet(input_openpose_url: string, prompt: string) {
    return await client.run({
        deployment_id: process.env.COMFY_DEPLOYMENT_ID_CONTROLNET!,
        inputs: {
            "positive_prompt": prompt,
            "openpose": input_openpose_url
        }
    })
}

export async function checkStatus(run_id: string) {
    return await client.getRun(run_id)
}

export async function getUploadUrl(type: string, file_size: number) {
    try {
        return await client.getUploadUrl(type, file_size)
    } catch (error) {
        console.log(error)
    }
}

export async function getWebsocketUrl() {
    return await client.getWebsocketUrl({
        deployment_id: process.env.COMFY_DEPLOYMENT_WS!,
    })
}