@weirdfingers/baseboards 0.5.3 → 0.6.1

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.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/templates/api/alembic/env.py +9 -1
  4. package/templates/api/alembic/versions/20250101_000000_initial_schema.py +107 -49
  5. package/templates/api/alembic/versions/20251022_174729_remove_provider_name_from_generations.py +7 -3
  6. package/templates/api/alembic/versions/20251023_165852_switch_to_declarative_base_and_mapping.py +57 -1
  7. package/templates/api/alembic/versions/20251202_000000_add_artifact_lineage.py +134 -0
  8. package/templates/api/alembic/versions/2025925_62735_add_seed_data_for_default_tenant.py +8 -5
  9. package/templates/api/config/generators.yaml +111 -0
  10. package/templates/api/src/boards/__init__.py +1 -1
  11. package/templates/api/src/boards/api/app.py +2 -1
  12. package/templates/api/src/boards/api/endpoints/tenant_registration.py +1 -1
  13. package/templates/api/src/boards/api/endpoints/uploads.py +150 -0
  14. package/templates/api/src/boards/auth/factory.py +1 -1
  15. package/templates/api/src/boards/dbmodels/__init__.py +8 -22
  16. package/templates/api/src/boards/generators/artifact_resolution.py +45 -12
  17. package/templates/api/src/boards/generators/implementations/fal/audio/__init__.py +16 -1
  18. package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_music_generation.py +171 -0
  19. package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_sound_effect_generation.py +167 -0
  20. package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_sound_effects_v2.py +194 -0
  21. package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_tts_eleven_v3.py +209 -0
  22. package/templates/api/src/boards/generators/implementations/fal/audio/fal_elevenlabs_tts_turbo_v2_5.py +206 -0
  23. package/templates/api/src/boards/generators/implementations/fal/audio/fal_minimax_speech_26_hd.py +237 -0
  24. package/templates/api/src/boards/generators/implementations/fal/audio/minimax_speech_2_6_turbo.py +1 -1
  25. package/templates/api/src/boards/generators/implementations/fal/image/__init__.py +30 -0
  26. package/templates/api/src/boards/generators/implementations/fal/image/clarity_upscaler.py +220 -0
  27. package/templates/api/src/boards/generators/implementations/fal/image/crystal_upscaler.py +173 -0
  28. package/templates/api/src/boards/generators/implementations/fal/image/fal_ideogram_character.py +227 -0
  29. package/templates/api/src/boards/generators/implementations/fal/image/flux_2.py +203 -0
  30. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_edit.py +230 -0
  31. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro.py +204 -0
  32. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro_edit.py +221 -0
  33. package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image.py +177 -0
  34. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_edit_image.py +182 -0
  35. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_mini.py +167 -0
  36. package/templates/api/src/boards/generators/implementations/fal/image/ideogram_character_edit.py +299 -0
  37. package/templates/api/src/boards/generators/implementations/fal/image/ideogram_v2.py +190 -0
  38. package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro_edit.py +226 -0
  39. package/templates/api/src/boards/generators/implementations/fal/image/qwen_image.py +249 -0
  40. package/templates/api/src/boards/generators/implementations/fal/image/qwen_image_edit.py +244 -0
  41. package/templates/api/src/boards/generators/implementations/fal/video/__init__.py +42 -0
  42. package/templates/api/src/boards/generators/implementations/fal/video/bytedance_seedance_v1_pro_text_to_video.py +209 -0
  43. package/templates/api/src/boards/generators/implementations/fal/video/creatify_lipsync.py +161 -0
  44. package/templates/api/src/boards/generators/implementations/fal/video/fal_bytedance_seedance_v1_pro_image_to_video.py +222 -0
  45. package/templates/api/src/boards/generators/implementations/fal/video/fal_minimax_hailuo_02_standard_text_to_video.py +152 -0
  46. package/templates/api/src/boards/generators/implementations/fal/video/fal_pixverse_lipsync.py +197 -0
  47. package/templates/api/src/boards/generators/implementations/fal/video/fal_sora_2_text_to_video.py +173 -0
  48. package/templates/api/src/boards/generators/implementations/fal/video/infinitalk.py +221 -0
  49. package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_image_to_video.py +175 -0
  50. package/templates/api/src/boards/generators/implementations/fal/video/minimax_hailuo_2_3_pro_image_to_video.py +153 -0
  51. package/templates/api/src/boards/generators/implementations/fal/video/sora2_image_to_video.py +172 -0
  52. package/templates/api/src/boards/generators/implementations/fal/video/sora_2_image_to_video_pro.py +175 -0
  53. package/templates/api/src/boards/generators/implementations/fal/video/sora_2_text_to_video_pro.py +163 -0
  54. package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2_pro.py +155 -0
  55. package/templates/api/src/boards/generators/implementations/fal/video/veed_lipsync.py +174 -0
  56. package/templates/api/src/boards/generators/implementations/fal/video/veo3.py +194 -0
  57. package/templates/api/src/boards/generators/implementations/fal/video/veo31_first_last_frame_to_video.py +1 -1
  58. package/templates/api/src/boards/generators/implementations/fal/video/wan_pro_image_to_video.py +158 -0
  59. package/templates/api/src/boards/graphql/access_control.py +1 -1
  60. package/templates/api/src/boards/graphql/mutations/root.py +16 -4
  61. package/templates/api/src/boards/graphql/resolvers/board.py +0 -2
  62. package/templates/api/src/boards/graphql/resolvers/generation.py +10 -233
  63. package/templates/api/src/boards/graphql/resolvers/lineage.py +381 -0
  64. package/templates/api/src/boards/graphql/resolvers/upload.py +463 -0
  65. package/templates/api/src/boards/graphql/types/generation.py +62 -26
  66. package/templates/api/src/boards/middleware.py +1 -1
  67. package/templates/api/src/boards/storage/factory.py +2 -2
  68. package/templates/api/src/boards/tenant_isolation.py +9 -9
  69. package/templates/api/src/boards/workers/actors.py +10 -1
  70. package/templates/web/package.json +1 -1
  71. package/templates/web/src/app/boards/[boardId]/page.tsx +14 -5
  72. package/templates/web/src/app/lineage/[generationId]/page.tsx +233 -0
  73. package/templates/web/src/components/boards/ArtifactPreview.tsx +20 -1
  74. package/templates/web/src/components/boards/UploadArtifact.tsx +253 -0
