Skip to content

Commit

Permalink
working to add gen3 and kling through fal.ai
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Oct 10, 2024
1 parent a7f984d commit a3cbbc2
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/app/src/app/api/resolve/providers/falai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,63 @@ export async function resolveSegment(
}
}

segment.assetUrl = result?.video?.url || ''
} else if (model === 'fal-ai/kling-video/v1/standard/text-to-video') {
if (!request.prompts.image.positive) {
throw new Error(`cannot generate a video without a storyboard prompt`)
}

const result = (await fal.run(model, {
input: {
...getWorkflowInputValues(request.settings.videoGenerationWorkflow),

sync_mode: true,
enable_safety_checker:
request.settings.censorNotForAllAudiencesContent,
},
})) as FalAiVideoResponse

if (request.settings.censorNotForAllAudiencesContent) {
if (
Array.isArray(result.has_nsfw_concepts) &&
result.has_nsfw_concepts.includes(true)
) {
throw new Error(
`The generated content has been filtered according to your safety settings`
)
}
}

segment.assetUrl = result?.video?.url || ''
} else if (model === 'fal-ai/runway-gen3/turbo/image-to-video') {
const hasPromptOrImage = request.prompts.image.positive || request.prompts.video.image
if (!hasPromptOrImage) {
throw new Error(`cannot generate a video without a storyboard prompt or a storybaord text`)
}

const result = (await fal.run(model, {
input: {
...getWorkflowInputValues(request.settings.videoGenerationWorkflow),

image_url: request.prompts.video.image,

sync_mode: true,
enable_safety_checker:
request.settings.censorNotForAllAudiencesContent,
},
})) as FalAiVideoResponse

if (request.settings.censorNotForAllAudiencesContent) {
if (
Array.isArray(result.has_nsfw_concepts) &&
result.has_nsfw_concepts.includes(true)
) {
throw new Error(
`The generated content has been filtered according to your safety settings`
)
}
}

segment.assetUrl = result?.video?.url || ''
} else {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,45 @@ TODO: add those as well
// -> we can create a ticket to fix this
// ------------------------------------------------------------------------------
export const defaultWorkflows: ClapWorkflow[] = [
{
id: 'falai://fal-ai/kling-video/v1/standard/text-to-video',
label: 'Kling 1.0',
description: '',
tags: ['video generation'],
author: '',
thumbnailUrl: '',
nonCommercial: true,

engine: ClapWorkflowEngine.REST_API,
provider: ClapWorkflowProvider.FALAI,
category: ClapWorkflowCategory.VIDEO_GENERATION,
data: 'fal-ai/kling-video/v1/standard/text-to-video',
schema: '',
inputFields: [genericPrompt],
inputValues: {
[genericPrompt.id]: genericPrompt.defaultValue,
},
},
{
id: 'falai://fal-ai/runway-gen3/turbo/image-to-video',
label: 'RunwayML Gen 3',
description: '',
tags: ['video generation'],
author: '',
thumbnailUrl: '',
nonCommercial: true,

engine: ClapWorkflowEngine.REST_API,
provider: ClapWorkflowProvider.FALAI,
category: ClapWorkflowCategory.VIDEO_GENERATION,
data: 'fal-ai/runway-gen3/turbo/image-to-video',
schema: '',
inputFields: [genericPrompt, genericImageUrl],
inputValues: {
[genericPrompt.id]: genericPrompt.defaultValue,
[genericImageUrl.id]: genericImageUrl.defaultValue,
},
},
{
id: 'falai://fal-ai/cogvideox-5b',
label: 'CogVideoX-5b',
Expand Down

0 comments on commit a3cbbc2

Please sign in to comment.