@weirdfingers/baseboards 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +561 -469
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
- package/templates/README.md +0 -122
- package/templates/api/.env.example +0 -65
- package/templates/api/ARTIFACT_RESOLUTION_GUIDE.md +0 -148
- package/templates/api/Dockerfile +0 -32
- package/templates/api/README.md +0 -264
- package/templates/api/alembic/env.py +0 -114
- package/templates/api/alembic/script.py.mako +0 -28
- package/templates/api/alembic/versions/20250101_000000_initial_schema.py +0 -506
- package/templates/api/alembic/versions/20251022_174729_remove_provider_name_from_generations.py +0 -75
- package/templates/api/alembic/versions/20251023_165852_switch_to_declarative_base_and_mapping.py +0 -467
- package/templates/api/alembic/versions/20251202_000000_add_artifact_lineage.py +0 -134
- package/templates/api/alembic/versions/2025925_62735_add_seed_data_for_default_tenant.py +0 -88
- package/templates/api/alembic.ini +0 -36
- package/templates/api/config/generators.yaml +0 -237
- package/templates/api/config/storage_config.yaml +0 -26
- package/templates/api/docs/ADDING_GENERATORS.md +0 -409
- package/templates/api/docs/GENERATORS_API.md +0 -502
- package/templates/api/docs/MIGRATIONS.md +0 -472
- package/templates/api/docs/TESTING_LIVE_APIS.md +0 -417
- package/templates/api/docs/storage_providers.md +0 -337
- package/templates/api/pyproject.toml +0 -205
- package/templates/api/src/boards/__init__.py +0 -10
- package/templates/api/src/boards/api/app.py +0 -172
- package/templates/api/src/boards/api/auth.py +0 -75
- package/templates/api/src/boards/api/endpoints/__init__.py +0 -3
- package/templates/api/src/boards/api/endpoints/jobs.py +0 -76
- package/templates/api/src/boards/api/endpoints/setup.py +0 -505
- package/templates/api/src/boards/api/endpoints/sse.py +0 -129
- package/templates/api/src/boards/api/endpoints/storage.py +0 -155
- package/templates/api/src/boards/api/endpoints/tenant_registration.py +0 -296
- package/templates/api/src/boards/api/endpoints/uploads.py +0 -149
- package/templates/api/src/boards/api/endpoints/webhooks.py +0 -13
- package/templates/api/src/boards/auth/__init__.py +0 -15
- package/templates/api/src/boards/auth/adapters/__init__.py +0 -27
- package/templates/api/src/boards/auth/adapters/auth0.py +0 -220
- package/templates/api/src/boards/auth/adapters/base.py +0 -73
- package/templates/api/src/boards/auth/adapters/clerk.py +0 -172
- package/templates/api/src/boards/auth/adapters/jwt.py +0 -122
- package/templates/api/src/boards/auth/adapters/none.py +0 -102
- package/templates/api/src/boards/auth/adapters/oidc.py +0 -284
- package/templates/api/src/boards/auth/adapters/supabase.py +0 -110
- package/templates/api/src/boards/auth/context.py +0 -35
- package/templates/api/src/boards/auth/factory.py +0 -129
- package/templates/api/src/boards/auth/middleware.py +0 -221
- package/templates/api/src/boards/auth/provisioning.py +0 -129
- package/templates/api/src/boards/auth/tenant_extraction.py +0 -278
- package/templates/api/src/boards/cli.py +0 -354
- package/templates/api/src/boards/config.py +0 -131
- package/templates/api/src/boards/database/__init__.py +0 -7
- package/templates/api/src/boards/database/cli.py +0 -110
- package/templates/api/src/boards/database/connection.py +0 -292
- package/templates/api/src/boards/database/models.py +0 -19
- package/templates/api/src/boards/database/seed_data.py +0 -182
- package/templates/api/src/boards/dbmodels/__init__.py +0 -441
- package/templates/api/src/boards/generators/__init__.py +0 -57
- package/templates/api/src/boards/generators/artifact_resolution.py +0 -405
- package/templates/api/src/boards/generators/artifacts.py +0 -53
- package/templates/api/src/boards/generators/base.py +0 -144
- package/templates/api/src/boards/generators/implementations/__init__.py +0 -14
- package/templates/api/src/boards/generators/implementations/fal/__init__.py +0 -25
- package/templates/api/src/boards/generators/implementations/fal/audio/__init__.py +0 -23
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_music_generation.py +0 -171
- package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_sound_effect_generation.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_text_to_speech.py +0 -176
- package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_tts_turbo.py +0 -195
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_sound_effects_v2.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_tts_eleven_v3.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_elevenlabs_tts_turbo_v2_5.py +0 -206
- package/templates/api/src/boards/generators/implementations/fal/audio/fal_minimax_speech_26_hd.py +0 -237
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_music_v2.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/audio/minimax_speech_2_6_turbo.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/__init__.py +0 -63
- package/templates/api/src/boards/generators/implementations/fal/image/bytedance_seedream_v45_edit.py +0 -219
- package/templates/api/src/boards/generators/implementations/fal/image/clarity_upscaler.py +0 -220
- package/templates/api/src/boards/generators/implementations/fal/image/crystal_upscaler.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/image/fal_ideogram_character.py +0 -227
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2.py +0 -203
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_edit.py +0 -230
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro.py +0 -204
- package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro_edit.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_kontext.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_ultra.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image_edit.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_15_edit.py +0 -216
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_5.py +0 -177
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_edit_image.py +0 -182
- package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_mini.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_character_edit.py +0 -299
- package/templates/api/src/boards/generators/implementations/fal/image/ideogram_v2.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview_fast.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_edit.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro.py +0 -179
- package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro_edit.py +0 -226
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image.py +0 -249
- package/templates/api/src/boards/generators/implementations/fal/image/qwen_image_edit.py +0 -244
- package/templates/api/src/boards/generators/implementations/fal/image/reve_edit.py +0 -178
- package/templates/api/src/boards/generators/implementations/fal/image/reve_text_to_image.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/image/seedream_v45_text_to_image.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/utils.py +0 -61
- package/templates/api/src/boards/generators/implementations/fal/video/__init__.py +0 -77
- package/templates/api/src/boards/generators/implementations/fal/video/bytedance_seedance_v1_pro_text_to_video.py +0 -209
- package/templates/api/src/boards/generators/implementations/fal/video/creatify_lipsync.py +0 -161
- package/templates/api/src/boards/generators/implementations/fal/video/fal_bytedance_seedance_v1_pro_image_to_video.py +0 -222
- package/templates/api/src/boards/generators/implementations/fal/video/fal_minimax_hailuo_02_standard_text_to_video.py +0 -152
- package/templates/api/src/boards/generators/implementations/fal/video/fal_pixverse_lipsync.py +0 -197
- package/templates/api/src/boards/generators/implementations/fal/video/fal_sora_2_text_to_video.py +0 -173
- package/templates/api/src/boards/generators/implementations/fal/video/infinitalk.py +0 -221
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_pro.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_standard.py +0 -159
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_image_to_video.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_text_to_video.py +0 -168
- package/templates/api/src/boards/generators/implementations/fal/video/minimax_hailuo_2_3_pro_image_to_video.py +0 -153
- package/templates/api/src/boards/generators/implementations/fal/video/sora2_image_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_image_to_video_pro.py +0 -175
- package/templates/api/src/boards/generators/implementations/fal/video/sora_2_text_to_video_pro.py +0 -163
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2.py +0 -167
- package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2_pro.py +0 -155
- package/templates/api/src/boards/generators/implementations/fal/video/veed_fabric_1_0.py +0 -180
- package/templates/api/src/boards/generators/implementations/fal/video/veed_lipsync.py +0 -174
- package/templates/api/src/boards/generators/implementations/fal/video/veo3.py +0 -194
- package/templates/api/src/boards/generators/implementations/fal/video/veo31.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast.py +0 -190
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast_image_to_video.py +0 -191
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_first_last_frame_to_video.py +0 -187
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_image_to_video.py +0 -183
- package/templates/api/src/boards/generators/implementations/fal/video/veo31_reference_to_video.py +0 -172
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_image_to_video.py +0 -212
- package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_text_to_video.py +0 -208
- package/templates/api/src/boards/generators/implementations/fal/video/wan_pro_image_to_video.py +0 -158
- package/templates/api/src/boards/generators/implementations/kie/__init__.py +0 -11
- package/templates/api/src/boards/generators/implementations/kie/base.py +0 -316
- package/templates/api/src/boards/generators/implementations/kie/image/__init__.py +0 -3
- package/templates/api/src/boards/generators/implementations/kie/image/nano_banana_edit.py +0 -190
- package/templates/api/src/boards/generators/implementations/kie/utils.py +0 -98
- package/templates/api/src/boards/generators/implementations/kie/video/__init__.py +0 -8
- package/templates/api/src/boards/generators/implementations/kie/video/veo3.py +0 -161
- package/templates/api/src/boards/generators/implementations/openai/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/audio/whisper.py +0 -69
- package/templates/api/src/boards/generators/implementations/openai/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/openai/image/dalle3.py +0 -96
- package/templates/api/src/boards/generators/implementations/replicate/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/image/flux_pro.py +0 -88
- package/templates/api/src/boards/generators/implementations/replicate/video/__init__.py +0 -1
- package/templates/api/src/boards/generators/implementations/replicate/video/lipsync.py +0 -73
- package/templates/api/src/boards/generators/loader.py +0 -253
- package/templates/api/src/boards/generators/registry.py +0 -114
- package/templates/api/src/boards/generators/resolution.py +0 -632
- package/templates/api/src/boards/generators/testmods/class_gen.py +0 -34
- package/templates/api/src/boards/generators/testmods/import_side_effect.py +0 -35
- package/templates/api/src/boards/graphql/__init__.py +0 -7
- package/templates/api/src/boards/graphql/access_control.py +0 -136
- package/templates/api/src/boards/graphql/mutations/root.py +0 -148
- package/templates/api/src/boards/graphql/queries/root.py +0 -116
- package/templates/api/src/boards/graphql/resolvers/__init__.py +0 -8
- package/templates/api/src/boards/graphql/resolvers/auth.py +0 -12
- package/templates/api/src/boards/graphql/resolvers/board.py +0 -1053
- package/templates/api/src/boards/graphql/resolvers/generation.py +0 -666
- package/templates/api/src/boards/graphql/resolvers/generator.py +0 -50
- package/templates/api/src/boards/graphql/resolvers/lineage.py +0 -381
- package/templates/api/src/boards/graphql/resolvers/upload.py +0 -463
- package/templates/api/src/boards/graphql/resolvers/user.py +0 -25
- package/templates/api/src/boards/graphql/schema.py +0 -81
- package/templates/api/src/boards/graphql/types/board.py +0 -102
- package/templates/api/src/boards/graphql/types/generation.py +0 -166
- package/templates/api/src/boards/graphql/types/generator.py +0 -17
- package/templates/api/src/boards/graphql/types/user.py +0 -47
- package/templates/api/src/boards/jobs/repository.py +0 -153
- package/templates/api/src/boards/logging.py +0 -195
- package/templates/api/src/boards/middleware.py +0 -339
- package/templates/api/src/boards/progress/__init__.py +0 -4
- package/templates/api/src/boards/progress/models.py +0 -25
- package/templates/api/src/boards/progress/publisher.py +0 -64
- package/templates/api/src/boards/py.typed +0 -0
- package/templates/api/src/boards/redis_pool.py +0 -118
- package/templates/api/src/boards/storage/__init__.py +0 -52
- package/templates/api/src/boards/storage/base.py +0 -363
- package/templates/api/src/boards/storage/config.py +0 -187
- package/templates/api/src/boards/storage/factory.py +0 -288
- package/templates/api/src/boards/storage/implementations/__init__.py +0 -27
- package/templates/api/src/boards/storage/implementations/gcs.py +0 -340
- package/templates/api/src/boards/storage/implementations/local.py +0 -201
- package/templates/api/src/boards/storage/implementations/s3.py +0 -294
- package/templates/api/src/boards/storage/implementations/supabase.py +0 -218
- package/templates/api/src/boards/tenant_isolation.py +0 -446
- package/templates/api/src/boards/validation.py +0 -262
- package/templates/api/src/boards/workers/__init__.py +0 -1
- package/templates/api/src/boards/workers/actors.py +0 -274
- package/templates/api/src/boards/workers/cli.py +0 -125
- package/templates/api/src/boards/workers/context.py +0 -348
- package/templates/api/src/boards/workers/middleware.py +0 -58
- package/templates/api/src/py.typed +0 -0
- package/templates/compose.web.yaml +0 -35
- package/templates/compose.yaml +0 -116
- package/templates/docker/env.example +0 -23
- package/templates/web/.env.example +0 -28
- package/templates/web/Dockerfile +0 -51
- package/templates/web/components.json +0 -22
- package/templates/web/imageLoader.js +0 -18
- package/templates/web/next-env.d.ts +0 -5
- package/templates/web/next.config.js +0 -36
- package/templates/web/package.json +0 -41
- package/templates/web/postcss.config.mjs +0 -7
- package/templates/web/public/favicon.ico +0 -0
- package/templates/web/src/app/boards/[boardId]/page.tsx +0 -353
- package/templates/web/src/app/globals.css +0 -123
- package/templates/web/src/app/layout.tsx +0 -31
- package/templates/web/src/app/lineage/[generationId]/page.tsx +0 -235
- package/templates/web/src/app/page.tsx +0 -35
- package/templates/web/src/app/providers.tsx +0 -18
- package/templates/web/src/components/boards/ArtifactInputSlots.tsx +0 -206
- package/templates/web/src/components/boards/ArtifactPreview.tsx +0 -466
- package/templates/web/src/components/boards/GenerationGrid.tsx +0 -282
- package/templates/web/src/components/boards/GenerationInput.tsx +0 -370
- package/templates/web/src/components/boards/GeneratorSelector.tsx +0 -272
- package/templates/web/src/components/boards/UploadArtifact.tsx +0 -563
- package/templates/web/src/components/header.tsx +0 -32
- package/templates/web/src/components/theme-provider.tsx +0 -10
- package/templates/web/src/components/theme-toggle.tsx +0 -75
- package/templates/web/src/components/ui/alert-dialog.tsx +0 -157
- package/templates/web/src/components/ui/button.tsx +0 -58
- package/templates/web/src/components/ui/card.tsx +0 -92
- package/templates/web/src/components/ui/dropdown-menu.tsx +0 -200
- package/templates/web/src/components/ui/navigation-menu.tsx +0 -168
- package/templates/web/src/components/ui/toast.tsx +0 -128
- package/templates/web/src/components/ui/toaster.tsx +0 -35
- package/templates/web/src/components/ui/use-toast.ts +0 -187
- package/templates/web/src/hooks/useGeneratorMRU.ts +0 -57
- package/templates/web/src/lib/utils.ts +0 -6
- package/templates/web/tsconfig.json +0 -41
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
fal.ai Kling Video AI Avatar v2 Standard generator.
|
|
3
|
-
|
|
4
|
-
Generates avatar videos by synthesizing realistic humans, animals, cartoons, or
|
|
5
|
-
stylized characters. Takes an image and audio as inputs to create synchronized
|
|
6
|
-
video output.
|
|
7
|
-
|
|
8
|
-
Based on Fal AI's fal-ai/kling-video/ai-avatar/v2/standard model.
|
|
9
|
-
See: https://fal.ai/models/fal-ai/kling-video/ai-avatar/v2/standard
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
import os
|
|
13
|
-
|
|
14
|
-
from pydantic import BaseModel, Field
|
|
15
|
-
|
|
16
|
-
from ....artifacts import AudioArtifact, ImageArtifact
|
|
17
|
-
from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class KlingVideoAiAvatarV2StandardInput(BaseModel):
|
|
21
|
-
"""Input schema for Kling Video AI Avatar v2 Standard.
|
|
22
|
-
|
|
23
|
-
Artifact fields are automatically detected via type introspection
|
|
24
|
-
and resolved from generation IDs to artifact objects.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
image: ImageArtifact = Field(description="The image to use as your avatar")
|
|
28
|
-
audio: AudioArtifact = Field(description="The audio file for lip-sync animation")
|
|
29
|
-
prompt: str | None = Field(
|
|
30
|
-
default=".", description="The prompt to use for the video generation"
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class FalKlingVideoAiAvatarV2StandardGenerator(BaseGenerator):
|
|
35
|
-
"""Generator for AI-powered avatar video synthesis."""
|
|
36
|
-
|
|
37
|
-
name = "fal-kling-video-ai-avatar-v2-standard"
|
|
38
|
-
description = "Fal: Kling Video AI Avatar v2 Standard - Avatar video from image and audio"
|
|
39
|
-
artifact_type = "video"
|
|
40
|
-
|
|
41
|
-
def get_input_schema(self) -> type[KlingVideoAiAvatarV2StandardInput]:
|
|
42
|
-
"""Return the input schema for this generator."""
|
|
43
|
-
return KlingVideoAiAvatarV2StandardInput
|
|
44
|
-
|
|
45
|
-
async def generate(
|
|
46
|
-
self, inputs: KlingVideoAiAvatarV2StandardInput, context: GeneratorExecutionContext
|
|
47
|
-
) -> GeneratorResult:
|
|
48
|
-
"""Generate avatar video using fal.ai kling-video/ai-avatar/v2/standard."""
|
|
49
|
-
# Check for API key
|
|
50
|
-
if not os.getenv("FAL_KEY"):
|
|
51
|
-
raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
|
|
52
|
-
|
|
53
|
-
# Import fal_client
|
|
54
|
-
try:
|
|
55
|
-
import fal_client
|
|
56
|
-
except ImportError as e:
|
|
57
|
-
raise ImportError(
|
|
58
|
-
"fal.ai SDK is required for FalKlingVideoAiAvatarV2StandardGenerator. "
|
|
59
|
-
"Install with: pip install weirdfingers-boards[generators-fal]"
|
|
60
|
-
) from e
|
|
61
|
-
|
|
62
|
-
# Upload image and audio artifacts to Fal's public storage
|
|
63
|
-
# Fal API requires publicly accessible URLs
|
|
64
|
-
from ..utils import upload_artifacts_to_fal
|
|
65
|
-
|
|
66
|
-
# Upload image and audio separately
|
|
67
|
-
image_urls = await upload_artifacts_to_fal([inputs.image], context)
|
|
68
|
-
audio_urls = await upload_artifacts_to_fal([inputs.audio], context)
|
|
69
|
-
|
|
70
|
-
# Prepare arguments for fal.ai API
|
|
71
|
-
arguments = {
|
|
72
|
-
"image_url": image_urls[0],
|
|
73
|
-
"audio_url": audio_urls[0],
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
# Add prompt only if provided and not the default empty value
|
|
77
|
-
if inputs.prompt and inputs.prompt != ".":
|
|
78
|
-
arguments["prompt"] = inputs.prompt
|
|
79
|
-
|
|
80
|
-
# Submit async job
|
|
81
|
-
handler = await fal_client.submit_async(
|
|
82
|
-
"fal-ai/kling-video/ai-avatar/v2/standard",
|
|
83
|
-
arguments=arguments,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
# Store external job ID
|
|
87
|
-
await context.set_external_job_id(handler.request_id)
|
|
88
|
-
|
|
89
|
-
# Stream progress updates
|
|
90
|
-
from .....progress.models import ProgressUpdate
|
|
91
|
-
|
|
92
|
-
event_count = 0
|
|
93
|
-
async for event in handler.iter_events(with_logs=True):
|
|
94
|
-
event_count += 1
|
|
95
|
-
# Sample every 3rd event to avoid spam
|
|
96
|
-
if event_count % 3 == 0:
|
|
97
|
-
# Extract logs if available
|
|
98
|
-
logs = getattr(event, "logs", None)
|
|
99
|
-
if logs:
|
|
100
|
-
# Join log entries into a single message
|
|
101
|
-
if isinstance(logs, list):
|
|
102
|
-
message = " | ".join(str(log) for log in logs if log)
|
|
103
|
-
else:
|
|
104
|
-
message = str(logs)
|
|
105
|
-
|
|
106
|
-
if message:
|
|
107
|
-
await context.publish_progress(
|
|
108
|
-
ProgressUpdate(
|
|
109
|
-
job_id=handler.request_id,
|
|
110
|
-
status="processing",
|
|
111
|
-
progress=50.0, # Approximate mid-point progress
|
|
112
|
-
phase="processing",
|
|
113
|
-
message=message,
|
|
114
|
-
)
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
# Get final result
|
|
118
|
-
result = await handler.get()
|
|
119
|
-
|
|
120
|
-
# Extract video from result
|
|
121
|
-
# fal.ai returns: {"video": {"url": ..., "content_type": ...}, "duration": ...}
|
|
122
|
-
video_data = result.get("video")
|
|
123
|
-
|
|
124
|
-
if not video_data:
|
|
125
|
-
raise ValueError("No video returned from fal.ai API")
|
|
126
|
-
|
|
127
|
-
video_url = video_data.get("url")
|
|
128
|
-
if not video_url:
|
|
129
|
-
raise ValueError("Video missing URL in fal.ai response")
|
|
130
|
-
|
|
131
|
-
# Extract format from content_type (e.g., "video/mp4" -> "mp4")
|
|
132
|
-
content_type = video_data.get("content_type", "video/mp4")
|
|
133
|
-
video_format = content_type.split("/")[-1] if "/" in content_type else "mp4"
|
|
134
|
-
|
|
135
|
-
# Extract duration from response (available in API response)
|
|
136
|
-
duration = result.get("duration")
|
|
137
|
-
|
|
138
|
-
# Store the video result
|
|
139
|
-
# Use input image dimensions as base dimensions (avatar video maintains aspect ratio)
|
|
140
|
-
artifact = await context.store_video_result(
|
|
141
|
-
storage_url=video_url,
|
|
142
|
-
format=video_format,
|
|
143
|
-
width=inputs.image.width,
|
|
144
|
-
height=inputs.image.height,
|
|
145
|
-
duration=duration,
|
|
146
|
-
fps=None, # Not provided by API
|
|
147
|
-
output_index=0,
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
return GeneratorResult(outputs=[artifact])
|
|
151
|
-
|
|
152
|
-
async def estimate_cost(self, inputs: KlingVideoAiAvatarV2StandardInput) -> float:
|
|
153
|
-
"""Estimate cost for Kling Video AI Avatar v2 Standard generation in USD.
|
|
154
|
-
|
|
155
|
-
Pricing not specified in documentation, using estimate based on
|
|
156
|
-
typical Kling video generation costs.
|
|
157
|
-
"""
|
|
158
|
-
# Estimate per generation based on typical Kling pricing
|
|
159
|
-
return 0.10
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Kling v2.5 Turbo Pro image-to-video generator.
|
|
3
|
-
|
|
4
|
-
Top-tier image-to-video generation with unparalleled motion fluidity, cinematic visuals,
|
|
5
|
-
and exceptional prompt precision using Kling's v2.5 Turbo Pro model.
|
|
6
|
-
|
|
7
|
-
Based on Fal AI's fal-ai/kling-video/v2.5-turbo/pro/image-to-video model.
|
|
8
|
-
See: https://fal.ai/models/fal-ai/kling-video/v2.5-turbo/pro/image-to-video
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import os
|
|
12
|
-
from typing import Literal
|
|
13
|
-
|
|
14
|
-
from pydantic import BaseModel, Field
|
|
15
|
-
|
|
16
|
-
from ....artifacts import ImageArtifact
|
|
17
|
-
from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class KlingVideoV25TurboProImageToVideoInput(BaseModel):
|
|
21
|
-
"""Input schema for Kling v2.5 Turbo Pro image-to-video generation.
|
|
22
|
-
|
|
23
|
-
Artifact fields (image_url) are automatically detected via type introspection
|
|
24
|
-
and resolved from generation IDs to ImageArtifact objects.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
prompt: str = Field(
|
|
28
|
-
description="Text description of desired video content",
|
|
29
|
-
max_length=2500,
|
|
30
|
-
)
|
|
31
|
-
image_url: ImageArtifact = Field(
|
|
32
|
-
description="Source image for animation",
|
|
33
|
-
)
|
|
34
|
-
duration: Literal["5", "10"] = Field(
|
|
35
|
-
default="5",
|
|
36
|
-
description="Video length in seconds",
|
|
37
|
-
)
|
|
38
|
-
negative_prompt: str = Field(
|
|
39
|
-
default="blur, distort, and low quality",
|
|
40
|
-
description="Elements to exclude from output",
|
|
41
|
-
max_length=2500,
|
|
42
|
-
)
|
|
43
|
-
cfg_scale: float = Field(
|
|
44
|
-
default=0.5,
|
|
45
|
-
ge=0.0,
|
|
46
|
-
le=1.0,
|
|
47
|
-
description="Guidance strength controlling prompt adherence (0-1)",
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class FalKlingVideoV25TurboProImageToVideoGenerator(BaseGenerator):
|
|
52
|
-
"""Generator for image-to-video using Kling v2.5 Turbo Pro."""
|
|
53
|
-
|
|
54
|
-
name = "fal-kling-video-v2-5-turbo-pro-image-to-video"
|
|
55
|
-
description = (
|
|
56
|
-
"Fal: Kling v2.5 Turbo Pro - top-tier image-to-video generation with cinematic visuals"
|
|
57
|
-
)
|
|
58
|
-
artifact_type = "video"
|
|
59
|
-
|
|
60
|
-
def get_input_schema(self) -> type[KlingVideoV25TurboProImageToVideoInput]:
|
|
61
|
-
"""Return the input schema for this generator."""
|
|
62
|
-
return KlingVideoV25TurboProImageToVideoInput
|
|
63
|
-
|
|
64
|
-
async def generate(
|
|
65
|
-
self, inputs: KlingVideoV25TurboProImageToVideoInput, context: GeneratorExecutionContext
|
|
66
|
-
) -> GeneratorResult:
|
|
67
|
-
"""Generate video using fal.ai Kling v2.5 Turbo Pro image-to-video model."""
|
|
68
|
-
# Check for API key
|
|
69
|
-
if not os.getenv("FAL_KEY"):
|
|
70
|
-
raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
|
|
71
|
-
|
|
72
|
-
# Import fal_client
|
|
73
|
-
try:
|
|
74
|
-
import fal_client
|
|
75
|
-
except ImportError as e:
|
|
76
|
-
raise ImportError(
|
|
77
|
-
"fal.ai SDK is required for FalKlingVideoV25TurboProImageToVideoGenerator. "
|
|
78
|
-
"Install with: pip install weirdfingers-boards[generators-fal]"
|
|
79
|
-
) from e
|
|
80
|
-
|
|
81
|
-
# Upload image artifact to Fal's public storage
|
|
82
|
-
# Fal API requires publicly accessible URLs
|
|
83
|
-
from ..utils import upload_artifacts_to_fal
|
|
84
|
-
|
|
85
|
-
image_urls = await upload_artifacts_to_fal([inputs.image_url], context)
|
|
86
|
-
|
|
87
|
-
# Prepare arguments for fal.ai API
|
|
88
|
-
arguments = {
|
|
89
|
-
"prompt": inputs.prompt,
|
|
90
|
-
"image_url": image_urls[0],
|
|
91
|
-
"duration": inputs.duration,
|
|
92
|
-
"negative_prompt": inputs.negative_prompt,
|
|
93
|
-
"cfg_scale": inputs.cfg_scale,
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
# Submit async job
|
|
97
|
-
handler = await fal_client.submit_async(
|
|
98
|
-
"fal-ai/kling-video/v2.5-turbo/pro/image-to-video",
|
|
99
|
-
arguments=arguments,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
# Store external job ID
|
|
103
|
-
await context.set_external_job_id(handler.request_id)
|
|
104
|
-
|
|
105
|
-
# Stream progress updates
|
|
106
|
-
from .....progress.models import ProgressUpdate
|
|
107
|
-
|
|
108
|
-
event_count = 0
|
|
109
|
-
async for event in handler.iter_events(with_logs=True):
|
|
110
|
-
event_count += 1
|
|
111
|
-
# Sample every 3rd event to avoid spam
|
|
112
|
-
if event_count % 3 == 0:
|
|
113
|
-
# Extract logs if available
|
|
114
|
-
logs = getattr(event, "logs", None)
|
|
115
|
-
if logs:
|
|
116
|
-
# Join log entries into a single message
|
|
117
|
-
if isinstance(logs, list):
|
|
118
|
-
message = " | ".join(str(log) for log in logs if log)
|
|
119
|
-
else:
|
|
120
|
-
message = str(logs)
|
|
121
|
-
|
|
122
|
-
if message:
|
|
123
|
-
await context.publish_progress(
|
|
124
|
-
ProgressUpdate(
|
|
125
|
-
job_id=handler.request_id,
|
|
126
|
-
status="processing",
|
|
127
|
-
progress=50.0, # Approximate mid-point progress
|
|
128
|
-
phase="processing",
|
|
129
|
-
message=message,
|
|
130
|
-
)
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
# Get final result
|
|
134
|
-
result = await handler.get()
|
|
135
|
-
|
|
136
|
-
# Extract video from result
|
|
137
|
-
# fal.ai returns: {"video": {"url": "...", "content_type": "video/mp4", ...}}
|
|
138
|
-
video_data = result.get("video")
|
|
139
|
-
if not video_data:
|
|
140
|
-
raise ValueError("No video returned from fal.ai API")
|
|
141
|
-
|
|
142
|
-
video_url = video_data.get("url")
|
|
143
|
-
if not video_url:
|
|
144
|
-
raise ValueError("Video missing URL in fal.ai response")
|
|
145
|
-
|
|
146
|
-
# Determine video dimensions based on input image
|
|
147
|
-
# Kling maintains the aspect ratio of the input image
|
|
148
|
-
# Use input image dimensions as reference
|
|
149
|
-
width = inputs.image_url.width
|
|
150
|
-
height = inputs.image_url.height
|
|
151
|
-
|
|
152
|
-
# Store video result
|
|
153
|
-
artifact = await context.store_video_result(
|
|
154
|
-
storage_url=video_url,
|
|
155
|
-
format="mp4",
|
|
156
|
-
width=width,
|
|
157
|
-
height=height,
|
|
158
|
-
duration=float(inputs.duration), # Convert "5" or "10" to float
|
|
159
|
-
output_index=0,
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
return GeneratorResult(outputs=[artifact])
|
|
163
|
-
|
|
164
|
-
async def estimate_cost(self, inputs: KlingVideoV25TurboProImageToVideoInput) -> float:
|
|
165
|
-
"""Estimate cost for Kling v2.5 Turbo Pro image-to-video generation.
|
|
166
|
-
|
|
167
|
-
Pricing information not provided in official documentation.
|
|
168
|
-
Estimated at $0.15 per video based on typical video generation costs.
|
|
169
|
-
Cost may vary based on duration and quality settings.
|
|
170
|
-
"""
|
|
171
|
-
# Approximate cost per video
|
|
172
|
-
# 10-second videos may cost more than 5-second videos
|
|
173
|
-
base_cost = 0.15
|
|
174
|
-
duration_multiplier = 2.0 if inputs.duration == "10" else 1.0
|
|
175
|
-
return base_cost * duration_multiplier
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Kling v2.5 Turbo Pro text-to-video generator.
|
|
3
|
-
|
|
4
|
-
Top-tier text-to-video generation with unparalleled motion fluidity, cinematic visuals,
|
|
5
|
-
and exceptional prompt precision using Kling's v2.5 Turbo Pro model.
|
|
6
|
-
|
|
7
|
-
Based on Fal AI's fal-ai/kling-video/v2.5-turbo/pro/text-to-video model.
|
|
8
|
-
See: https://fal.ai/models/fal-ai/kling-video/v2.5-turbo/pro/text-to-video
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import os
|
|
12
|
-
from typing import Literal
|
|
13
|
-
|
|
14
|
-
from pydantic import BaseModel, Field
|
|
15
|
-
|
|
16
|
-
from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class KlingVideoV25TurboProTextToVideoInput(BaseModel):
|
|
20
|
-
"""Input schema for Kling v2.5 Turbo Pro text-to-video generation."""
|
|
21
|
-
|
|
22
|
-
prompt: str = Field(
|
|
23
|
-
description="Primary instruction for video generation",
|
|
24
|
-
max_length=2500,
|
|
25
|
-
)
|
|
26
|
-
duration: Literal["5", "10"] = Field(
|
|
27
|
-
default="5",
|
|
28
|
-
description="Video length in seconds",
|
|
29
|
-
)
|
|
30
|
-
aspect_ratio: Literal["16:9", "9:16", "1:1"] = Field(
|
|
31
|
-
default="16:9",
|
|
32
|
-
description="Frame dimensions",
|
|
33
|
-
)
|
|
34
|
-
negative_prompt: str = Field(
|
|
35
|
-
default="blur, distort, and low quality",
|
|
36
|
-
description="Elements to exclude from output",
|
|
37
|
-
max_length=2500,
|
|
38
|
-
)
|
|
39
|
-
cfg_scale: float = Field(
|
|
40
|
-
default=0.5,
|
|
41
|
-
ge=0.0,
|
|
42
|
-
le=1.0,
|
|
43
|
-
description="Guidance strength controlling prompt adherence (0-1)",
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class FalKlingVideoV25TurboProTextToVideoGenerator(BaseGenerator):
|
|
48
|
-
"""Generator for text-to-video using Kling v2.5 Turbo Pro."""
|
|
49
|
-
|
|
50
|
-
name = "fal-kling-video-v2-5-turbo-pro-text-to-video"
|
|
51
|
-
description = (
|
|
52
|
-
"Fal: Kling v2.5 Turbo Pro - top-tier text-to-video generation with cinematic visuals"
|
|
53
|
-
)
|
|
54
|
-
artifact_type = "video"
|
|
55
|
-
|
|
56
|
-
def get_input_schema(self) -> type[KlingVideoV25TurboProTextToVideoInput]:
|
|
57
|
-
"""Return the input schema for this generator."""
|
|
58
|
-
return KlingVideoV25TurboProTextToVideoInput
|
|
59
|
-
|
|
60
|
-
async def generate(
|
|
61
|
-
self, inputs: KlingVideoV25TurboProTextToVideoInput, context: GeneratorExecutionContext
|
|
62
|
-
) -> GeneratorResult:
|
|
63
|
-
"""Generate video using fal.ai Kling v2.5 Turbo Pro model."""
|
|
64
|
-
# Check for API key
|
|
65
|
-
if not os.getenv("FAL_KEY"):
|
|
66
|
-
raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
|
|
67
|
-
|
|
68
|
-
# Import fal_client
|
|
69
|
-
try:
|
|
70
|
-
import fal_client
|
|
71
|
-
except ImportError as e:
|
|
72
|
-
raise ImportError(
|
|
73
|
-
"fal.ai SDK is required for FalKlingVideoV25TurboProTextToVideoGenerator. "
|
|
74
|
-
"Install with: pip install weirdfingers-boards[generators-fal]"
|
|
75
|
-
) from e
|
|
76
|
-
|
|
77
|
-
# Prepare arguments for fal.ai API
|
|
78
|
-
arguments = {
|
|
79
|
-
"prompt": inputs.prompt,
|
|
80
|
-
"duration": inputs.duration,
|
|
81
|
-
"aspect_ratio": inputs.aspect_ratio,
|
|
82
|
-
"negative_prompt": inputs.negative_prompt,
|
|
83
|
-
"cfg_scale": inputs.cfg_scale,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
# Submit async job
|
|
87
|
-
handler = await fal_client.submit_async(
|
|
88
|
-
"fal-ai/kling-video/v2.5-turbo/pro/text-to-video",
|
|
89
|
-
arguments=arguments,
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
# Store external job ID
|
|
93
|
-
await context.set_external_job_id(handler.request_id)
|
|
94
|
-
|
|
95
|
-
# Stream progress updates
|
|
96
|
-
from .....progress.models import ProgressUpdate
|
|
97
|
-
|
|
98
|
-
event_count = 0
|
|
99
|
-
async for event in handler.iter_events(with_logs=True):
|
|
100
|
-
event_count += 1
|
|
101
|
-
# Sample every 3rd event to avoid spam
|
|
102
|
-
if event_count % 3 == 0:
|
|
103
|
-
# Extract logs if available
|
|
104
|
-
logs = getattr(event, "logs", None)
|
|
105
|
-
if logs:
|
|
106
|
-
# Join log entries into a single message
|
|
107
|
-
if isinstance(logs, list):
|
|
108
|
-
message = " | ".join(str(log) for log in logs if log)
|
|
109
|
-
else:
|
|
110
|
-
message = str(logs)
|
|
111
|
-
|
|
112
|
-
if message:
|
|
113
|
-
await context.publish_progress(
|
|
114
|
-
ProgressUpdate(
|
|
115
|
-
job_id=handler.request_id,
|
|
116
|
-
status="processing",
|
|
117
|
-
progress=50.0, # Approximate mid-point progress
|
|
118
|
-
phase="processing",
|
|
119
|
-
message=message,
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
# Get final result
|
|
124
|
-
result = await handler.get()
|
|
125
|
-
|
|
126
|
-
# Extract video from result
|
|
127
|
-
# fal.ai returns: {"video": {"url": "...", "content_type": "video/mp4", ...}}
|
|
128
|
-
video_data = result.get("video")
|
|
129
|
-
if not video_data:
|
|
130
|
-
raise ValueError("No video returned from fal.ai API")
|
|
131
|
-
|
|
132
|
-
video_url = video_data.get("url")
|
|
133
|
-
if not video_url:
|
|
134
|
-
raise ValueError("Video missing URL in fal.ai response")
|
|
135
|
-
|
|
136
|
-
# Determine video dimensions based on aspect ratio
|
|
137
|
-
# Using HD quality resolutions
|
|
138
|
-
aspect_ratio_dimensions = {
|
|
139
|
-
"16:9": (1920, 1080),
|
|
140
|
-
"9:16": (1080, 1920),
|
|
141
|
-
"1:1": (1080, 1080),
|
|
142
|
-
}
|
|
143
|
-
width, height = aspect_ratio_dimensions.get(inputs.aspect_ratio, (1920, 1080))
|
|
144
|
-
|
|
145
|
-
# Store video result
|
|
146
|
-
artifact = await context.store_video_result(
|
|
147
|
-
storage_url=video_url,
|
|
148
|
-
format="mp4",
|
|
149
|
-
width=width,
|
|
150
|
-
height=height,
|
|
151
|
-
duration=float(inputs.duration), # Convert "5" or "10" to float
|
|
152
|
-
output_index=0,
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
return GeneratorResult(outputs=[artifact])
|
|
156
|
-
|
|
157
|
-
async def estimate_cost(self, inputs: KlingVideoV25TurboProTextToVideoInput) -> float:
|
|
158
|
-
"""Estimate cost for Kling v2.5 Turbo Pro generation.
|
|
159
|
-
|
|
160
|
-
Pricing information not provided in official documentation.
|
|
161
|
-
Estimated at $0.15 per video based on typical video generation costs.
|
|
162
|
-
Cost may vary based on duration and quality settings.
|
|
163
|
-
"""
|
|
164
|
-
# Approximate cost per video
|
|
165
|
-
# 10-second videos may cost more than 5-second videos
|
|
166
|
-
base_cost = 0.15
|
|
167
|
-
duration_multiplier = 2.0 if inputs.duration == "10" else 1.0
|
|
168
|
-
return base_cost * duration_multiplier
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
MiniMax Hailuo 2.3 Pro image-to-video generator.
|
|
3
|
-
|
|
4
|
-
Advanced image-to-video generation model with 1080p resolution. Transforms static
|
|
5
|
-
images into dynamic videos using text prompts to guide the creative output.
|
|
6
|
-
|
|
7
|
-
Based on Fal AI's fal-ai/minimax/hailuo-2.3/pro/image-to-video model.
|
|
8
|
-
See: https://fal.ai/models/fal-ai/minimax/hailuo-2.3/pro/image-to-video
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import os
|
|
12
|
-
|
|
13
|
-
from pydantic import BaseModel, Field
|
|
14
|
-
|
|
15
|
-
from ....artifacts import ImageArtifact
|
|
16
|
-
from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class MinimaxHailuo23ProImageToVideoInput(BaseModel):
|
|
20
|
-
"""Input schema for MiniMax Hailuo 2.3 Pro image-to-video generation.
|
|
21
|
-
|
|
22
|
-
Artifact fields (image_url) are automatically detected via type introspection
|
|
23
|
-
and resolved from generation IDs to ImageArtifact objects.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
prompt: str = Field(
|
|
27
|
-
description="Text prompt for video generation",
|
|
28
|
-
min_length=1,
|
|
29
|
-
max_length=2000,
|
|
30
|
-
)
|
|
31
|
-
image_url: ImageArtifact = Field(description="URL of the image to use as the first frame")
|
|
32
|
-
prompt_optimizer: bool = Field(
|
|
33
|
-
default=True,
|
|
34
|
-
description="Whether to use the model's prompt optimizer",
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class FalMinimaxHailuo23ProImageToVideoGenerator(BaseGenerator):
|
|
39
|
-
"""Generator for creating videos from images using MiniMax Hailuo 2.3 Pro."""
|
|
40
|
-
|
|
41
|
-
name = "fal-minimax-hailuo-2-3-pro-image-to-video"
|
|
42
|
-
description = "Fal: MiniMax Hailuo 2.3 Pro - Image-to-video with 1080p resolution"
|
|
43
|
-
artifact_type = "video"
|
|
44
|
-
|
|
45
|
-
def get_input_schema(self) -> type[MinimaxHailuo23ProImageToVideoInput]:
|
|
46
|
-
"""Return the input schema for this generator."""
|
|
47
|
-
return MinimaxHailuo23ProImageToVideoInput
|
|
48
|
-
|
|
49
|
-
async def generate(
|
|
50
|
-
self, inputs: MinimaxHailuo23ProImageToVideoInput, context: GeneratorExecutionContext
|
|
51
|
-
) -> GeneratorResult:
|
|
52
|
-
"""Generate video using fal.ai minimax/hailuo-2.3/pro/image-to-video."""
|
|
53
|
-
# Check for API key
|
|
54
|
-
if not os.getenv("FAL_KEY"):
|
|
55
|
-
raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
|
|
56
|
-
|
|
57
|
-
# Import fal_client
|
|
58
|
-
try:
|
|
59
|
-
import fal_client
|
|
60
|
-
except ImportError as e:
|
|
61
|
-
raise ImportError(
|
|
62
|
-
"fal.ai SDK is required for FalMinimaxHailuo23ProImageToVideoGenerator. "
|
|
63
|
-
"Install with: pip install weirdfingers-boards[generators-fal]"
|
|
64
|
-
) from e
|
|
65
|
-
|
|
66
|
-
# Upload image artifact to Fal's public storage
|
|
67
|
-
# Fal API requires publicly accessible URLs, but our storage_url might be:
|
|
68
|
-
# - Localhost URLs (not publicly accessible)
|
|
69
|
-
# - Private S3 buckets (not publicly accessible)
|
|
70
|
-
# So we upload to Fal's temporary storage first
|
|
71
|
-
from ..utils import upload_artifacts_to_fal
|
|
72
|
-
|
|
73
|
-
image_urls = await upload_artifacts_to_fal([inputs.image_url], context)
|
|
74
|
-
|
|
75
|
-
# Prepare arguments for fal.ai API
|
|
76
|
-
arguments = {
|
|
77
|
-
"prompt": inputs.prompt,
|
|
78
|
-
"image_url": image_urls[0],
|
|
79
|
-
"prompt_optimizer": inputs.prompt_optimizer,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
# Submit async job
|
|
83
|
-
handler = await fal_client.submit_async(
|
|
84
|
-
"fal-ai/minimax/hailuo-2.3/pro/image-to-video",
|
|
85
|
-
arguments=arguments,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
# Store external job ID
|
|
89
|
-
await context.set_external_job_id(handler.request_id)
|
|
90
|
-
|
|
91
|
-
# Stream progress updates
|
|
92
|
-
from .....progress.models import ProgressUpdate
|
|
93
|
-
|
|
94
|
-
event_count = 0
|
|
95
|
-
async for event in handler.iter_events(with_logs=True):
|
|
96
|
-
event_count += 1
|
|
97
|
-
# Sample every 3rd event to avoid spam
|
|
98
|
-
if event_count % 3 == 0:
|
|
99
|
-
# Extract logs if available
|
|
100
|
-
logs = getattr(event, "logs", None)
|
|
101
|
-
if logs:
|
|
102
|
-
# Join log entries into a single message
|
|
103
|
-
if isinstance(logs, list):
|
|
104
|
-
message = " | ".join(str(log) for log in logs if log)
|
|
105
|
-
else:
|
|
106
|
-
message = str(logs)
|
|
107
|
-
|
|
108
|
-
if message:
|
|
109
|
-
await context.publish_progress(
|
|
110
|
-
ProgressUpdate(
|
|
111
|
-
job_id=handler.request_id,
|
|
112
|
-
status="processing",
|
|
113
|
-
progress=50.0,
|
|
114
|
-
phase="processing",
|
|
115
|
-
message=message,
|
|
116
|
-
)
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
# Get final result
|
|
120
|
-
result = await handler.get()
|
|
121
|
-
|
|
122
|
-
# Extract video from result
|
|
123
|
-
# Expected structure: {"video": {"url": "...", "content_type": "...", ...}}
|
|
124
|
-
video_data = result.get("video")
|
|
125
|
-
if not video_data:
|
|
126
|
-
raise ValueError("No video returned from fal.ai API")
|
|
127
|
-
|
|
128
|
-
video_url = video_data.get("url")
|
|
129
|
-
if not video_url:
|
|
130
|
-
raise ValueError("Video missing URL in fal.ai response")
|
|
131
|
-
|
|
132
|
-
# Store video result
|
|
133
|
-
# Note: Fal API doesn't provide video dimensions/duration in the response,
|
|
134
|
-
# so we'll use defaults based on the model's 1080p output
|
|
135
|
-
artifact = await context.store_video_result(
|
|
136
|
-
storage_url=video_url,
|
|
137
|
-
format="mp4",
|
|
138
|
-
width=1920,
|
|
139
|
-
height=1080,
|
|
140
|
-
duration=None, # Duration not provided in response
|
|
141
|
-
output_index=0,
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
return GeneratorResult(outputs=[artifact])
|
|
145
|
-
|
|
146
|
-
async def estimate_cost(self, inputs: MinimaxHailuo23ProImageToVideoInput) -> float:
|
|
147
|
-
"""Estimate cost for this generation in USD.
|
|
148
|
-
|
|
149
|
-
Note: Pricing information not available in Fal documentation.
|
|
150
|
-
Using placeholder value that should be updated with actual pricing.
|
|
151
|
-
"""
|
|
152
|
-
# TODO: Update with actual pricing from Fal when available
|
|
153
|
-
return 0.12 # Placeholder estimate for 1080p video generation
|