Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Aug 12, 2024
1 parent b5369ea commit 02d66b3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
39 changes: 19 additions & 20 deletions src/app/api/resolve/providers/comfy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export async function resolveSegment(
).init()

if (request.segment.category === ClapSegmentCategory.STORYBOARD) {

const comfyApiWorkflow = JSON.parse(
request.settings.imageGenerationWorkflow.data
)
Expand Down Expand Up @@ -91,28 +90,28 @@ export async function resolveSegment(
// to make things easier, we are going to assume that the ClapWorkflow object
// is 100% correctly defined, and that we can rely on `inputFields` and `inputValues`
//
// that way, the responsibility of automatically identifying the inputs from a raw JSON workflow
// that way, the responsibility of automatically identifying the inputs from a raw JSON workflow
// (eg. coming from OpenArt.ai) will be done by a separate pre-processing code

const inputFields =
request.settings.imageGenerationWorkflow.inputFields || []

// since this is a random "wild" workflow, it is possible
// that the field name is a bit different
// we try to look into the workflow input fields
// to find the best match
const promptFields = [
inputFields.find((f) => f.id === 'prompt'), // exactMatch,
inputFields.find((f) => f.id.includes('prompt')), // similarName,
inputFields.find((f) => f.type === 'string'), // similarType
].filter((x) => typeof x !== 'undefined')

const promptField = promptFields[0]
if (!promptField) {
throw new Error(
`this workflow doesn't seem to have a parameter called "prompt"`
)
}
request.settings.imageGenerationWorkflow.inputFields || []

// since this is a random "wild" workflow, it is possible
// that the field name is a bit different
// we try to look into the workflow input fields
// to find the best match
const promptFields = [
inputFields.find((f) => f.id === 'prompt'), // exactMatch,
inputFields.find((f) => f.id.includes('prompt')), // similarName,
inputFields.find((f) => f.type === 'string'), // similarType
].filter((x) => typeof x !== 'undefined')

const promptField = promptFields[0]
if (!promptField) {
throw new Error(
`this workflow doesn't seem to have a parameter called "prompt"`
)
}

// TODO: modify the serialized workflow payload
// to inject our params:
Expand Down
24 changes: 18 additions & 6 deletions src/app/api/resolve/providers/falai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,30 @@ export async function resolveSegment(
request.settings.imageGenerationWorkflow
)

// for the moment let's use FAL's predefined sizes
// but I've notived that with Flux.1 release they started to add
// support for custom sizes as well
// previous FAL used predefined sizes
// but I've notived that they started to add support for custom sizes as well
// so let's use custom sizing now

const imageSize = {
width:
request.meta.width ||
workflowValues.width ||
workflowDefaultValues.width,
height:
request.meta.width ||
workflowValues.height ||
workflowDefaultValues.height,
}

const imageSize =
// this was the previous system
/*
request.meta.orientation === ClapMediaOrientation.SQUARE
? FalAiImageSize.SQUARE_HD
: request.meta.orientation === ClapMediaOrientation.PORTRAIT
? FalAiImageSize.PORTRAIT_16_9
: FalAiImageSize.LANDSCAPE_16_9
*/

// for the moment let's use FAL's predefined sizes
// but see my previous comment above: it's temporary
delete workflowDefaultValues.width
delete workflowDefaultValues.height
delete workflowValues.width
Expand All @@ -76,6 +87,7 @@ export async function resolveSegment(
if (model === 'fal-ai/pulid') {
result = (await fal.run(model, {
input: {
prompt: request.prompts.image.positive,
reference_images: [
{
image_url: request.prompts.image.identity,
Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { ClapWorkflowProvider } from '@aitube/clap'
import { ComfyIcuAccelerator } from '@aitube/clapper-services'

export const ClapWorkflowProviderShortNames = {
[ClapWorkflowProvider.BUILTIN]: 'BUilt-in',
[ClapWorkflowProvider.BUILTIN]: 'Clapper',
[ClapWorkflowProvider.ANTHROPIC]: 'Anthropic',
[ClapWorkflowProvider.COHERE]: 'Cohere',
[ClapWorkflowProvider.COMFYUI]: 'ComfyUI',
[ClapWorkflowProvider.COMFYICU]: 'Comfy.icu',
[ClapWorkflowProvider.COMFYDEPLOY]: 'ComfyDeploy.com',
[ClapWorkflowProvider.CUSTOM]: 'Custom API',
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function SettingsSectionProvider() {
onChange={setReplicateApiKey}
type={apiKeyType}
/>

<FormInput
label="ComfyUI API URL"
value={comfyUiApiUrl}
Expand Down

0 comments on commit 02d66b3

Please sign in to comment.