@@ -16,30 +16,33 @@ export async function resolveSegment(
16
16
}
17
17
18
18
if ( request . segment . category === ClapSegmentCategory . STORYBOARD ) {
19
-
20
- const workflowId = request . settings . imageGenerationWorkflow . id . split ( '://' ) . pop ( ) || ''
19
+ const workflowId =
20
+ request . settings . imageGenerationWorkflow . id . split ( '://' ) . pop ( ) || ''
21
21
22
22
if ( ! workflowId ) {
23
23
throw new Error ( `The ComfyICU workflow ID is missing` )
24
24
}
25
25
26
- const inputFields = request . settings . imageGenerationWorkflow . inputFields || [ ]
26
+ const inputFields =
27
+ request . settings . imageGenerationWorkflow . inputFields || [ ]
27
28
28
29
// since this is a random "wild" workflow, it is possible
29
30
// that the field name is a bit different
30
31
// we try to look into the workflow input fields
31
32
// to find the best match
32
33
const promptFields = [
33
- inputFields . find ( f => f . id === 'prompt' ) , // exactMatch,
34
- inputFields . find ( f => f . id . includes ( 'prompt' ) ) , // similarName,
35
- inputFields . find ( f => f . type === 'string' ) // similarType
36
- ] . filter ( x => typeof x !== 'undefined' )
34
+ inputFields . find ( ( f ) => f . id === 'prompt' ) , // exactMatch,
35
+ inputFields . find ( ( f ) => f . id . includes ( 'prompt' ) ) , // similarName,
36
+ inputFields . find ( ( f ) => f . type === 'string' ) , // similarType
37
+ ] . filter ( ( x ) => typeof x !== 'undefined' )
37
38
38
39
const promptField = promptFields [ 0 ]
39
40
if ( ! promptField ) {
40
- throw new Error ( `this workflow doesn't seem to have a parameter called "prompt"` )
41
+ throw new Error (
42
+ `this workflow doesn't seem to have a parameter called "prompt"`
43
+ )
41
44
}
42
-
45
+
43
46
// TODO: modify the serialized workflow payload
44
47
// to inject our params:
45
48
// ...getWorkflowInputValues(request.settings.imageGenerationWorkflow),
@@ -51,20 +54,22 @@ export async function resolveSegment(
51
54
files : { } ,
52
55
}
53
56
54
-
55
- const rawResponse = await fetch ( `https://comfy.icu/api/v1/workflows/${ workflowId } /runs` , {
56
- headers : {
57
- accept : "application/json" ,
58
- "content-type" : "application/json" ,
59
- authorization : `Bearer ${ request . settings . comfyIcuApiKey } ` ,
60
- } ,
61
- body : JSON . stringify ( payload ) ,
62
- method : "POST" ,
63
- } ) ;
57
+ const rawResponse = await fetch (
58
+ `https://comfy.icu/api/v1/workflows/${ workflowId } /runs` ,
59
+ {
60
+ headers : {
61
+ accept : 'application/json' ,
62
+ 'content-type' : 'application/json' ,
63
+ authorization : `Bearer ${ request . settings . comfyIcuApiKey } ` ,
64
+ } ,
65
+ body : JSON . stringify ( payload ) ,
66
+ method : 'POST' ,
67
+ }
68
+ )
64
69
65
70
const response = await rawResponse . json ( )
66
71
67
- if ( response . status === " error" ) {
72
+ if ( response . status === ' error' ) {
68
73
throw new Error ( response . message )
69
74
}
70
75
0 commit comments