@weirdfingers/baseboards 0.9.6 → 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.
Files changed (237) hide show
  1. package/dist/index.js +560 -469
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -5
  4. package/templates/README.md +0 -122
  5. package/templates/api/.env.example +0 -65
  6. package/templates/api/ARTIFACT_RESOLUTION_GUIDE.md +0 -148
  7. package/templates/api/Dockerfile +0 -32
  8. package/templates/api/README.md +0 -264
  9. package/templates/api/alembic/env.py +0 -114
  10. package/templates/api/alembic/script.py.mako +0 -28
  11. package/templates/api/alembic/versions/20250101_000000_initial_schema.py +0 -506
  12. package/templates/api/alembic/versions/20251022_174729_remove_provider_name_from_generations.py +0 -75
  13. package/templates/api/alembic/versions/20251023_165852_switch_to_declarative_base_and_mapping.py +0 -467
  14. package/templates/api/alembic/versions/20251202_000000_add_artifact_lineage.py +0 -134
  15. package/templates/api/alembic/versions/2025925_62735_add_seed_data_for_default_tenant.py +0 -88
  16. package/templates/api/alembic.ini +0 -36
  17. package/templates/api/config/generators.yaml +0 -237
  18. package/templates/api/config/storage_config.yaml +0 -26
  19. package/templates/api/docs/ADDING_GENERATORS.md +0 -409
  20. package/templates/api/docs/GENERATORS_API.md +0 -502
  21. package/templates/api/docs/MIGRATIONS.md +0 -472
  22. package/templates/api/docs/TESTING_LIVE_APIS.md +0 -417
  23. package/templates/api/docs/storage_providers.md +0 -337
  24. package/templates/api/pyproject.toml +0 -205
  25. package/templates/api/src/boards/__init__.py +0 -10
  26. package/templates/api/src/boards/api/app.py +0 -172
  27. package/templates/api/src/boards/api/auth.py +0 -75
  28. package/templates/api/src/boards/api/endpoints/__init__.py +0 -3
  29. package/templates/api/src/boards/api/endpoints/jobs.py +0 -76
  30. package/templates/api/src/boards/api/endpoints/setup.py +0 -505
  31. package/templates/api/src/boards/api/endpoints/sse.py +0 -129
  32. package/templates/api/src/boards/api/endpoints/storage.py +0 -155
  33. package/templates/api/src/boards/api/endpoints/tenant_registration.py +0 -296
  34. package/templates/api/src/boards/api/endpoints/uploads.py +0 -149
  35. package/templates/api/src/boards/api/endpoints/webhooks.py +0 -13
  36. package/templates/api/src/boards/auth/__init__.py +0 -15
  37. package/templates/api/src/boards/auth/adapters/__init__.py +0 -27
  38. package/templates/api/src/boards/auth/adapters/auth0.py +0 -220
  39. package/templates/api/src/boards/auth/adapters/base.py +0 -73
  40. package/templates/api/src/boards/auth/adapters/clerk.py +0 -172
  41. package/templates/api/src/boards/auth/adapters/jwt.py +0 -122
  42. package/templates/api/src/boards/auth/adapters/none.py +0 -102
  43. package/templates/api/src/boards/auth/adapters/oidc.py +0 -284
  44. package/templates/api/src/boards/auth/adapters/supabase.py +0 -110
  45. package/templates/api/src/boards/auth/context.py +0 -35
  46. package/templates/api/src/boards/auth/factory.py +0 -129
  47. package/templates/api/src/boards/auth/middleware.py +0 -221
  48. package/templates/api/src/boards/auth/provisioning.py +0 -129
  49. package/templates/api/src/boards/auth/tenant_extraction.py +0 -278
  50. package/templates/api/src/boards/cli.py +0 -354
  51. package/templates/api/src/boards/config.py +0 -131
  52. package/templates/api/src/boards/database/__init__.py +0 -7
  53. package/templates/api/src/boards/database/cli.py +0 -110
  54. package/templates/api/src/boards/database/connection.py +0 -292
  55. package/templates/api/src/boards/database/models.py +0 -19
  56. package/templates/api/src/boards/database/seed_data.py +0 -182
  57. package/templates/api/src/boards/dbmodels/__init__.py +0 -441
  58. package/templates/api/src/boards/generators/__init__.py +0 -57
  59. package/templates/api/src/boards/generators/artifact_resolution.py +0 -405
  60. package/templates/api/src/boards/generators/artifacts.py +0 -53
  61. package/templates/api/src/boards/generators/base.py +0 -144
  62. package/templates/api/src/boards/generators/implementations/__init__.py +0 -14
  63. package/templates/api/src/boards/generators/implementations/fal/__init__.py +0 -25
  64. package/templates/api/src/boards/generators/implementations/fal/audio/__init__.py +0 -23
  65. package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_music_generation.py +0 -171
  66. package/templates/api/src/boards/generators/implementations/fal/audio/beatoven_sound_effect_generation.py +0 -167
  67. package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_text_to_speech.py +0 -176
  68. package/templates/api/src/boards/generators/implementations/fal/audio/chatterbox_tts_turbo.py +0 -195
  69. package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_sound_effects_v2.py +0 -194
  70. package/templates/api/src/boards/generators/implementations/fal/audio/elevenlabs_tts_eleven_v3.py +0 -209
  71. package/templates/api/src/boards/generators/implementations/fal/audio/fal_elevenlabs_tts_turbo_v2_5.py +0 -206
  72. package/templates/api/src/boards/generators/implementations/fal/audio/fal_minimax_speech_26_hd.py +0 -237
  73. package/templates/api/src/boards/generators/implementations/fal/audio/minimax_music_v2.py +0 -173
  74. package/templates/api/src/boards/generators/implementations/fal/audio/minimax_speech_2_6_turbo.py +0 -221
  75. package/templates/api/src/boards/generators/implementations/fal/image/__init__.py +0 -63
  76. package/templates/api/src/boards/generators/implementations/fal/image/bytedance_seedream_v45_edit.py +0 -219
  77. package/templates/api/src/boards/generators/implementations/fal/image/clarity_upscaler.py +0 -220
  78. package/templates/api/src/boards/generators/implementations/fal/image/crystal_upscaler.py +0 -173
  79. package/templates/api/src/boards/generators/implementations/fal/image/fal_ideogram_character.py +0 -227
  80. package/templates/api/src/boards/generators/implementations/fal/image/flux_2.py +0 -203
  81. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_edit.py +0 -230
  82. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro.py +0 -204
  83. package/templates/api/src/boards/generators/implementations/fal/image/flux_2_pro_edit.py +0 -221
  84. package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_kontext.py +0 -216
  85. package/templates/api/src/boards/generators/implementations/fal/image/flux_pro_ultra.py +0 -197
  86. package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image.py +0 -177
  87. package/templates/api/src/boards/generators/implementations/fal/image/gemini_25_flash_image_edit.py +0 -208
  88. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_15_edit.py +0 -216
  89. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_5.py +0 -177
  90. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_edit_image.py +0 -182
  91. package/templates/api/src/boards/generators/implementations/fal/image/gpt_image_1_mini.py +0 -167
  92. package/templates/api/src/boards/generators/implementations/fal/image/ideogram_character_edit.py +0 -299
  93. package/templates/api/src/boards/generators/implementations/fal/image/ideogram_v2.py +0 -190
  94. package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview.py +0 -191
  95. package/templates/api/src/boards/generators/implementations/fal/image/imagen4_preview_fast.py +0 -179
  96. package/templates/api/src/boards/generators/implementations/fal/image/nano_banana.py +0 -183
  97. package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_edit.py +0 -212
  98. package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro.py +0 -179
  99. package/templates/api/src/boards/generators/implementations/fal/image/nano_banana_pro_edit.py +0 -226
  100. package/templates/api/src/boards/generators/implementations/fal/image/qwen_image.py +0 -249
  101. package/templates/api/src/boards/generators/implementations/fal/image/qwen_image_edit.py +0 -244
  102. package/templates/api/src/boards/generators/implementations/fal/image/reve_edit.py +0 -178
  103. package/templates/api/src/boards/generators/implementations/fal/image/reve_text_to_image.py +0 -155
  104. package/templates/api/src/boards/generators/implementations/fal/image/seedream_v45_text_to_image.py +0 -180
  105. package/templates/api/src/boards/generators/implementations/fal/utils.py +0 -61
  106. package/templates/api/src/boards/generators/implementations/fal/video/__init__.py +0 -77
  107. package/templates/api/src/boards/generators/implementations/fal/video/bytedance_seedance_v1_pro_text_to_video.py +0 -209
  108. package/templates/api/src/boards/generators/implementations/fal/video/creatify_lipsync.py +0 -161
  109. package/templates/api/src/boards/generators/implementations/fal/video/fal_bytedance_seedance_v1_pro_image_to_video.py +0 -222
  110. package/templates/api/src/boards/generators/implementations/fal/video/fal_minimax_hailuo_02_standard_text_to_video.py +0 -152
  111. package/templates/api/src/boards/generators/implementations/fal/video/fal_pixverse_lipsync.py +0 -197
  112. package/templates/api/src/boards/generators/implementations/fal/video/fal_sora_2_text_to_video.py +0 -173
  113. package/templates/api/src/boards/generators/implementations/fal/video/infinitalk.py +0 -221
  114. package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_pro.py +0 -168
  115. package/templates/api/src/boards/generators/implementations/fal/video/kling_video_ai_avatar_v2_standard.py +0 -159
  116. package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_image_to_video.py +0 -175
  117. package/templates/api/src/boards/generators/implementations/fal/video/kling_video_v2_5_turbo_pro_text_to_video.py +0 -168
  118. package/templates/api/src/boards/generators/implementations/fal/video/minimax_hailuo_2_3_pro_image_to_video.py +0 -153
  119. package/templates/api/src/boards/generators/implementations/fal/video/sora2_image_to_video.py +0 -172
  120. package/templates/api/src/boards/generators/implementations/fal/video/sora_2_image_to_video_pro.py +0 -175
  121. package/templates/api/src/boards/generators/implementations/fal/video/sora_2_text_to_video_pro.py +0 -163
  122. package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2.py +0 -167
  123. package/templates/api/src/boards/generators/implementations/fal/video/sync_lipsync_v2_pro.py +0 -155
  124. package/templates/api/src/boards/generators/implementations/fal/video/veed_fabric_1_0.py +0 -180
  125. package/templates/api/src/boards/generators/implementations/fal/video/veed_lipsync.py +0 -174
  126. package/templates/api/src/boards/generators/implementations/fal/video/veo3.py +0 -194
  127. package/templates/api/src/boards/generators/implementations/fal/video/veo31.py +0 -190
  128. package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast.py +0 -190
  129. package/templates/api/src/boards/generators/implementations/fal/video/veo31_fast_image_to_video.py +0 -191
  130. package/templates/api/src/boards/generators/implementations/fal/video/veo31_first_last_frame_to_video.py +0 -187
  131. package/templates/api/src/boards/generators/implementations/fal/video/veo31_image_to_video.py +0 -183
  132. package/templates/api/src/boards/generators/implementations/fal/video/veo31_reference_to_video.py +0 -172
  133. package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_image_to_video.py +0 -212
  134. package/templates/api/src/boards/generators/implementations/fal/video/wan_25_preview_text_to_video.py +0 -208
  135. package/templates/api/src/boards/generators/implementations/fal/video/wan_pro_image_to_video.py +0 -158
  136. package/templates/api/src/boards/generators/implementations/kie/__init__.py +0 -11
  137. package/templates/api/src/boards/generators/implementations/kie/base.py +0 -316
  138. package/templates/api/src/boards/generators/implementations/kie/image/__init__.py +0 -3
  139. package/templates/api/src/boards/generators/implementations/kie/image/nano_banana_edit.py +0 -190
  140. package/templates/api/src/boards/generators/implementations/kie/utils.py +0 -98
  141. package/templates/api/src/boards/generators/implementations/kie/video/__init__.py +0 -8
  142. package/templates/api/src/boards/generators/implementations/kie/video/veo3.py +0 -161
  143. package/templates/api/src/boards/generators/implementations/openai/__init__.py +0 -1
  144. package/templates/api/src/boards/generators/implementations/openai/audio/__init__.py +0 -1
  145. package/templates/api/src/boards/generators/implementations/openai/audio/whisper.py +0 -69
  146. package/templates/api/src/boards/generators/implementations/openai/image/__init__.py +0 -1
  147. package/templates/api/src/boards/generators/implementations/openai/image/dalle3.py +0 -96
  148. package/templates/api/src/boards/generators/implementations/replicate/__init__.py +0 -1
  149. package/templates/api/src/boards/generators/implementations/replicate/image/__init__.py +0 -1
  150. package/templates/api/src/boards/generators/implementations/replicate/image/flux_pro.py +0 -88
  151. package/templates/api/src/boards/generators/implementations/replicate/video/__init__.py +0 -1
  152. package/templates/api/src/boards/generators/implementations/replicate/video/lipsync.py +0 -73
  153. package/templates/api/src/boards/generators/loader.py +0 -253
  154. package/templates/api/src/boards/generators/registry.py +0 -114
  155. package/templates/api/src/boards/generators/resolution.py +0 -632
  156. package/templates/api/src/boards/generators/testmods/class_gen.py +0 -34
  157. package/templates/api/src/boards/generators/testmods/import_side_effect.py +0 -35
  158. package/templates/api/src/boards/graphql/__init__.py +0 -7
  159. package/templates/api/src/boards/graphql/access_control.py +0 -136
  160. package/templates/api/src/boards/graphql/mutations/root.py +0 -148
  161. package/templates/api/src/boards/graphql/queries/root.py +0 -116
  162. package/templates/api/src/boards/graphql/resolvers/__init__.py +0 -8
  163. package/templates/api/src/boards/graphql/resolvers/auth.py +0 -12
  164. package/templates/api/src/boards/graphql/resolvers/board.py +0 -1053
  165. package/templates/api/src/boards/graphql/resolvers/generation.py +0 -666
  166. package/templates/api/src/boards/graphql/resolvers/generator.py +0 -50
  167. package/templates/api/src/boards/graphql/resolvers/lineage.py +0 -381
  168. package/templates/api/src/boards/graphql/resolvers/upload.py +0 -463
  169. package/templates/api/src/boards/graphql/resolvers/user.py +0 -25
  170. package/templates/api/src/boards/graphql/schema.py +0 -81
  171. package/templates/api/src/boards/graphql/types/board.py +0 -102
  172. package/templates/api/src/boards/graphql/types/generation.py +0 -166
  173. package/templates/api/src/boards/graphql/types/generator.py +0 -17
  174. package/templates/api/src/boards/graphql/types/user.py +0 -47
  175. package/templates/api/src/boards/jobs/repository.py +0 -153
  176. package/templates/api/src/boards/logging.py +0 -195
  177. package/templates/api/src/boards/middleware.py +0 -339
  178. package/templates/api/src/boards/progress/__init__.py +0 -4
  179. package/templates/api/src/boards/progress/models.py +0 -25
  180. package/templates/api/src/boards/progress/publisher.py +0 -64
  181. package/templates/api/src/boards/py.typed +0 -0
  182. package/templates/api/src/boards/redis_pool.py +0 -118
  183. package/templates/api/src/boards/storage/__init__.py +0 -52
  184. package/templates/api/src/boards/storage/base.py +0 -363
  185. package/templates/api/src/boards/storage/config.py +0 -187
  186. package/templates/api/src/boards/storage/factory.py +0 -288
  187. package/templates/api/src/boards/storage/implementations/__init__.py +0 -27
  188. package/templates/api/src/boards/storage/implementations/gcs.py +0 -340
  189. package/templates/api/src/boards/storage/implementations/local.py +0 -201
  190. package/templates/api/src/boards/storage/implementations/s3.py +0 -294
  191. package/templates/api/src/boards/storage/implementations/supabase.py +0 -218
  192. package/templates/api/src/boards/tenant_isolation.py +0 -446
  193. package/templates/api/src/boards/validation.py +0 -262
  194. package/templates/api/src/boards/workers/__init__.py +0 -1
  195. package/templates/api/src/boards/workers/actors.py +0 -274
  196. package/templates/api/src/boards/workers/cli.py +0 -125
  197. package/templates/api/src/boards/workers/context.py +0 -348
  198. package/templates/api/src/boards/workers/middleware.py +0 -58
  199. package/templates/api/src/py.typed +0 -0
  200. package/templates/compose.web.yaml +0 -35
  201. package/templates/compose.yaml +0 -116
  202. package/templates/docker/env.example +0 -23
  203. package/templates/web/.env.example +0 -28
  204. package/templates/web/Dockerfile +0 -51
  205. package/templates/web/components.json +0 -22
  206. package/templates/web/imageLoader.js +0 -18
  207. package/templates/web/next-env.d.ts +0 -5
  208. package/templates/web/next.config.js +0 -36
  209. package/templates/web/package.json +0 -41
  210. package/templates/web/postcss.config.mjs +0 -7
  211. package/templates/web/public/favicon.ico +0 -0
  212. package/templates/web/src/app/boards/[boardId]/page.tsx +0 -353
  213. package/templates/web/src/app/globals.css +0 -123
  214. package/templates/web/src/app/layout.tsx +0 -31
  215. package/templates/web/src/app/lineage/[generationId]/page.tsx +0 -235
  216. package/templates/web/src/app/page.tsx +0 -35
  217. package/templates/web/src/app/providers.tsx +0 -18
  218. package/templates/web/src/components/boards/ArtifactInputSlots.tsx +0 -206
  219. package/templates/web/src/components/boards/ArtifactPreview.tsx +0 -466
  220. package/templates/web/src/components/boards/GenerationGrid.tsx +0 -282
  221. package/templates/web/src/components/boards/GenerationInput.tsx +0 -370
  222. package/templates/web/src/components/boards/GeneratorSelector.tsx +0 -272
  223. package/templates/web/src/components/boards/UploadArtifact.tsx +0 -563
  224. package/templates/web/src/components/header.tsx +0 -32
  225. package/templates/web/src/components/theme-provider.tsx +0 -10
  226. package/templates/web/src/components/theme-toggle.tsx +0 -75
  227. package/templates/web/src/components/ui/alert-dialog.tsx +0 -157
  228. package/templates/web/src/components/ui/button.tsx +0 -58
  229. package/templates/web/src/components/ui/card.tsx +0 -92
  230. package/templates/web/src/components/ui/dropdown-menu.tsx +0 -200
  231. package/templates/web/src/components/ui/navigation-menu.tsx +0 -168
  232. package/templates/web/src/components/ui/toast.tsx +0 -128
  233. package/templates/web/src/components/ui/toaster.tsx +0 -35
  234. package/templates/web/src/components/ui/use-toast.ts +0 -187
  235. package/templates/web/src/hooks/useGeneratorMRU.ts +0 -57
  236. package/templates/web/src/lib/utils.ts +0 -6
  237. package/templates/web/tsconfig.json +0 -41
