Skip to content

Commit 505167e

Browse files
committed
improving workflows
1 parent 5c344b3 commit 505167e

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed

src/app/api/resolve/providers/comfy-comfyicu/index.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,33 @@ export async function resolveSegment(
1616
}
1717

1818
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() || ''
2121

2222
if (!workflowId) {
2323
throw new Error(`The ComfyICU workflow ID is missing`)
2424
}
2525

26-
const inputFields = request.settings.imageGenerationWorkflow.inputFields || []
26+
const inputFields =
27+
request.settings.imageGenerationWorkflow.inputFields || []
2728

2829
// since this is a random "wild" workflow, it is possible
2930
// that the field name is a bit different
3031
// we try to look into the workflow input fields
3132
// to find the best match
3233
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')
3738

3839
const promptField = promptFields[0]
3940
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+
)
4144
}
42-
45+
4346
// TODO: modify the serialized workflow payload
4447
// to inject our params:
4548
// ...getWorkflowInputValues(request.settings.imageGenerationWorkflow),
@@ -51,20 +54,22 @@ export async function resolveSegment(
5154
files: {},
5255
}
5356

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+
)
6469

6570
const response = await rawResponse.json()
6671

67-
if (response.status === "error") {
72+
if (response.status === 'error') {
6873
throw new Error(response.message)
6974
}
7075

src/app/api/resolve/providers/comfy-comfyicu/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ export type ComfyIcuWorkflowOutput = {
2121
url: string
2222
thumbnail_url: string
2323
}
24-

src/app/api/resolve/providers/falai/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ export async function resolveSegment(
5050
}
5151
}
5252

53-
const {
54-
workflowDefaultValues,
55-
workflowValues
56-
} = getWorkflowInputValues(request.settings.imageGenerationWorkflow)
57-
53+
const { workflowDefaultValues, workflowValues } = getWorkflowInputValues(
54+
request.settings.imageGenerationWorkflow
55+
)
56+
5857
// for the moment let's use FAL's predefined sizes
5958
const imageSize =
6059
request.meta.orientation === ClapMediaOrientation.SQUARE
@@ -184,7 +183,6 @@ export async function resolveSegment(
184183
} else if (request.segment.category === ClapSegmentCategory.DIALOGUE) {
185184
model = request.settings.voiceGenerationWorkflow.data || ''
186185

187-
188186
let voiceIdentity =
189187
request.prompts.voice.identity ||
190188
// TODO for the default we should use one of our own voices instea
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import { ClapInputValues, ClapWorkflow } from "@aitube/clap"
1+
import { ClapInputValues, ClapWorkflow } from '@aitube/clap'
22

33
export function getWorkflowInputValues(workflow: ClapWorkflow): {
44
workflowDefaultValues: ClapInputValues
55
workflowValues: ClapInputValues
66
} {
7-
const workflowDefaultValues =
8-
workflow.inputFields.reduce(
7+
const workflowDefaultValues = workflow.inputFields.reduce(
98
(acc, field) => ({
109
...acc,
1110
[field.id]: field.defaultValue,
1211
}),
1312
{} as ClapInputValues
1413
)
1514

16-
const workflowValues = workflow
17-
.inputValues as ClapInputValues
15+
const workflowValues = workflow.inputValues as ClapInputValues
1816

1917
return {
2018
workflowDefaultValues,
21-
workflowValues
19+
workflowValues,
2220
}
23-
}
21+
}

src/services/editors/workflow-editor/workflows/comfyicu/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from '../common/defaultValues'
1212

1313
export const comfyicuWorkflows: ClapWorkflow[] = [
14-
1514
/*
1615
1716
Unfortunately Comfy.icu doesn't support:

0 commit comments

Comments
 (0)