@@ -0,0 +1,171 @@
1
+ """
2
+ Beatoven music generation - royalty-free instrumental music generator.
3
+
4
+ Generate high-quality instrumental music from electronic, hip hop, and indie rock
5
+ to cinematic and classical genres. Designed for games, films, social content,
6
+ podcasts, and similar applications.
7
+
8
+ Based on Fal AI's beatoven/music-generation model.
9
+ See: https://fal.ai/models/beatoven/music-generation
10
+ """
11
+
12
+ import os
13
+
14
+ from pydantic import BaseModel, Field
15
+
16
+ from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
17
+
18
+
19
+ class BeatovenMusicGenerationInput(BaseModel):
20
+ """Input schema for beatoven music generation.
21
+
22
+ All fields use appropriate types and validation based on the Fal AI API.
23
+ """
24
+
25
+ prompt: str = Field(
26
+ description="Text description of the desired music (style, mood, instruments, tempo, etc.)"
27
+ )
28
+ duration: float = Field(
29
+ default=90,
30
+ ge=5,
31
+ le=150,
32
+ description="Duration of generated music in seconds (5-150)",
33
+ )
34
+ refinement: int = Field(
35
+ default=100,
36
+ ge=10,
37
+ le=200,
38
+ description="Quality improvement level (10-200, higher is better quality)",
39
+ )
40
+ creativity: float = Field(
41
+ default=16,
42
+ ge=1,
43
+ le=20,
44
+ description="Creative interpretation degree (1-20, higher is more creative)",
45
+ )
46
+ seed: int | None = Field(
47
+ default=None,
48
+ ge=0,
49
+ le=2147483647,
50
+ description="Seed for reproducible results (0-2147483647, null for random)",
51
+ )
52
+ negative_prompt: str = Field(
53
+ default="",
54
+ description="Elements to exclude from the generated music",
55
+ )
56
+
57
+
58
+ class FalBeatovenMusicGenerationGenerator(BaseGenerator):
59
+ """Beatoven music generation using fal.ai."""
60
+
61
+ name = "beatoven-music-generation"
62
+ artifact_type = "audio"
63
+ description = "Fal: Beatoven - generate royalty-free instrumental music from text prompts"
64
+
65
+ def get_input_schema(self) -> type[BeatovenMusicGenerationInput]:
66
+ return BeatovenMusicGenerationInput
67
+
68
+ async def generate(
69
+ self, inputs: BeatovenMusicGenerationInput, context: GeneratorExecutionContext
70
+ ) -> GeneratorResult:
71
+ """Generate music using fal.ai beatoven/music-generation model."""
72
+ # Check for API key (fal-client uses FAL_KEY environment variable)
73
+ if not os.getenv("FAL_KEY"):
74
+ raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
75
+
76
+ # Import fal_client
77
+ try:
78
+ import fal_client
79
+ except ImportError as e:
80
+ raise ImportError(
81
+ "fal.ai SDK is required for FalBeatovenMusicGenerationGenerator. "
82
+ "Install with: pip install weirdfingers-boards[generators-fal]"
83
+ ) from e
84
+
85
+ # Prepare arguments for fal.ai API
86
+ from typing import Any
87
+
88
+ arguments: dict[str, Any] = {
89
+ "prompt": inputs.prompt,
90
+ "duration": inputs.duration,
91
+ "refinement": inputs.refinement,
92
+ "creativity": inputs.creativity,
93
+ }
94
+
95
+ # Add optional parameters if provided
96
+ if inputs.seed is not None:
97
+ arguments["seed"] = inputs.seed
98
+
99
+ if inputs.negative_prompt:
100
+ arguments["negative_prompt"] = inputs.negative_prompt
101
+
102
+ # Submit async job and get handler
103
+ handler = await fal_client.submit_async(
104
+ "beatoven/music-generation",
105
+ arguments=arguments,
106
+ )
107
+
108
+ # Store the external job ID for tracking
109
+ await context.set_external_job_id(handler.request_id)
110
+
111
+ # Stream progress updates (sample every 3rd event to avoid spam)
112
+ from .....progress.models import ProgressUpdate
113
+
114
+ event_count = 0
115
+ async for event in handler.iter_events(with_logs=True):
116
+ event_count += 1
117
+
118
+ # Process every 3rd event to provide feedback without overwhelming
119
+ if event_count % 3 == 0:
120
+ # Extract logs if available
121
+ logs = getattr(event, "logs", None)
122
+ if logs:
123
+ # Join log entries into a single message
124
+ if isinstance(logs, list):
125
+ message = " | ".join(str(log) for log in logs if log)
126
+ else:
127
+ message = str(logs)
128
+
129
+ if message:
130
+ await context.publish_progress(
131
+ ProgressUpdate(
132
+ job_id=handler.request_id,
133
+ status="processing",
134
+ progress=50.0, # Approximate mid-point progress
135
+ phase="processing",
136
+ message=message,
137
+ )
138
+ )
139
+
140
+ # Get final result
141
+ result = await handler.get()
142
+
143
+ # Extract audio from result
144
+ # fal.ai returns: {"audio": {"url": "...", "content_type": "...", "file_size": ...}}
145
+ audio_data = result.get("audio")
146
+ if not audio_data:
147
+ raise ValueError("No audio returned from fal.ai API")
148
+
149
+ audio_url = audio_data.get("url")
150
+ if not audio_url:
151
+ raise ValueError("Audio missing URL in fal.ai response")
152
+
153
+ # Beatoven returns WAV format
154
+ audio_format = "wav"
155
+
156
+ # Store audio result
157
+ artifact = await context.store_audio_result(
158
+ storage_url=audio_url,
159
+ format=audio_format,
160
+ output_index=0,
161
+ )
162
+
163
+ return GeneratorResult(outputs=[artifact])
164
+
165
+ async def estimate_cost(self, inputs: BeatovenMusicGenerationInput) -> float:
166
+ """Estimate cost for beatoven music generation.
167
+
168
+ Estimated at approximately $0.05 per music generation.
169
+ Actual cost may vary based on duration and quality settings.
170
+ """
171
+ return 0.05 # $0.05 per music generation
@@ -0,0 +1,167 @@
1
+ """
2
+ fal.ai beatoven/sound-effect-generation generator.
3
+
4
+ Create professional-grade sound effects from animal and vehicle to nature, sci-fi,
5
+ and otherworldly sounds. Perfect for films, games, and digital content.
6
+
7
+ Based on Fal AI's beatoven/sound-effect-generation model.
8
+ See: https://fal.ai/models/beatoven/sound-effect-generation
9
+ """
10
+
11
+ import os
12
+
13
+ from pydantic import BaseModel, Field
14
+
15
+ from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
16
+
17
+
18
+ class BeatovenSoundEffectGenerationInput(BaseModel):
19
+ """Input schema for beatoven/sound-effect-generation.
20
+
21
+ Artifact fields are automatically detected via type introspection
22
+ and resolved from generation IDs to artifact objects.
23
+ """
24
+
25
+ prompt: str = Field(description="Describe the sound effect you want to generate")
26
+ duration: float = Field(
27
+ default=5,
28
+ ge=1,
29
+ le=35,
30
+ description="Length of the generated sound effect in seconds",
31
+ )
32
+ refinement: int = Field(
33
+ default=40,
34
+ ge=10,
35
+ le=200,
36
+ description="Refinement level - Higher values may improve quality but take longer",
37
+ )
38
+ creativity: float = Field(
39
+ default=16,
40
+ ge=1,
41
+ le=20,
42
+ description="Creativity level - higher values allow more creative interpretation",
43
+ )
44
+ negative_prompt: str = Field(
45
+ default="",
46
+ description="Describe the types of sounds you don't want to generate",
47
+ )
48
+ seed: int | None = Field(
49
+ default=None,
50
+ ge=0,
51
+ le=2147483647,
52
+ description="Random seed for reproducible results - leave empty for random generation",
53
+ )
54
+
55
+
56
+ class FalBeatovenSoundEffectGenerationGenerator(BaseGenerator):
57
+ """Generator for creating professional-grade sound effects."""
58
+
59
+ name = "fal-beatoven-sound-effect-generation"
60
+ description = (
61
+ "Fal: Beatoven Sound Effects - create professional-grade sound effects "
62
+ "for films, games, and digital content"
63
+ )
64
+ artifact_type = "audio"
65
+
66
+ def get_input_schema(self) -> type[BeatovenSoundEffectGenerationInput]:
67
+ """Return the input schema for this generator."""
68
+ return BeatovenSoundEffectGenerationInput
69
+
70
+ async def generate(
71
+ self, inputs: BeatovenSoundEffectGenerationInput, context: GeneratorExecutionContext
72
+ ) -> GeneratorResult:
73
+ """Generate audio using fal.ai beatoven/sound-effect-generation."""
74
+ # Check for API key
75
+ if not os.getenv("FAL_KEY"):
76
+ raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
77
+
78
+ # Import fal_client
79
+ try:
80
+ import fal_client
81
+ except ImportError as e:
82
+ raise ImportError(
83
+ "fal.ai SDK is required for FalBeatovenSoundEffectGenerationGenerator. "
84
+ "Install with: pip install weirdfingers-boards[generators-fal]"
85
+ ) from e
86
+
87
+ # Prepare arguments for fal.ai API
88
+ from typing import Any
89
+
90
+ arguments: dict[str, Any] = {
91
+ "prompt": inputs.prompt,
92
+ "duration": inputs.duration,
93
+ "refinement": inputs.refinement,
94
+ "creativity": inputs.creativity,
95
+ "negative_prompt": inputs.negative_prompt,
96
+ }
97
+
98
+ # Add seed if provided
99
+ if inputs.seed is not None:
100
+ arguments["seed"] = inputs.seed
101
+
102
+ # Submit async job
103
+ handler = await fal_client.submit_async(
104
+ "beatoven/sound-effect-generation",
105
+ arguments=arguments,
106
+ )
107
+
108
+ # Store external job ID
109
+ await context.set_external_job_id(handler.request_id)
110
+
111
+ # Stream progress updates
112
+ from .....progress.models import ProgressUpdate
113
+
114
+ event_count = 0
115
+ async for event in handler.iter_events(with_logs=True):
116
+ event_count += 1
117
+ # Sample every 3rd event to avoid spam
118
+ if event_count % 3 == 0:
119
+ # Extract logs if available
120
+ logs = getattr(event, "logs", None)
121
+ if logs:
122
+ # Join log entries into a single message
123
+ if isinstance(logs, list):
124
+ message = " | ".join(str(log) for log in logs if log)
125
+ else:
126
+ message = str(logs)
127
+
128
+ if message:
129
+ await context.publish_progress(
130
+ ProgressUpdate(
131
+ job_id=handler.request_id,
132
+ status="processing",
133
+ progress=50.0,
134
+ phase="processing",
135
+ message=message,
136
+ )
137
+ )
138
+
139
+ # Get final result
140
+ result = await handler.get()
141
+
142
+ # Extract audio from result
143
+ # fal.ai returns: {"audio": {"url": "...", "content_type": "...", ...}}
144
+ audio_data = result.get("audio")
145
+ if not audio_data:
146
+ raise ValueError("No audio returned from fal.ai API")
147
+
148
+ audio_url = audio_data.get("url")
149
+ if not audio_url:
150
+ raise ValueError("Audio missing URL in fal.ai response")
151
+
152
+ # Store audio result (WAV format)
153
+ artifact = await context.store_audio_result(
154
+ storage_url=audio_url,
155
+ format="wav",
156
+ output_index=0,
157
+ )
158
+
159
+ return GeneratorResult(outputs=[artifact])
160
+
161
+ async def estimate_cost(self, inputs: BeatovenSoundEffectGenerationInput) -> float:
162
+ """Estimate cost for this generation in USD.
163
+
164
+ Estimated at approximately $0.05 per sound effect generation.
165
+ Actual cost may vary based on duration and refinement settings.
166
+ """
167
+ return 0.05
@@ -0,0 +1,194 @@
1
+ """
2
+ fal.ai ElevenLabs Sound Effects V2 text-to-audio generator.
3
+
4
+ Generate sound effects from text descriptions using ElevenLabs advanced
5
+ sound effects model. Supports customizable duration, prompt influence,
6
+ and multiple output formats.
7
+
8
+ Based on Fal AI's fal-ai/elevenlabs/sound-effects/v2 model.
9
+ See: https://fal.ai/models/fal-ai/elevenlabs/sound-effects/v2
10
+ """
11
+
12
+ import os
13
+ from typing import Literal
14
+
15
+ from pydantic import BaseModel, Field
16
+
17
+ from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
18
+
19
+
20
+ class ElevenlabsSoundEffectsV2Input(BaseModel):
21
+ """Input schema for ElevenLabs Sound Effects V2 generation.
22
+
23
+ Generates custom sound effects from natural language descriptions with
24
+ configurable duration, prompt influence, and output format.
25
+ """
26
+
27
+ text: str = Field(
28
+ description="Text describing the sound effect to generate",
29
+ examples=[
30
+ "Spacious braam suitable for high-impact movie trailer moments",
31
+ "A gentle wind chime tinkling in a soft breeze",
32
+ ],
33
+ )
34
+ duration_seconds: float | None = Field(
35
+ default=None,
36
+ ge=0.5,
37
+ le=22.0,
38
+ description=(
39
+ "Duration in seconds (0.5-22). "
40
+ "If None, optimal duration will be determined from prompt."
41
+ ),
42
+ )
43
+ prompt_influence: float = Field(
44
+ default=0.3,
45
+ ge=0.0,
46
+ le=1.0,
47
+ description="How closely to follow the prompt (0-1). Higher values mean less variation.",
48
+ )
49
+ output_format: Literal[
50
+ "mp3_22050_32",
51
+ "mp3_44100_32",
52
+ "mp3_44100_64",
53
+ "mp3_44100_96",
54
+ "mp3_44100_128",
55
+ "mp3_44100_192",
56
+ "pcm_8000",
57
+ "pcm_16000",
58
+ "pcm_22050",
59
+ "pcm_24000",
60
+ "pcm_44100",
61
+ "pcm_48000",
62
+ "ulaw_8000",
63
+ "alaw_8000",
64
+ "opus_48000_32",
65
+ "opus_48000_64",
66
+ "opus_48000_96",
67
+ "opus_48000_128",
68
+ "opus_48000_192",
69
+ ] = Field(
70
+ default="mp3_44100_128",
71
+ description=(
72
+ "Output format of the generated audio. Formatted as codec_sample_rate_bitrate."
73
+ ),
74
+ )
75
+ loop: bool = Field(
76
+ default=False,
77
+ description="Whether to create a sound effect that loops smoothly.",
78
+ )
79
+
80
+
81
+ class FalElevenlabsSoundEffectsV2Generator(BaseGenerator):
82
+ """ElevenLabs Sound Effects V2 text-to-audio generator using fal.ai."""
83
+
84
+ name = "fal-elevenlabs-sound-effects-v2"
85
+ artifact_type = "audio"
86
+ description = (
87
+ "Fal: ElevenLabs Sound Effects V2 - "
88
+ "Generate custom sound effects from text descriptions with advanced AI"
89
+ )
90
+
91
+ def get_input_schema(self) -> type[ElevenlabsSoundEffectsV2Input]:
92
+ return ElevenlabsSoundEffectsV2Input
93
+
94
+ async def generate(
95
+ self, inputs: ElevenlabsSoundEffectsV2Input, context: GeneratorExecutionContext
96
+ ) -> GeneratorResult:
97
+ """Generate sound effect using fal.ai ElevenLabs Sound Effects V2 model."""
98
+ # Check for API key (fal-client uses FAL_KEY environment variable)
99
+ if not os.getenv("FAL_KEY"):
100
+ raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
101
+
102
+ # Import fal_client
103
+ try:
104
+ import fal_client
105
+ except ImportError as e:
106
+ raise ImportError(
107
+ "fal.ai SDK is required for FalElevenlabsSoundEffectsV2Generator. "
108
+ "Install with: pip install weirdfingers-boards[generators-fal]"
109
+ ) from e
110
+
111
+ # Prepare arguments for fal.ai API
112
+ arguments = {
113
+ "text": inputs.text,
114
+ "prompt_influence": inputs.prompt_influence,
115
+ "output_format": inputs.output_format,
116
+ "loop": inputs.loop,
117
+ }
118
+
119
+ # Only include duration_seconds if specified
120
+ if inputs.duration_seconds is not None:
121
+ arguments["duration_seconds"] = inputs.duration_seconds
122
+
123
+ # Submit async job and get handler
124
+ handler = await fal_client.submit_async(
125
+ "fal-ai/elevenlabs/sound-effects/v2",
126
+ arguments=arguments,
127
+ )
128
+
129
+ # Store the external job ID for tracking
130
+ await context.set_external_job_id(handler.request_id)
131
+
132
+ # Stream progress updates (sample every 3rd event to avoid spam)
133
+ from .....progress.models import ProgressUpdate
134
+
135
+ event_count = 0
136
+ async for event in handler.iter_events(with_logs=True):
137
+ event_count += 1
138
+
139
+ # Process every 3rd event to provide feedback without overwhelming
140
+ if event_count % 3 == 0:
141
+ # Extract logs if available
142
+ logs = getattr(event, "logs", None)
143
+ if logs:
144
+ # Join log entries into a single message
145
+ if isinstance(logs, list):
146
+ message = " | ".join(str(log) for log in logs if log)
147
+ else:
148
+ message = str(logs)
149
+
150
+ if message:
151
+ await context.publish_progress(
152
+ ProgressUpdate(
153
+ job_id=handler.request_id,
154
+ status="processing",
155
+ progress=50.0, # Approximate mid-point progress
156
+ phase="processing",
157
+ message=message,
158
+ )
159
+ )
160
+
161
+ # Get final result
162
+ result = await handler.get()
163
+
164
+ # Extract audio URL from result
165
+ # fal.ai returns: {"audio": {"url": "...", "content_type": "...", ...}}
166
+ audio_data = result.get("audio")
167
+ if audio_data is None:
168
+ raise ValueError("No audio data returned from fal.ai API")
169
+
170
+ audio_url = audio_data.get("url")
171
+ if not audio_url:
172
+ raise ValueError("Audio URL missing in fal.ai response")
173
+
174
+ # Extract format from output_format (e.g., "mp3_44100_128" -> "mp3")
175
+ format_parts = inputs.output_format.split("_")
176
+ audio_format = format_parts[0] if format_parts else "mp3"
177
+
178
+ # Store audio result
179
+ artifact = await context.store_audio_result(
180
+ storage_url=audio_url,
181
+ format=audio_format,
182
+ output_index=0,
183
+ )
184
+
185
+ return GeneratorResult(outputs=[artifact])
186
+
187
+ async def estimate_cost(self, inputs: ElevenlabsSoundEffectsV2Input) -> float:
188
+ """Estimate cost for ElevenLabs Sound Effects V2 generation.
189
+
190
+ Based on typical ElevenLabs sound effects pricing.
191
+ Cost is approximately $0.055 per sound effect generation.
192
+ """
193
+ # Fixed cost per generation regardless of duration or format
194
+ return 0.055