@@ -1,179 +0,0 @@
1
- """
2
- fal.ai nano-banana-pro text-to-image generator.
3
-
4
- State-of-the-art image generation using Google's latest model, specializing in
5
- realism and typography applications.
6
-
7
- See: https://fal.ai/models/fal-ai/nano-banana-pro
8
- """
9
-
10
- import os
11
- from typing import Literal
12
-
13
- from pydantic import BaseModel, Field
14
-
15
- from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
16
-
17
-
18
- class NanoBananaProInput(BaseModel):
19
- """Input schema for nano-banana-pro image generation."""
20
-
21
- prompt: str = Field(
22
- min_length=3,
23
- max_length=50000,
24
- description="The text prompt to generate an image from",
25
- )
26
- aspect_ratio: Literal[
27
- "21:9",
28
- "16:9",
29
- "3:2",
30
- "4:3",
31
- "5:4",
32
- "1:1",
33
- "4:5",
34
- "3:4",
35
- "2:3",
36
- "9:16",
37
- ] = Field(
38
- default="1:1",
39
- description="Image aspect ratio",
40
- )
41
- num_images: int = Field(
42
- default=1,
43
- ge=1,
44
- le=4,
45
- description="Number of images to generate in batch",
46
- )
47
- resolution: Literal["1K", "2K", "4K"] = Field(
48
- default="1K",
49
- description="Image resolution (1K, 2K, or 4K)",
50
- )
51
- output_format: Literal["jpeg", "png", "webp"] = Field(
52
- default="png",
53
- description="Output image format",
54
- )
55
- sync_mode: bool = Field(
56
- default=True,
57
- description="Use synchronous mode (wait for completion)",
58
- )
59
-
60
-
61
- class FalNanoBananaProGenerator(BaseGenerator):
62
- """nano-banana-pro image generator using fal.ai.
63
-
64
- Google's state-of-the-art image generation and editing model, specializing
65
- in realism and typography applications.
66
- """
67
-
68
- name = "fal-nano-banana-pro"
69
- artifact_type = "image"
70
- description = (
71
- "Fal: nano-banana-pro - Google's state-of-the-art image generation "
72
- "with excellent realism and typography"
73
- )
74
-
75
- def get_input_schema(self) -> type[NanoBananaProInput]:
76
- return NanoBananaProInput
77
-
78
- async def generate(
79
- self, inputs: NanoBananaProInput, context: GeneratorExecutionContext
80
- ) -> GeneratorResult:
81
- """Generate images using fal.ai nano-banana-pro model."""
82
- # Check for API key (fal-client uses FAL_KEY environment variable)
83
- if not os.getenv("FAL_KEY"):
84
- raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
85
-
86
- # Import fal_client
87
- try:
88
- import fal_client
89
- except ImportError as e:
90
- raise ImportError(
91
- "fal.ai SDK is required for NanoBananaProGenerator. "
92
- "Install with: pip install weirdfingers-boards[generators-fal]"
93
- ) from e
94
-
95
- # Prepare arguments for fal.ai API
96
- arguments = {
97
- "prompt": inputs.prompt,
98
- "aspect_ratio": inputs.aspect_ratio,
99
- "num_images": inputs.num_images,
100
- "resolution": inputs.resolution,
101
- "output_format": inputs.output_format,
102
- "sync_mode": inputs.sync_mode,
103
- }
104
-
105
- # Submit async job and get handler
106
- handler = await fal_client.submit_async(
107
- "fal-ai/nano-banana-pro",
108
- arguments=arguments,
109
- )
110
-
111
- # Store the external job ID for tracking
112
- await context.set_external_job_id(handler.request_id)
113
-
114
- # Stream progress updates (sample every 3rd event to avoid spam)
115
- from .....progress.models import ProgressUpdate
116
-
117
- event_count = 0
118
- async for event in handler.iter_events(with_logs=True):
119
- event_count += 1
120
-
121
- # Process every 3rd event to provide feedback without overwhelming
122
- if event_count % 3 == 0:
123
- # Extract logs if available
124
- logs = getattr(event, "logs", None)
125
- if logs:
126
- # Join log entries into a single message
127
- if isinstance(logs, list):
128
- message = " | ".join(str(log) for log in logs if log)
129
- else:
130
- message = str(logs)
131
-
132
- if message:
133
- await context.publish_progress(
134
- ProgressUpdate(
135
- job_id=handler.request_id,
136
- status="processing",
137
- progress=50.0, # Approximate mid-point progress
138
- phase="processing",
139
- message=message,
140
- )
141
- )
142
-
143
- # Get final result
144
- result = await handler.get()
145
-
146
- # Extract image URLs from result
147
- # fal.ai returns: {"images": [{"url": "...", "width": ..., "height": ...}, ...]}
148
- images = result.get("images", [])
149
- if not images:
150
- raise ValueError("No images returned from fal.ai API")
151
-
152
- # Store each image using output_index
153
- artifacts = []
154
- for idx, image_data in enumerate(images):
155
- image_url = image_data.get("url")
156
- width = image_data.get("width")
157
- height = image_data.get("height")
158
-
159
- if not image_url:
160
- raise ValueError(f"Image {idx} missing URL in fal.ai response")
161
-
162
- # Store with appropriate output_index
163
- artifact = await context.store_image_result(
164
- storage_url=image_url,
165
- format=inputs.output_format,
166
- width=width,
167
- height=height,
168
- output_index=idx,
169
- )
170
- artifacts.append(artifact)
171
-
172
- return GeneratorResult(outputs=artifacts)
173
-
174
- async def estimate_cost(self, inputs: NanoBananaProInput) -> float:
175
- """Estimate cost for nano-banana-pro generation.
176
-
177
- nano-banana-pro is a premium model costing approximately $0.039 per image.
178
- """
179
- return 0.039 * inputs.num_images # $0.039 per image, scaled by batch size
@@ -1,226 +0,0 @@
1
- """
2
- fal.ai nano-banana-pro image editing generator.
3
-
4
- Edit images using fal.ai's nano-banana-pro/edit model (powered by Google's latest
5
- image generation and editing model). Specializes in realism and typography.
6
-
7
- See: https://fal.ai/models/fal-ai/nano-banana-pro/edit
8
- """
9
-
10
- import os
11
- from typing import Literal
12
-
13
- from pydantic import BaseModel, Field
14
-
15
- from ....artifacts import ImageArtifact
16
- from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
17
-
18
-
19
- class NanoBananaProEditInput(BaseModel):
20
- """Input schema for nano-banana-pro image editing.
21
-
22
- Artifact fields (like image_sources) are automatically detected via type
23
- introspection and resolved from generation IDs to ImageArtifact objects.
24
- """
25
-
26
- prompt: str = Field(
27
- min_length=3,
28
- max_length=50000,
29
- description="The prompt for image editing",
30
- )
31
- image_sources: list[ImageArtifact] = Field(
32
- description="List of input images for editing (from previous generations)",
33
- min_length=1,
34
- )
35
- num_images: int = Field(
36
- default=1,
37
- ge=1,
38
- le=4,
39
- description="Number of images to generate",
40
- )
41
- aspect_ratio: Literal[
42
- "auto",
43
- "21:9",
44
- "16:9",
45
- "3:2",
46
- "4:3",
47
- "5:4",
48
- "1:1",
49
- "4:5",
50
- "3:4",
51
- "2:3",
52
- "9:16",
53
- ] = Field(
54
- default="auto",
55
- description=(
56
- "Aspect ratio for generated images. Default is 'auto', which takes one "
57
- "of the input images' aspect ratio"
58
- ),
59
- )
60
- resolution: Literal["1K", "2K", "4K"] = Field(
61
- default="1K",
62
- description="Image resolution (1K, 2K, or 4K)",
63
- )
64
- output_format: Literal["jpeg", "png", "webp"] = Field(
65
- default="png",
66
- description="Output image format",
67
- )
68
- sync_mode: bool = Field(
69
- default=False,
70
- description=(
71
- "If True, the media will be returned as a data URI and the output "
72
- "data won't be available in the request history"
73
- ),
74
- )
75
- enable_web_search: bool = Field(
76
- default=False,
77
- description="Enable web search for generating images with current information",
78
- )
79
- limit_generations: bool = Field(
80
- default=False,
81
- description=(
82
- "Experimental parameter to limit the number of generations from each "
83
- "round of prompting to 1. Set to True to disregard any instructions in "
84
- "the prompt regarding the number of images to generate"
85
- ),
86
- )
87
-
88
-
89
- class FalNanoBananaProEditGenerator(BaseGenerator):
90
- """nano-banana-pro image editing generator using fal.ai.
91
-
92
- Google's state-of-the-art image generation and editing model, specializing
93
- in realism and typography applications.
94
- """
95
-
96
- name = "fal-nano-banana-pro-edit"
97
- artifact_type = "image"
98
- description = (
99
- "Fal: nano-banana-pro edit - Google's state-of-the-art image editing "
100
- "with excellent realism and typography"
101
- )
102
-
103
- def get_input_schema(self) -> type[NanoBananaProEditInput]:
104
- return NanoBananaProEditInput
105
-
106
- async def generate(
107
- self, inputs: NanoBananaProEditInput, context: GeneratorExecutionContext
108
- ) -> GeneratorResult:
109
- """Edit images using fal.ai nano-banana-pro/edit model."""
110
- # Check for API key (fal-client uses FAL_KEY environment variable)
111
- if not os.getenv("FAL_KEY"):
112
- raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
113
-
114
- # Import fal_client
115
- try:
116
- import fal_client
117
- except ImportError as e:
118
- raise ImportError(
119
- "fal.ai SDK is required for FalNanoBananaProEditGenerator. "
120
- "Install with: pip install weirdfingers-boards[generators-fal]"
121
- ) from e
122
-
123
- # Upload image artifacts to Fal's public storage
124
- # Fal API requires publicly accessible URLs, but our storage_url might be:
125
- # - Localhost URLs (not publicly accessible)
126
- # - Private S3 buckets (not publicly accessible)
127
- # So we upload to Fal's temporary storage first
128
- from ..utils import upload_artifacts_to_fal
129
-
130
- image_urls = await upload_artifacts_to_fal(inputs.image_sources, context)
131
-
132
- # Prepare arguments for fal.ai API
133
- arguments = {
134
- "prompt": inputs.prompt,
135
- "image_urls": image_urls,
136
- "num_images": inputs.num_images,
137
- "aspect_ratio": inputs.aspect_ratio,
138
- "resolution": inputs.resolution,
139
- "output_format": inputs.output_format,
140
- "sync_mode": inputs.sync_mode,
141
- "enable_web_search": inputs.enable_web_search,
142
- "limit_generations": inputs.limit_generations,
143
- }
144
-
145
- # Submit async job and get handler
146
- handler = await fal_client.submit_async(
147
- "fal-ai/nano-banana-pro/edit",
148
- arguments=arguments,
149
- )
150
-
151
- # Store the external job ID for tracking
152
- await context.set_external_job_id(handler.request_id)
153
-
154
- # Stream progress updates (sample every 3rd event to avoid spam)
155
- from .....progress.models import ProgressUpdate
156
-
157
- event_count = 0
158
- async for event in handler.iter_events(with_logs=True):
159
- event_count += 1
160
-
161
- # Process every 3rd event to provide feedback without overwhelming
162
- if event_count % 3 == 0:
163
- # Extract logs if available
164
- logs = getattr(event, "logs", None)
165
- if logs:
166
- # Join log entries into a single message
167
- if isinstance(logs, list):
168
- message = " | ".join(str(log) for log in logs if log)
169
- else:
170
- message = str(logs)
171
-
172
- if message:
173
- await context.publish_progress(
174
- ProgressUpdate(
175
- job_id=handler.request_id,
176
- status="processing",
177
- progress=50.0, # Approximate mid-point progress
178
- phase="processing",
179
- message=message,
180
- )
181
- )
182
-
183
- # Get final result
184
- result = await handler.get()
185
-
186
- # Extract image URLs and description from result
187
- # fal.ai returns: {
188
- # "images": [{"url": "...", "width": ..., "height": ...}, ...],
189
- # "description": "Text description from the model"
190
- # }
191
- images = result.get("images", [])
192
-
193
- if not images:
194
- raise ValueError("No images returned from fal.ai API")
195
-
196
- # Store each image using output_index
197
- artifacts = []
198
- for idx, image_data in enumerate(images):
199
- image_url = image_data.get("url")
200
- # Extract dimensions if available, otherwise use sensible defaults
201
- width = image_data.get("width", 1024)
202
- height = image_data.get("height", 1024)
203
-
204
- if not image_url:
205
- raise ValueError(f"Image {idx} missing URL in fal.ai response")
206
-
207
- # Store with appropriate output_index
208
- artifact = await context.store_image_result(
209
- storage_url=image_url,
210
- format=inputs.output_format,
211
- width=width,
212
- height=height,
213
- output_index=idx,
214
- )
215
- artifacts.append(artifact)
216
-
217
- return GeneratorResult(outputs=artifacts)
218
-
219
- async def estimate_cost(self, inputs: NanoBananaProEditInput) -> float:
220
- """Estimate cost for nano-banana-pro edit generation.
221
-
222
- nano-banana-pro/edit uses Google's latest image editing model.
223
- Using the same pricing as nano-banana-pro text-to-image.
224
- """
225
- # $0.039 per image
226
- return 0.039 * inputs.num_images
@@ -1,249 +0,0 @@
1
- """
2
- fal.ai qwen-image text-to-image generator.
3
-
4
- Qwen-Image is an advanced image generation model with exceptional text rendering
5
- and precise editing capabilities. Based on Fal AI's fal-ai/qwen-image model.
6
-
7
- See: https://fal.ai/models/fal-ai/qwen-image
8
- """
9
-
10
- import os
11
- from typing import Literal
12
-
13
- from pydantic import BaseModel, Field
14
-
15
- from ....base import BaseGenerator, GeneratorExecutionContext, GeneratorResult
16
-
17
-
18
- class LoraConfig(BaseModel):
19
- """LoRA configuration for model fine-tuning."""
20
-
21
- path: str = Field(description="Path or URL to LoRA weights")
22
- scale: float = Field(
23
- default=1.0,
24
- ge=0.0,
25
- le=4.0,
26
- description="Scale factor for LoRA influence (0-4)",
27
- )
28
-
29
-
30
- class CustomImageSize(BaseModel):
31
- """Custom image dimensions."""
32
-
33
- width: int = Field(description="Image width in pixels")
34
- height: int = Field(description="Image height in pixels")
35
-
36
-
37
- class QwenImageInput(BaseModel):
38
- """Input schema for qwen-image generation.
39
-
40
- Qwen-Image supports advanced text rendering and precise image editing capabilities.
41
- """
42
-
43
- prompt: str = Field(description="Text prompt for image generation")
44
- num_images: int = Field(
45
- default=1,
46
- ge=1,
47
- le=4,
48
- description="Number of images to generate (1-4)",
49
- )
50
- num_inference_steps: int = Field(
51
- default=30,
52
- ge=2,
53
- le=250,
54
- description="Number of inference steps (more steps = higher quality but slower)",
55
- )
56
- image_size: (
57
- Literal[
58
- "square_hd",
59
- "square",
60
- "portrait_4_3",
61
- "portrait_16_9",
62
- "landscape_4_3",
63
- "landscape_16_9",
64
- ]
65
- | CustomImageSize
66
- ) = Field(
67
- default="landscape_4_3",
68
- description="Image aspect ratio preset or custom dimensions",
69
- )
70
- output_format: Literal["jpeg", "png"] = Field(
71
- default="png",
72
- description="Output image format",
73
- )
74
- guidance_scale: float = Field(
75
- default=2.5,
76
- ge=0.0,
77
- le=20.0,
78
- description="Guidance scale for prompt adherence (0-20)",
79
- )
80
- seed: int | None = Field(
81
- default=None,
82
- description="Random seed for reproducibility (optional)",
83
- )
84
- negative_prompt: str = Field(
85
- default=" ",
86
- description="Negative prompt to specify unwanted elements",
87
- )
88
- acceleration: Literal["none", "regular", "high"] = Field(
89
- default="none",
90
- description="Acceleration level for faster generation",
91
- )
92
- enable_safety_checker: bool = Field(
93
- default=True,
94
- description="Enable safety checker to filter NSFW content",
95
- )
96
- use_turbo: bool = Field(
97
- default=False,
98
- description="Enable turbo mode for faster generation (10 steps, CFG=1.2)",
99
- )
100
- sync_mode: bool = Field(
101
- default=False,
102
- description="Use synchronous mode (wait for completion)",
103
- )
104
- loras: list[LoraConfig] = Field(
105
- default=[],
106
- max_length=3,
107
- description="LoRA configurations (up to 3 can be merged)",
108
- )
109
-
110
-
111
- class FalQwenImageGenerator(BaseGenerator):
112
- """Qwen-Image generator using fal.ai.
113
-
114
- Advanced image generation with exceptional text rendering and editing capabilities.
115
- """
116
-
117
- name = "fal-qwen-image"
118
- artifact_type = "image"
119
- description = "Fal: Qwen-Image - advanced text-to-image with exceptional text rendering"
120
-
121
- def get_input_schema(self) -> type[QwenImageInput]:
122
- return QwenImageInput
123
-
124
- async def generate(
125
- self, inputs: QwenImageInput, context: GeneratorExecutionContext
126
- ) -> GeneratorResult:
127
- """Generate images using fal.ai qwen-image model."""
128
- # Check for API key (fal-client uses FAL_KEY environment variable)
129
- if not os.getenv("FAL_KEY"):
130
- raise ValueError("API configuration invalid. Missing FAL_KEY environment variable")
131
-
132
- # Import fal_client
133
- try:
134
- import fal_client
135
- except ImportError as e:
136
- raise ImportError(
137
- "fal.ai SDK is required for FalQwenImageGenerator. "
138
- "Install with: pip install weirdfingers-boards[generators-fal]"
139
- ) from e
140
-
141
- # Prepare arguments for fal.ai API
142
- arguments = {
143
- "prompt": inputs.prompt,
144
- "num_images": inputs.num_images,
145
- "num_inference_steps": inputs.num_inference_steps,
146
- "output_format": inputs.output_format,
147
- "guidance_scale": inputs.guidance_scale,
148
- "negative_prompt": inputs.negative_prompt,
149
- "acceleration": inputs.acceleration,
150
- "enable_safety_checker": inputs.enable_safety_checker,
151
- "use_turbo": inputs.use_turbo,
152
- "sync_mode": inputs.sync_mode,
153
- }
154
-
155
- # Handle image_size: can be string or custom dimensions
156
- if isinstance(inputs.image_size, str):
157
- arguments["image_size"] = inputs.image_size
158
- else:
159
- # CustomImageSize object
160
- arguments["image_size"] = {
161
- "width": inputs.image_size.width,
162
- "height": inputs.image_size.height,
163
- }
164
-
165
- # Add seed if provided
166
- if inputs.seed is not None:
167
- arguments["seed"] = inputs.seed
168
-
169
- # Add LoRAs if provided
170
- if inputs.loras:
171
- arguments["loras"] = [{"path": lora.path, "scale": lora.scale} for lora in inputs.loras]
172
-
173
- # Submit async job and get handler
174
- handler = await fal_client.submit_async(
175
- "fal-ai/qwen-image",
176
- arguments=arguments,
177
- )
178
-
179
- # Store the external job ID for tracking
180
- await context.set_external_job_id(handler.request_id)
181
-
182
- # Stream progress updates (sample every 3rd event to avoid spam)
183
- from .....progress.models import ProgressUpdate
184
-
185
- event_count = 0
186
- async for event in handler.iter_events(with_logs=True):
187
- event_count += 1
188
-
189
- # Process every 3rd event to provide feedback without overwhelming
190
- if event_count % 3 == 0:
191
- # Extract logs if available
192
- logs = getattr(event, "logs", None)
193
- if logs:
194
- # Join log entries into a single message
195
- if isinstance(logs, list):
196
- message = " | ".join(str(log) for log in logs if log)
197
- else:
198
- message = str(logs)
199
-
200
- if message:
201
- await context.publish_progress(
202
- ProgressUpdate(
203
- job_id=handler.request_id,
204
- status="processing",
205
- progress=50.0, # Approximate mid-point progress
206
- phase="processing",
207
- message=message,
208
- )
209
- )
210
-
211
- # Get final result
212
- result = await handler.get()
213
-
214
- # Extract image URLs from result
215
- # fal.ai returns: {"images": [{"url": "...", "width": ..., "height": ...}, ...]}
216
- images = result.get("images", [])
217
- if not images:
218
- raise ValueError("No images returned from fal.ai API")
219
-
220
- # Store each image using output_index
221
- artifacts = []
222
- for idx, image_data in enumerate(images):
223
- image_url = image_data.get("url")
224
- # Optional width and height
225
- width = image_data.get("width")
226
- height = image_data.get("height")
227
-
228
- if not image_url:
229
- raise ValueError(f"Image {idx} missing URL in fal.ai response")
230
-
231
- # Store with appropriate output_index
232
- artifact = await context.store_image_result(
233
- storage_url=image_url,
234
- format=inputs.output_format,
235
- width=width,
236
- height=height,
237
- output_index=idx,
238
- )
239
- artifacts.append(artifact)
240
-
241
- return GeneratorResult(outputs=artifacts)
242
-
243
- async def estimate_cost(self, inputs: QwenImageInput) -> float:
244
- """Estimate cost for qwen-image generation.
245
-
246
- Qwen-image pricing is approximately $0.05 per image based on similar
247
- high-quality text-to-image models on fal.ai.
248
- """
249
- return 0.05 * inputs.num_images # $0.05 per image, scaled by batch size