Add all the assets for episode 24
David8c83a84ff0f0
diff --git a/episode_24/README.md b/episode_24/README.mdnew file mode 100644index 0000000..c40e9ba--- /dev/null+++ b/episode_24/README.md@@ -0,0 +1,49 @@+# Episode 24: generate images with Qwen Image, Flux.1 [dev] and Fluex.1 Schnell with modal.com++In this video, we show you how to use Modal’s serverless GPU infrastructure with n8n to do image generation with Flux Kontext Dev for free.++<table>+ <tr>+ <td>+ <a href="https://www.skool.com/ai-agents-az/about">📚 Join our Skool community for support, premium content and more!</a>+ <p>Be part of a growing community and help us create more content like this</p>+ </td>+ <td>+ <img width="548" height="596" alt="Screenshot 2025-07-29 at 3 23 33 PM" src="https://github.com/user-attachments/assets/d687b58d-92d0-44c0-93f8-7be23d3cb80c" />+ </td>+ </tr>+</table>++## Free n8n JSON workflows++- [n8n subworkflow to run Flux.1 [dev] on Cloudflare Workers AI](n8n_cloudflare_flux_schnell.json)+- [n8n subworkflow to run FLUX.1 [dev] on modal.com](n8n_modal_flux_dev.json)+- [n8n subworkflow to run FLUX.1 Schnell on modal.com](n8n_modal_flux_schnell.json)+- [n8n subworkflow to run Qwen Image on modal.com](n8n_modal_qwen.json)+- [n8n workflow to create TikTok scary story videos](n8n_tiktok_scary.json)++## Modal applications++- [python modal application to run FLUX.1 [dev]](modal_nunchaku_flux_dev.py)+- [python modal application to run FLUX.1 Schnell](modal_nunchaku_flux_schnell.py)+- [python modal application to run Qwen Image](modal_nunchaku_qwen.py)++## Instructions++1. Install python3 and venv+2. Create a new virtual environment with `python3 -m venv .venv`+3. Activate the virtual environment with `source .venv/bin/activate`+4. Install modal with `pip install modal`+5. Download the modal python applications and put it in the same directory+6. Run `modal deploy <<YOUR_APP>>` to deploy the application+7. Copy the URL of the deployed application+8. Import and configure the subworkflows in n8n++## Additional resources++- [Join n8n](https://n8n.partnerlinks.io/fenoo5ekqs1g)+- [Modal.com](https://modal.com)++## Watch the video++[](https://www.youtube.com/watch?v=)diff --git a/episode_24/flux_dev.py b/episode_24/flux_dev.pydeleted file mode 100644index 8d15331..0000000--- a/episode_24/flux_dev.py+++ /dev/null@@ -1,614 +0,0 @@-# ----# output-directory: "/tmp/flux"-# args: ["--no-compile"]-# -----# # Run Flux fast on H100s with `torch.compile`--# _Update: To speed up inference by another >2x, check out the additional optimization-# techniques we tried in [this blog post](https://modal.com/blog/flux-3x-faster)!_--# In this guide, we'll run Flux as fast as possible on Modal using open source tools.-# We'll use `torch.compile` and NVIDIA H100 GPUs.--# ## Setting up the image and dependencies--import time-from io import BytesIO-from pathlib import Path-from typing import Optional--import modal--# We'll make use of the full [CUDA toolkit](https://modal.com/docs/guide/cuda)-# in this example, so we'll build our container image off of the `nvidia/cuda` base.--cuda_version = "12.4.0" # should be no greater than host CUDA version-flavor = "devel" # includes full CUDA toolkit-operating_sys = "ubuntu22.04"-tag = f"{cuda_version}-{flavor}-{operating_sys}"--cuda_dev_image = modal.Image.from_registry(- f"nvidia/cuda:{tag}", add_python="3.11"-).entrypoint([])--# Now we install most of our dependencies with `apt` and `pip`.-# For Hugging Face's [Diffusers](https://github.com/huggingface/diffusers) library-# we install from GitHub source and so pin to a specific commit.--# PyTorch added faster attention kernels for Hopper GPUs in version 2.5.--diffusers_commit_sha = "81cf3b2f155f1de322079af28f625349ee21ec6b"--flux_image = (- cuda_dev_image.apt_install(- "git",- "libglib2.0-0",- "libsm6",- "libxrender1",- "libxext6",- "ffmpeg",- "libgl1",- )- .pip_install(- "invisible_watermark==0.2.0",- "transformers==4.44.0",- "huggingface_hub[hf_transfer]==0.26.2",- "accelerate==0.33.0",- "safetensors==0.4.4",- "sentencepiece==0.2.0",- "torch==2.5.0",- f"git+https://github.com/huggingface/diffusers.git@{diffusers_commit_sha}",- "numpy<2",- "fastapi[standard]==0.115.4",- )- .env({"HF_HUB_ENABLE_HF_TRANSFER": "1", "HF_HUB_CACHE": "/cache"})-)--# Later, we'll also use `torch.compile` to increase the speed further.-# Torch compilation needs to be re-executed when each new container starts,-# so we turn on some extra caching to reduce compile times for later containers.--flux_image = flux_image.env(- {- "TORCHINDUCTOR_CACHE_DIR": "/cache/.inductor_cache",- "TORCHINDUCTOR_FX_GRAPH_CACHE": "1",- "CUDA_CACHE_PATH": "/cache/.nv_cache",- "TRITON_CACHE_DIR": "/cache/.triton_cache",- }-)--# Finally, we construct our Modal [App](https://modal.com/docs/reference/modal.App),-# set its default image to the one we just constructed,-# and import `FluxPipeline` for downloading and running Flux.1.--app = modal.App("example-flux", image=flux_image)--with flux_image.imports():- import torch- from diffusers import FluxPipeline- from fastapi import FastAPI, HTTPException, status- from fastapi.responses import Response- from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials- from pydantic import BaseModel- from typing import Optional- import os-- # Fix for transformers cache migration issue- try:- from transformers.utils.hub import move_cache-- move_cache()- except Exception:- # Ignore if cache migration fails or is not needed- pass--# ## Defining a parameterized `Model` inference class--# Next, we map the model's setup and inference code onto Modal.--# 1. We run the model setup in the method decorated with `@modal.enter()`. This includes loading the-# weights and moving them to the GPU, along with an optional `torch.compile` step (see details below).-# The `@modal.enter()` decorator ensures that this method runs only once, when a new container starts,-# instead of in the path of every call.--# 2. We run the actual inference in methods decorated with `@modal.method()`.--# *Note: Access to the Flux.1-schnell model on Hugging Face is-# [gated by a license agreement](https://huggingface.co/docs/hub/en/models-gated)-# which you must agree to-# [here](https://huggingface.co/black-forest-labs/FLUX.1-schnell).-# After you have accepted the license,-# [create a Modal Secret](https://modal.com/secrets)-# with the name `huggingface-secret` following the instructions in the template.*--MINUTES = 60 # seconds-VARIANT = "Krea-dev" # schnell, dev, or Krea-dev-DEFAULT_NUM_INFERENCE_STEPS = 8 # use ~50 for [dev], (1-4) for [schnell]--CACHE_VOLUME = modal.Volume.from_name("cache_volume", create_if_missing=True)--- gpu="L40S", # fast GPU with strong software support- scaledown_window=10 * MINUTES,- timeout=60 * MINUTES, # leave plenty of time for compilation- enable_memory_snapshot=True,- volumes={ # add Volumes to store serializable compilation artifacts- "/cache": CACHE_VOLUME,- },- secrets=[modal.Secret.from_name("flux-app-secrets")],-)-class Model:- compile: bool = modal.parameter( # see section on torch.compile below for details- default=False- )-- @modal.enter(snap=True)- def load(self):- """Load model to CPU for memory snapshot."""- print("📥 Starting model loading phase (CPU)...")- print(f"📦 Loading FLUX.1-{VARIANT} model from Hugging Face...")-- pipe = FluxPipeline.from_pretrained(- f"black-forest-labs/FLUX.1-{VARIANT}",- torch_dtype=torch.bfloat16,- use_safetensors=True,- ).to("cpu")-- print("✅ Model loaded to CPU successfully")- print("💾 Memory snapshot will be created after this step")- self.pipe = pipe-- @modal.enter(snap=False)- def setup(self):- """Move model to GPU and apply optimizations."""- print("🚀 Starting optimization phase...")- print("🔄 Moving model from CPU to GPU...")-- self.pipe.to("cuda")- print("✅ Model moved to GPU successfully")-- print("⚡ Applying standard optimizations and torch compilation...")- self.pipe = optimize(self.pipe, compile=self.compile)- print("✅ Standard optimizations completed")-- print("🫖 Setting up TeaCache for 2x speedup...")- self.setup_teacache()- print("🚀 TeaCache setup completed for 2x speedup")- print("🎯 Model is ready for inference!")-- def setup_teacache(self):- """Setup TeaCache for approximate caching speedup."""- print("🔧 Configuring TeaCache parameters...")-- # Enable TeaCache on the transformer- self.pipe.transformer.__class__.enable_teacache = True- self.pipe.transformer.__class__.cnt = 0- self.pipe.transformer.__class__.num_steps = None # Will be set during inference- self.pipe.transformer.__class__.rel_l1_thresh = 0.6 # 2.0x speedup threshold- self.pipe.transformer.__class__.accumulated_rel_l1_distance = 0- self.pipe.transformer.__class__.previous_input = None- self.pipe.transformer.__class__.previous_result = None-- print(f"📊 TeaCache threshold set to {0.6} for 2x speedup")- print(f"🔄 Steps will be set dynamically during inference")-- print("🔀 Patching transformer forward method with TeaCache logic...")- self.patch_transformer_forward()- print("✅ TeaCache forward method patched successfully")-- def patch_transformer_forward(self):- """Patch the transformer forward method with TeaCache logic."""- import numpy as np-- original_forward = self.pipe.transformer.forward-- def teacache_forward(- hidden_states,- encoder_hidden_states=None,- pooled_projections=None,- timestep=None,- img_ids=None,- txt_ids=None,- guidance=None,- joint_attention_kwargs=None,- **kwargs,- ):- if (- hasattr(self.pipe.transformer, "enable_teacache")- and self.pipe.transformer.enable_teacache- ):- # Simplified TeaCache logic - determine if we should skip computation- should_calc = True-- if hasattr(self.pipe.transformer, "cnt") and hasattr(- self.pipe.transformer, "num_steps"- ):- # Safety check: ensure num_steps is valid- if (- self.pipe.transformer.num_steps is None- or self.pipe.transformer.num_steps <= 0- ):- print(- "⚠️ TeaCache: Invalid num_steps, disabling TeaCache for this inference"- )- should_calc = True- else:- # Use hidden_states directly for change detection (simplified approach)- current_input = hidden_states.clone()-- if (- self.pipe.transformer.cnt == 0- or self.pipe.transformer.cnt- == self.pipe.transformer.num_steps - 1- ):- should_calc = True- self.pipe.transformer.accumulated_rel_l1_distance = 0- else:- # TeaCache coefficients for FLUX (from official implementation)- coefficients = [- 4.98651651e02,- -2.83781631e02,- 5.58554382e01,- -3.82021401e00,- 2.64230861e-01,- ]- rescale_func = np.poly1d(coefficients)-- if (- hasattr(self.pipe.transformer, "previous_input")- and self.pipe.transformer.previous_input is not None- ):- # Calculate relative L1 distance between inputs- rel_diff = (- current_input - self.pipe.transformer.previous_input- ).abs().mean() / self.pipe.transformer.previous_input.abs().mean()-- self.pipe.transformer.accumulated_rel_l1_distance += (- rescale_func(rel_diff.cpu().item())- )-- if (- self.pipe.transformer.accumulated_rel_l1_distance- < self.pipe.transformer.rel_l1_thresh- ):- should_calc = False- print(- f"🫖 TeaCache: Step {self.pipe.transformer.cnt}/{self.pipe.transformer.num_steps} - Using cached result (distance: {self.pipe.transformer.accumulated_rel_l1_distance:.3f})"- )- else:- should_calc = True- self.pipe.transformer.accumulated_rel_l1_distance = (- 0- )- print(- f"🫖 TeaCache: Step {self.pipe.transformer.cnt}/{self.pipe.transformer.num_steps} - Computing new result (threshold exceeded)"- )-- self.pipe.transformer.previous_input = current_input- self.pipe.transformer.cnt += 1-- if self.pipe.transformer.cnt == self.pipe.transformer.num_steps:- self.pipe.transformer.cnt = 0-- # Use cached result if we're skipping computation- if (- not should_calc- and hasattr(self.pipe.transformer, "previous_result")- and self.pipe.transformer.previous_result is not None- ):- # Return cached result- return self.pipe.transformer.previous_result- else:- # Compute normally and cache the result- result = original_forward(- hidden_states,- encoder_hidden_states,- pooled_projections,- timestep,- img_ids,- txt_ids,- guidance,- joint_attention_kwargs,- **kwargs,- )- self.pipe.transformer.previous_result = result- return result-- # Fallback to original forward if TeaCache is disabled- return original_forward(- hidden_states,- encoder_hidden_states,- pooled_projections,- timestep,- img_ids,- txt_ids,- guidance,- joint_attention_kwargs,- **kwargs,- )-- # Replace the forward method- self.pipe.transformer.forward = teacache_forward-- @modal.method()- def inference(- self,- prompt: str,- width: int = 1024,- height: int = 1024,- seed: Optional[int] = None,- steps: int = DEFAULT_NUM_INFERENCE_STEPS,- cfg: float = 1.0,- ) -> bytes:- print("🎨 Starting image generation...")- print(f"📝 Prompt: {prompt}")- print(f"📐 Dimensions: {width}x{height}")- print(f"🎛️ CFG Scale: {cfg}")-- # Ensure steps is valid- if steps is None or steps <= 0:- steps = DEFAULT_NUM_INFERENCE_STEPS- print(f"⚠️ Invalid steps value, using default: {steps}")-- # Update TeaCache with the actual number of steps being used- if (- hasattr(self.pipe.transformer, "enable_teacache")- and self.pipe.transformer.enable_teacache- ):- self.pipe.transformer.__class__.num_steps = steps- self.pipe.transformer.__class__.cnt = 0 # Reset counter- print(f"🫖 TeaCache configured for {steps} steps")-- # Use provided seed or generate a random one- if seed is not None:- print(f"🎲 Using seed: {seed}")- generator = torch.Generator(device="cuda").manual_seed(seed)- else:- print("🎲 Using random seed")- generator = torch.Generator(device="cuda")-- print(f"🔄 Running {steps} inference steps with TeaCache optimization...")- out = self.pipe(- prompt,- width=width,- height=height,- output_type="pil",- num_inference_steps=steps,- generator=generator,- guidance_scale=cfg,- ).images[0]-- print("🖼️ Converting image to bytes...")- byte_stream = BytesIO()- out.save(byte_stream, format="PNG")- result_bytes = byte_stream.getvalue()- print(f"✅ Image generated successfully! Size: {len(result_bytes)} bytes")- return result_bytes---# Create a separate FastAPI app to handle the web interface[email protected](image=flux_image, cpu="0.5", memory="2GiB")[email protected]_app()-def fastapi_app():- from fastapi import Depends, FastAPI, HTTPException, status- from fastapi.responses import Response- from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials- from pydantic import BaseModel- from typing import Optional- import os-- class GenerateRequest(BaseModel):- prompt: str- width: int = 1024- height: int = 1024- seed: Optional[int] = None- steps: int = DEFAULT_NUM_INFERENCE_STEPS- cfg: float = 1.0-- web_app = FastAPI(- title="Flux Image Generator",- description="Generate images using Flux model",- version="1.0.0",- )-- @web_app.post("/generate")- async def generate_image(- request: GenerateRequest,- token: Optional[HTTPAuthorizationCredentials] = Depends(- HTTPBearer(auto_error=False)- ),- ):- """- Generate an image using Flux model.-- - **prompt**: Text description of the image you want to generate- - **width**: Width of the generated image (default: 1024)- - **height**: Height of the generated image (default: 1024)- - **seed**: Optional seed for reproducible results- - **steps**: Number of inference steps (default: 8)- - **cfg**: Classifier-Free Guidance scale (default: 1.0)- """-- if os.environ.get("BEARER_TOKEN", False):- if not token or token.credentials != os.environ["BEARER_TOKEN"]:- raise HTTPException(- status_code=status.HTTP_401_UNAUTHORIZED,- detail="Incorrect bearer token",- headers={"WWW-Authenticate": "Bearer"},- )-- try:- # Validate and set default for steps if needed- steps = request.steps- if steps is None or steps <= 0:- steps = DEFAULT_NUM_INFERENCE_STEPS-- model = Model()- result_bytes = model.inference.remote(- prompt=request.prompt,- width=request.width,- height=request.height,- seed=request.seed,- steps=steps,- cfg=request.cfg,- )-- return Response(- content=result_bytes,- media_type="image/png",- headers={"Content-Disposition": "inline; filename=generated_image.png"},- )-- except Exception as e:- raise HTTPException(- status_code=500, detail=f"Error generating image: {str(e)}"- )-- return web_app---# ## Calling our inference function--# To generate an image we just need to call the `Model`'s `generate` method-# with `.remote` appended to it.-# You can call `.generate.remote` from any Python environment that has access to your Modal credentials.-# The local environment will get back the image as bytes.--# Here, we wrap the call in a Modal [`local_entrypoint`](https://modal.com/docs/reference/modal.App#local_entrypoint)-# so that it can be run with `modal run`:--# ```bash-# modal run flux.py-# ```--# By default, we call `generate` twice to demonstrate how much faster-# the inference is after cold start. In our tests, clients received images in about 1.2 seconds.-# We save the output bytes to a temporary file.--[email protected]_entrypoint()-def main(- prompt: str = "a computer screen showing ASCII terminal art of the"- " word 'Modal' in neon green. two programmers are pointing excitedly"- " at the screen.",- twice: bool = True,- compile: bool = False,-):- t0 = time.time()- image_bytes = Model(compile=compile).inference.remote(prompt)- print(f"🎨 first inference latency: {time.time() - t0:.2f} seconds")-- if twice:- t0 = time.time()- image_bytes = Model(compile=compile).inference.remote(prompt)- print(f"🎨 second inference latency: {time.time() - t0:.2f} seconds")-- output_path = Path("/tmp") / "flux" / "output.jpg"- output_path.parent.mkdir(exist_ok=True, parents=True)- print(f"🎨 saving output to {output_path}")- output_path.write_bytes(image_bytes)---# ## Speeding up Flux with `torch.compile`--# By default, we do some basic optimizations, like adjusting memory layout-# and re-expressing the attention head projections as a single matrix multiplication.-# But there are additional speedups to be had!--# PyTorch 2 added a compiler that optimizes the-# compute graphs created dynamically during PyTorch execution.-# This feature helps close the gap with the performance of static graph frameworks-# like TensorRT and TensorFlow.--# Here, we follow the suggestions from Hugging Face's-# [guide to fast diffusion inference](https://huggingface.co/docs/diffusers/en/tutorials/fast_diffusion),-# which we verified with our own internal benchmarks.-# Review that guide for detailed explanations of the choices made below.--# The resulting compiled Flux `schnell` deployment returns images to the client in under a second (~700 ms), according to our testing.-# _Super schnell_!--# Compilation takes up to twenty minutes on first iteration.-# As of time of writing in late 2024,-# the compilation artifacts cannot be fully serialized,-# so some compilation work must be re-executed every time a new container is started.-# That includes when scaling up an existing deployment or the first time a Function is invoked with `modal run`.--# We cache compilation outputs from `nvcc`, `triton`, and `inductor`,-# which can reduce compilation time by up to an order of magnitude.-# For details see [this tutorial](https://pytorch.org/tutorials/recipes/torch_compile_caching_tutorial.html).--# You can turn on compilation with the `--compile` flag.-# Try it out with:--# ```bash-# modal run flux.py --compile-# ```--# The `compile` option is passed by a [`modal.parameter`](https://modal.com/docs/reference/modal.parameter#modalparameter) on our class.-# Each different choice for a `parameter` creates a [separate auto-scaling deployment](https://modal.com/docs/guide/parameterized-functions).-# That means your client can use arbitrary logic to decide whether to hit a compiled or eager endpoint.---def optimize(pipe, compile=True):- print("🔧 Starting optimization process...")-- print("🔗 Fusing QKV projections in Transformer and VAE...")- pipe.transformer.fuse_qkv_projections()- pipe.vae.fuse_qkv_projections()- print("✅ QKV projections fused successfully")-- print("💾 Switching to channels_last memory layout...")- pipe.transformer.to(memory_format=torch.channels_last)- pipe.vae.to(memory_format=torch.channels_last)- print("✅ Memory layout optimized")-- if not compile:- print("⚠️ Torch compilation disabled, skipping compilation step")- return pipe-- print("⚡ Configuring torch compilation settings...")- # set torch compile flags with enhanced configuration- config = torch._inductor.config- config.disable_progress = False # show progress bar- config.conv_1x1_as_mm = True # treat 1x1 convolutions as matrix muls- # adjust autotuning algorithm- config.coordinate_descent_tuning = True- config.coordinate_descent_check_all_directions = True- config.epilogue_fusion = False # do not fuse pointwise ops into matmuls- config.shape_padding = True # new optimization from blog post- print("✅ Torch compilation config set")-- print("🚀 Compiling transformer with max-autotune-no-cudagraphs...")- pipe.transformer = torch.compile(- pipe.transformer,- mode="max-autotune-no-cudagraphs",- dynamic=True,- fullgraph=True,- )- print("✅ Transformer compiled")-- print("🚀 Compiling VAE decoder...")- pipe.vae.decode = torch.compile(- pipe.vae.decode, mode="max-autotune-no-cudagraphs", dynamic=True, fullgraph=True- )- print("✅ VAE decoder compiled")-- # trigger torch compilation- print("🔦 Triggering torch compilation with dummy inference...")- print("⏱️ This may take up to 20 minutes on first run...")-- pipe(- "dummy prompt to trigger torch compilation",- output_type="pil",- height=1024,- width=1024,- num_inference_steps=DEFAULT_NUM_INFERENCE_STEPS, # use ~50 for [dev], smaller for [schnell]- num_images_per_prompt=1,- ).images[0]-- print("🔦 Torch compilation completed successfully!")-- return pipediff --git a/episode_24/modal_nunchaku_flux_dev.py b/episode_24/modal_nunchaku_flux_dev.pynew file mode 100644index 0000000..5091743--- /dev/null+++ b/episode_24/modal_nunchaku_flux_dev.py@@ -0,0 +1,225 @@+from io import BytesIO+from pathlib import Path+from typing import Optional++import modal++image = (+ modal.Image.from_registry(+ "nvidia/cuda:12.8.1-devel-ubuntu22.04",+ add_python="3.13",+ )+ .entrypoint([]) # remove verbose logging by base image on entry+ .apt_install("git")+ .pip_install("uv")+ .run_commands(+ f"uv pip install --system --compile-bytecode --index-strategy unsafe-best-match hf_transfer Pillow~=11.2.1 safetensors~=0.5.3 transformers~=4.53.0 sentencepiece~=0.2.0 torch==2.7.1 torchvision torchaudio optimum-quanto==0.2.7 fastapi[standard]==0.115.4 python-multipart==0.0.12 https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.0/nunchaku-1.0.0+torch2.7-cp313-cp313-linux_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu128"+ )+)++MODEL_NAME = "black-forest-labs/FLUX.1-dev"++CACHE_DIR = Path("/cache")+cache_volume = modal.Volume.from_name("hf-hub-cache", create_if_missing=True)+volumes = {CACHE_DIR: cache_volume}++secrets = [modal.Secret.from_name("flux-app-secrets", required_keys=["HF_TOKEN"])]++image = image.env(+ {+ "HF_HUB_ENABLE_HF_TRANSFER": "1", # Allows faster model downloads+ "HF_HOME": str(CACHE_DIR), # Points the Hugging Face cache to a Volume+ }+)++app = modal.App("nunchaku-flux-dev-fastapi")++with image.imports():+ import torch+ import os+ from diffusers import FluxPipeline+ from nunchaku.models.transformers.transformer_flux_v2 import (+ NunchakuFluxTransformer2DModelV2,+ )+ from nunchaku.caching.diffusers_adapters.flux_v2 import apply_cache_on_pipe+ from nunchaku.utils import get_precision+ from PIL import Image+ from fastapi import FastAPI, Form, HTTPException+ from fastapi.responses import Response+ from pydantic import BaseModel+++ image=image,+ gpu="L40s",+ volumes=volumes,+ secrets=secrets,+ scaledown_window=120,+ timeout=10 * 60, # 10 minutes+)+class NunchakuFluxDevModel:+ @modal.enter()+ def enter(self):+ print(f"Downloading {MODEL_NAME} and Nunchaku transformer if necessary...")++ self.dtype = torch.bfloat16+ self.device = "cuda"++ # Auto-detect precision (int4 or fp4) based on GPU+ self.precision = get_precision()+ print(f"Detected precision: {self.precision}")++ # Load the quantized transformer+ self.transformer = NunchakuFluxTransformer2DModelV2.from_pretrained(+ f"nunchaku-tech/nunchaku-flux.1-dev/svdq-{self.precision}_r32-flux.1-dev.safetensors",+ cache_dir=CACHE_DIR,+ )++ # Load the full pipeline with the quantized transformer+ self.pipe = FluxPipeline.from_pretrained(+ MODEL_NAME,+ transformer=self.transformer,+ torch_dtype=self.dtype,+ cache_dir=CACHE_DIR,+ token=os.environ.get("HF_TOKEN"),+ ).to(self.device)++ # Apply cache optimizations for FLUX.1-dev+ apply_cache_on_pipe(+ self.pipe,+ use_double_fb_cache=True,+ residual_diff_threshold_multi=0.12,+ residual_diff_threshold_single=0.20,+ )++ print("Model loaded successfully!")++ @modal.method()+ def inference(+ self,+ prompt: str,+ width: int = 1024,+ height: int = 1024,+ num_inference_steps: int = 50,+ guidance_scale: float = 3.5,+ seed: Optional[int] = None,+ ) -> bytes:+ # Use provided seed or generate a random one+ if seed is not None:+ generator = torch.Generator(device=self.device).manual_seed(seed)+ else:+ generator = torch.Generator(device=self.device)++ print(f"Generating image with prompt: {prompt}")+ print(f"Using precision: {self.precision}")++ image = self.pipe(+ prompt=prompt,+ width=width,+ height=height,+ num_inference_steps=num_inference_steps,+ guidance_scale=guidance_scale,+ output_type="pil",+ generator=generator,+ ).images[0]++ byte_stream = BytesIO()+ image.save(byte_stream, format="PNG")+ image_bytes = byte_stream.getvalue()++ return image_bytes+++# Create a separate FastAPI app to handle the web interface[email protected](image=image, volumes=volumes, secrets=secrets, cpu="0.5", memory="2GiB")[email protected]_app()+def fastapi_app():+ from fastapi import Depends, FastAPI, Form, HTTPException, status+ from fastapi.responses import Response+ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials+ from pydantic import BaseModel++ class GenerateImageRequest(BaseModel):+ prompt: str+ width: int = 1024+ height: int = 1024+ steps: int = 50+ guidance_scale: float = 3.5+ seed: Optional[int] = None++ web_app = FastAPI(+ title="Nunchaku Flux Dev Generator",+ description="Generate images using Nunchaku-quantized Flux Dev model",+ version="1.0.0",+ )++ @web_app.post("/generate")+ async def generate_image(+ request: GenerateImageRequest,+ token: Optional[HTTPAuthorizationCredentials] = Depends(+ HTTPBearer(auto_error=False)+ ),+ ):+ """+ Generate an image using Nunchaku-quantized Flux Dev model.++ - **prompt**: Text description of the image you want to generate+ - **width**: Image width in pixels (default: 1024)+ - **height**: Image height in pixels (default: 1024)+ - **steps**: Number of denoising steps (default: 50, optimal for Dev)+ - **guidance_scale**: Guidance scale (default: 3.5, optimal for Dev)+ - **seed**: Optional seed for reproducible results+ """++ if os.environ.get("BEARER_TOKEN", False):+ if not token or token.credentials != os.environ["BEARER_TOKEN"]:+ raise HTTPException(+ status_code=status.HTTP_401_UNAUTHORIZED,+ detail="Incorrect bearer token",+ headers={"WWW-Authenticate": "Bearer"},+ )++ try:+ # Validate dimensions (must be divisible by 8 for FLUX)+ if request.width % 8 != 0 or request.height % 8 != 0:+ raise HTTPException(+ status_code=400,+ detail="Width and height must be divisible by 8.",+ )++ if request.width * request.height > 1024 * 1024:+ raise HTTPException(+ status_code=400,+ detail="Maximum image size is 1 megapixel (e.g., 1024x1024 or 2048x512).",+ )++ if request.width < 256 or request.height < 256:+ raise HTTPException(+ status_code=400,+ detail="Minimum image size is 256x256 pixels.",+ )++ model = NunchakuFluxDevModel()+ result_bytes = model.inference.remote(+ prompt=request.prompt[:280],+ width=request.width,+ height=request.height,+ num_inference_steps=request.steps,+ guidance_scale=request.guidance_scale,+ seed=request.seed,+ )++ return Response(+ content=result_bytes,+ media_type="image/png",+ headers={+ "Content-Disposition": f"inline; filename=nunchaku_flux_dev_{request.seed or 'random'}.png"+ },+ )++ except Exception as e:+ raise HTTPException(+ status_code=500, detail=f"Error generating image: {str(e)}"+ )++ return web_appdiff --git a/episode_24/modal_nunchaku_flux_schnell.py b/episode_24/modal_nunchaku_flux_schnell.pynew file mode 100644index 0000000..0c0a9cc--- /dev/null+++ b/episode_24/modal_nunchaku_flux_schnell.py@@ -0,0 +1,214 @@+from io import BytesIO+from pathlib import Path+from typing import Optional++import modal++image = (+ modal.Image.from_registry(+ "nvidia/cuda:12.8.1-devel-ubuntu22.04",+ add_python="3.13",+ )+ .entrypoint([]) # remove verbose logging by base image on entry+ .apt_install("git")+ .pip_install("uv")+ .run_commands(+ f"uv pip install --system --compile-bytecode --index-strategy unsafe-best-match Pillow~=11.2.1 safetensors~=0.5.3 transformers~=4.53.0 sentencepiece~=0.2.0 torch==2.7.1 torchvision torchaudio optimum-quanto==0.2.7 fastapi[standard]==0.115.4 python-multipart==0.0.12 https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.0/nunchaku-1.0.0+torch2.7-cp313-cp313-linux_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu128"+ )+)++MODEL_NAME = "black-forest-labs/FLUX.1-schnell"++CACHE_DIR = Path("/cache")+cache_volume = modal.Volume.from_name("hf-hub-cache", create_if_missing=True)+volumes = {CACHE_DIR: cache_volume}++secrets = [modal.Secret.from_name("flux-app-secrets", required_keys=["HF_TOKEN"])]++image = image.env(+ {+ "HF_HUB_ENABLE_HF_TRANSFER": "1", # Allows faster model downloads+ "HF_HOME": str(CACHE_DIR), # Points the Hugging Face cache to a Volume+ }+)++app = modal.App("nunchaku-flux-schnell-fastapi")++with image.imports():+ import torch+ import os+ from diffusers import FluxPipeline+ from nunchaku import NunchakuFluxTransformer2DModelV2+ from nunchaku.utils import get_precision+ from PIL import Image+ from fastapi import FastAPI, Form, HTTPException+ from fastapi.responses import Response+ from pydantic import BaseModel+++ image=image,+ gpu="L40s",+ volumes=volumes,+ secrets=secrets,+ scaledown_window=120,+ timeout=10 * 60, # 10 minutes+)+class NunchakuFluxSchnellModel:+ @modal.enter()+ def enter(self):+ print(f"Downloading {MODEL_NAME} and Nunchaku transformer if necessary...")++ self.dtype = torch.bfloat16+ self.device = "cuda"++ # Auto-detect precision (int4 or fp4) based on GPU+ self.precision = get_precision()+ print(f"Detected precision: {self.precision}")++ # Load the quantized transformer+ self.transformer = NunchakuFluxTransformer2DModelV2.from_pretrained(+ f"nunchaku-tech/nunchaku-flux.1-schnell/svdq-{self.precision}_r32-flux.1-schnell.safetensors",+ cache_dir=CACHE_DIR,+ )++ # Load the full pipeline with the quantized transformer+ self.pipe = FluxPipeline.from_pretrained(+ MODEL_NAME,+ transformer=self.transformer,+ torch_dtype=self.dtype,+ cache_dir=CACHE_DIR,+ token=os.environ.get("HF_TOKEN"),+ ).to(self.device)++ print("Model loaded successfully!")++ @modal.method()+ def inference(+ self,+ prompt: str,+ width: int = 1024,+ height: int = 1024,+ num_inference_steps: int = 4,+ guidance_scale: float = 0.0,+ seed: Optional[int] = None,+ ) -> bytes:+ # Use provided seed or generate a random one+ if seed is not None:+ generator = torch.Generator(device=self.device).manual_seed(seed)+ else:+ generator = torch.Generator(device=self.device)++ print(f"Generating image with prompt: {prompt}")+ print(f"Using precision: {self.precision}")++ image = self.pipe(+ prompt=prompt,+ width=width,+ height=height,+ num_inference_steps=num_inference_steps,+ guidance_scale=guidance_scale,+ output_type="pil",+ generator=generator,+ ).images[0]++ byte_stream = BytesIO()+ image.save(byte_stream, format="PNG")+ image_bytes = byte_stream.getvalue()++ return image_bytes+++# Create a separate FastAPI app to handle the web interface[email protected](image=image, volumes=volumes, secrets=secrets, cpu="0.5", memory="2GiB")[email protected]_app()+def fastapi_app():+ from fastapi import Depends, FastAPI, Form, HTTPException, status+ from fastapi.responses import Response+ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials+ from pydantic import BaseModel++ class GenerateImageRequest(BaseModel):+ prompt: str+ width: int = 1024+ height: int = 1024+ steps: int = 4+ guidance_scale: float = 0.0+ seed: Optional[int] = None++ web_app = FastAPI(+ title="Nunchaku Flux Schnell Generator",+ description="Generate images using Nunchaku-quantized Flux Schnell model",+ version="1.0.0",+ )++ @web_app.post("/generate")+ async def generate_image(+ request: GenerateImageRequest,+ token: Optional[HTTPAuthorizationCredentials] = Depends(+ HTTPBearer(auto_error=False)+ ),+ ):+ """+ Generate an image using Nunchaku-quantized Flux Schnell model.++ - **prompt**: Text description of the image you want to generate+ - **width**: Image width in pixels (default: 1024)+ - **height**: Image height in pixels (default: 1024)+ - **steps**: Number of denoising steps (default: 4, optimal for Schnell)+ - **guidance_scale**: Guidance scale (default: 0.0, optimal for Schnell)+ - **seed**: Optional seed for reproducible results+ """++ if os.environ.get("BEARER_TOKEN", False):+ if not token or token.credentials != os.environ["BEARER_TOKEN"]:+ raise HTTPException(+ status_code=status.HTTP_401_UNAUTHORIZED,+ detail="Incorrect bearer token",+ headers={"WWW-Authenticate": "Bearer"},+ )++ try:+ # Validate dimensions (must be divisible by 8 for FLUX)+ if request.width % 8 != 0 or request.height % 8 != 0:+ raise HTTPException(+ status_code=400,+ detail="Width and height must be divisible by 8.",+ )++ if request.width * request.height > 1024 * 1024:+ raise HTTPException(+ status_code=400,+ detail="Maximum image size is 1 megapixel (e.g., 1024x1024 or 2048x512).",+ )++ if request.width < 256 or request.height < 256:+ raise HTTPException(+ status_code=400,+ detail="Minimum image size is 256x256 pixels.",+ )++ model = NunchakuFluxSchnellModel()+ result_bytes = model.inference.remote(+ prompt=request.prompt,+ width=request.width,+ height=request.height,+ num_inference_steps=request.steps,+ guidance_scale=request.guidance_scale,+ seed=request.seed,+ )++ return Response(+ content=result_bytes,+ media_type="image/png",+ headers={+ "Content-Disposition": f"inline; filename=nunchaku_flux_schnell_{request.seed or 'random'}.png"+ },+ )++ except Exception as e:+ raise HTTPException(+ status_code=500, detail=f"Error generating image: {str(e)}"+ )++ return web_appdiff --git a/episode_24/modal_nunchaku_qwen.py b/episode_24/modal_nunchaku_qwen.pynew file mode 100644index 0000000..8cf6afb--- /dev/null+++ b/episode_24/modal_nunchaku_qwen.py@@ -0,0 +1,251 @@+from io import BytesIO+from pathlib import Path+from typing import Optional++import modal++image = (+ modal.Image.from_registry(+ "nvidia/cuda:12.8.1-devel-ubuntu22.04",+ add_python="3.13",+ )+ .entrypoint([]) # remove verbose logging by base image on entry+ .apt_install("git")+ .pip_install("uv")+ .run_commands(+ f"uv pip install --system --compile-bytecode --index-strategy unsafe-best-match hf_transfer Pillow~=11.2.1 safetensors~=0.5.3 transformers~=4.53.0 sentencepiece~=0.2.0 torch==2.7.1 torchvision torchaudio optimum-quanto==0.2.7 fastapi[standard]==0.115.4 python-multipart==0.0.12 diffusers https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.0/nunchaku-1.0.0+torch2.7-cp313-cp313-linux_x86_64.whl --extra-index-url https://download.pytorch.org/whl/cu128"+ )+)++MODEL_NAME = "Qwen/Qwen-Image"++# Qwen model configuration+num_inference_steps = 4 # you can also use the 8-step model to improve the quality+rank = 32 # you can also use the rank=128 model to improve the quality++CACHE_DIR = Path("/cache")+cache_volume = modal.Volume.from_name("hf-hub-cache", create_if_missing=True)+volumes = {CACHE_DIR: cache_volume}++secrets = [modal.Secret.from_name("flux-app-secrets", required_keys=["HF_TOKEN"])]++image = image.env(+ {+ "HF_HUB_ENABLE_HF_TRANSFER": "1", # Allows faster model downloads+ "HF_HOME": str(CACHE_DIR), # Points the Hugging Face cache to a Volume+ }+)++app = modal.App("nunchaku-qwen-image-fastapi")++with image.imports():+ import torch+ import os+ import math+ from diffusers import FlowMatchEulerDiscreteScheduler, QwenImagePipeline+ from nunchaku.models.transformers.transformer_qwenimage import (+ NunchakuQwenImageTransformer2DModel,+ )+ from nunchaku.utils import get_precision, get_gpu_memory+ from PIL import Image+ from fastapi import FastAPI, Form, HTTPException+ from fastapi.responses import Response+ from pydantic import BaseModel+++ image=image,+ gpu="L40s",+ volumes=volumes,+ secrets=secrets,+ scaledown_window=120,+ timeout=10 * 60, # 10 minutes+)+class NunchakuQwenImageModel:+ @modal.enter()+ def enter(self):+ print(f"Downloading {MODEL_NAME} and Nunchaku transformer if necessary...")++ self.dtype = torch.bfloat16+ self.device = "cuda"++ # Auto-detect precision (int4 or fp4) based on GPU+ self.precision = get_precision()+ print(f"Detected precision: {self.precision}")++ # Scheduler configuration for Qwen+ scheduler_config = {+ "base_image_seq_len": 256,+ "base_shift": math.log(3), # We use shift=3 in distillation+ "invert_sigmas": False,+ "max_image_seq_len": 8192,+ "max_shift": math.log(3), # We use shift=3 in distillation+ "num_train_timesteps": 1000,+ "shift": 1.0,+ "shift_terminal": None, # set shift_terminal to None+ "stochastic_sampling": False,+ "time_shift_type": "exponential",+ "use_beta_sigmas": False,+ "use_dynamic_shifting": True,+ "use_exponential_sigmas": False,+ "use_karras_sigmas": False,+ }+ self.scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)++ # Model paths for different step configurations+ model_paths = {+ 4: f"nunchaku-tech/nunchaku-qwen-image/svdq-{self.precision}_r{rank}-qwen-image-lightningv1.0-4steps.safetensors",+ 8: f"nunchaku-tech/nunchaku-qwen-image/svdq-{self.precision}_r{rank}-qwen-image-lightningv1.1-8steps.safetensors",+ }++ # Load the quantized transformer+ self.transformer = NunchakuQwenImageTransformer2DModel.from_pretrained(+ model_paths[num_inference_steps],+ cache_dir=CACHE_DIR,+ )++ # Load the full pipeline with the quantized transformer+ self.pipe = QwenImagePipeline.from_pretrained(+ MODEL_NAME,+ transformer=self.transformer,+ scheduler=self.scheduler,+ torch_dtype=self.dtype,+ cache_dir=CACHE_DIR,+ token=os.environ.get("HF_TOKEN"),+ ).to(self.device)++ # Memory optimization based on GPU memory+ if get_gpu_memory() > 18:+ self.pipe.enable_model_cpu_offload()+ else:+ # use per-layer offloading for low VRAM. This only requires 3-4GB of VRAM.+ self.transformer.set_offload(True)+ self.pipe._exclude_from_cpu_offload.append("transformer")+ self.pipe.enable_sequential_cpu_offload()++ print("Model loaded successfully!")++ @modal.method()+ def inference(+ self,+ prompt: str,+ negative_prompt: str = "",+ width: int = 1024,+ height: int = 1024,+ true_cfg_scale: float = 1.0,+ seed: Optional[int] = None,+ ) -> bytes:+ # Use provided seed or generate a random one+ if seed is not None:+ generator = torch.Generator(device=self.device).manual_seed(seed)+ else:+ generator = torch.Generator(device=self.device)++ print(f"Generating image with prompt: {prompt}")+ print(f"Using precision: {self.precision}")++ image = self.pipe(+ prompt=prompt,+ negative_prompt=negative_prompt,+ width=width,+ height=height,+ num_inference_steps=num_inference_steps,+ true_cfg_scale=true_cfg_scale,+ output_type="pil",+ generator=generator,+ ).images[0]++ byte_stream = BytesIO()+ image.save(byte_stream, format="PNG")+ image_bytes = byte_stream.getvalue()++ return image_bytes+++# Create a separate FastAPI app to handle the web interface[email protected](image=image, volumes=volumes, secrets=secrets, cpu="0.5", memory="2GiB")[email protected]_app()+def fastapi_app():+ from fastapi import Depends, FastAPI, Form, HTTPException, status+ from fastapi.responses import Response+ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials+ from pydantic import BaseModel++ class GenerateImageRequest(BaseModel):+ prompt: str+ negative_prompt: str = ""+ width: int = 1024+ height: int = 1024+ true_cfg_scale: float = 1.0+ seed: Optional[int] = None++ web_app = FastAPI(+ title="Nunchaku Qwen Image Generator",+ description="Generate images using Nunchaku-quantized Qwen Image model",+ version="1.0.0",+ )++ @web_app.post("/generate")+ async def generate_image(+ request: GenerateImageRequest,+ token: Optional[HTTPAuthorizationCredentials] = Depends(+ HTTPBearer(auto_error=False)+ ),+ ):+ """+ Generate an image using Nunchaku-quantized Qwen Image model.++ - **prompt**: Text description of the image you want to generate+ - **negative_prompt**: Text description of what you don't want in the image+ - **width**: Image width in pixels (default: 1024)+ - **height**: Image height in pixels (default: 1024)+ - **true_cfg_scale**: True CFG scale (default: 1.0, optimal for Qwen)+ - **seed**: Optional seed for reproducible results+ """++ if os.environ.get("BEARER_TOKEN", False):+ if not token or token.credentials != os.environ["BEARER_TOKEN"]:+ raise HTTPException(+ status_code=status.HTTP_401_UNAUTHORIZED,+ detail="Incorrect bearer token",+ headers={"WWW-Authenticate": "Bearer"},+ )++ try:+ # Validate reasonable size limits+ if request.width > 2048 or request.height > 2048:+ raise HTTPException(+ status_code=400,+ detail="Maximum image size is 2048x2048 pixels.",+ )++ if request.width < 256 or request.height < 256:+ raise HTTPException(+ status_code=400,+ detail="Minimum image size is 256x256 pixels.",+ )++ model = NunchakuQwenImageModel()+ result_bytes = model.inference.remote(+ prompt=request.prompt,+ negative_prompt=request.negative_prompt,+ width=request.width,+ height=request.height,+ true_cfg_scale=request.true_cfg_scale,+ seed=request.seed,+ )++ return Response(+ content=result_bytes,+ media_type="image/png",+ headers={+ "Content-Disposition": f"inline; filename=nunchaku_qwen_image_{request.seed or 'random'}.png"+ },+ )++ except Exception as e:+ raise HTTPException(+ status_code=500, detail=f"Error generating image: {str(e)}"+ )++ return web_appdiff --git a/episode_24/n8n_cloudflare_flux_schnell.json b/episode_24/n8n_cloudflare_flux_schnell.jsonnew file mode 100644index 0000000..70c940e--- /dev/null+++ b/episode_24/n8n_cloudflare_flux_schnell.json@@ -0,0 +1,279 @@+{+ "name": "Cloudflare Workers AI Flux subworkflow",+ "nodes": [+ {+ "parameters": {+ "operation": "toBinary",+ "sourceProperty": "result.image",+ "options": {}+ },+ "type": "n8n-nodes-base.convertToFile",+ "typeVersion": 1.1,+ "position": [+ 192,+ 0+ ],+ "id": "8ca149ce-c9ca-412b-a908-cf02e8df4b78",+ "name": "Convert to File"+ },+ {+ "parameters": {+ "url": "https://api.cloudflare.com/client/v4/accounts",+ "authentication": "genericCredentialType",+ "genericAuthType": "httpBearerAuth",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -208,+ 0+ ],+ "id": "8e5b1fe3-f67e-4568-ac3e-a85b97ba87ef",+ "name": "Get accounts",+ "credentials": {+ "httpBearerAuth": {+ "id": "jMnxp4DM3Ed198G6",+ "name": "Cloudflare"+ }+ }+ },+ {+ "parameters": {+ "method": "POST",+ "url": "=https://api.cloudflare.com/client/v4/accounts/{{ $json.result[0].id }}/ai/run/@cf/black-forest-labs/flux-1-schnell",+ "authentication": "genericCredentialType",+ "genericAuthType": "httpBearerAuth",+ "sendBody": true,+ "specifyBody": "=json",+ "bodyParameters": {+ "parameters": [+ {}+ ]+ },+ "jsonBody": "={{ \n\nJSON.stringify(\n {\n prompt: $('Setup workflow').item.json.prompt,\n seed: $('Setup workflow').item.json.seed,\n \"width\": $('Setup workflow').item.json.width,\n \"height\": $('Setup workflow').item.json.height,\n \"steps\": $('Setup workflow').item.json.steps\n }\n) \n\n}}",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -16,+ 0+ ],+ "id": "f2d17b27-8c0c-48a8-ac83-82038f91f9b8",+ "name": "Get Flux Schnell image",+ "credentials": {+ "httpBearerAuth": {+ "id": "jMnxp4DM3Ed198G6",+ "name": "Cloudflare"+ }+ }+ },+ {+ "parameters": {+ "workflowInputs": {+ "values": [+ {+ "name": "prompt"+ },+ {+ "name": "width",+ "type": "number"+ },+ {+ "name": "height",+ "type": "number"+ }+ ]+ }+ },+ "type": "n8n-nodes-base.executeWorkflowTrigger",+ "typeVersion": 1.1,+ "position": [+ -864,+ 0+ ],+ "id": "60a7e3aa-996e-4da7-a94b-96fc1a8308ed",+ "name": "When Executed by Another Workflow"+ },+ {+ "parameters": {+ "errorMessage": "The size of the image (width x height) is larger than 1 megapixel"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ -192,+ -224+ ],+ "id": "f0e7d7f9-1826-42d0-9986-a84723b5f1f6",+ "name": "Image > 1 megapixel"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "f6e30a82-76cd-4bfd-9bc5-b7fffb15e35c",+ "leftValue": "={{ $json.width * $json.height > 1048576 }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -448,+ -16+ ],+ "id": "2a02b7c6-12bd-4e2a-b578-c63cc1a57ea3",+ "name": "Check image size"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "3f7d5020-0710-4f3c-858f-0485a2bd2963",+ "name": "width",+ "value": "={{ $json.width || 1024 }}",+ "type": "number"+ },+ {+ "id": "39b906fa-3e0b-45b9-9c1b-95cbc51e195d",+ "name": "prompt",+ "value": "={{ $json.prompt }}",+ "type": "string"+ },+ {+ "id": "3f8593d2-cfb3-437a-a9fc-4430995cb78f",+ "name": "height",+ "value": "={{ $json.height || 1024 }}",+ "type": "number"+ },+ {+ "id": "065181ef-404a-4860-9019-976e6e8391e0",+ "name": "seed",+ "value": "={{ Math.floor(Math.random() * 100000000) }}",+ "type": "number"+ },+ {+ "id": "2c131da3-e708-4468-bb09-d400e7e5f28c",+ "name": "steps",+ "value": 4,+ "type": "number"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -656,+ 0+ ],+ "id": "8d13a67b-763b-468a-8f34-f1b5ed9e69bb",+ "name": "Setup workflow"+ }+ ],+ "pinData": {+ "When Executed by Another Workflow": [+ {+ "json": {+ "prompt": "A cat at the beach",+ "width": 1024,+ "height": 768+ }+ }+ ]+ },+ "connections": {+ "Get accounts": {+ "main": [+ [+ {+ "node": "Get Flux Schnell image",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Get Flux Schnell image": {+ "main": [+ [+ {+ "node": "Convert to File",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "When Executed by Another Workflow": {+ "main": [+ [+ {+ "node": "Setup workflow",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Check image size": {+ "main": [+ [+ {+ "node": "Image > 1 megapixel",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Get accounts",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup workflow": {+ "main": [+ [+ {+ "node": "Check image size",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "active": false,+ "settings": {+ "executionOrder": "v1"+ },+ "versionId": "989aca08-327f-4d9a-a1f2-c62d86f92c31",+ "meta": {+ "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"+ },+ "id": "qUcfFrY2UvwlIjbX",+ "tags": []+}\ No newline at end of filediff --git a/episode_24/n8n_modal_flux_dev.json b/episode_24/n8n_modal_flux_dev.jsonnew file mode 100644index 0000000..25cae7d--- /dev/null+++ b/episode_24/n8n_modal_flux_dev.json@@ -0,0 +1,296 @@+{+ "name": "Modal: flux dev subworkflow",+ "nodes": [+ {+ "parameters": {+ "workflowInputs": {+ "values": [+ {+ "name": "prompt"+ },+ {+ "name": "width",+ "type": "number"+ },+ {+ "name": "height",+ "type": "number"+ },+ {+ "name": "steps",+ "type": "number"+ },+ {+ "name": "guidance_scale",+ "type": "number"+ }+ ]+ }+ },+ "type": "n8n-nodes-base.executeWorkflowTrigger",+ "typeVersion": 1.1,+ "position": [+ -1056,+ 0+ ],+ "id": "a8b8c8b0-b73d-4039-aca4-c1d386c081d1",+ "name": "When Executed by Another Workflow"+ },+ {+ "parameters": {+ "errorMessage": "The size of the image (width x height) is larger than 1 megapixel"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ 0,+ -288+ ],+ "id": "202dfb57-c1c5-4174-b5ce-0811c9719d5b",+ "name": "Image > 1 megapixel"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "f6e30a82-76cd-4bfd-9bc5-b7fffb15e35c",+ "leftValue": "={{ $json.width * $json.height > 1048576 }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -448,+ -16+ ],+ "id": "7bc0143c-c84f-48c4-99e4-1d753141fb6f",+ "name": "Check image size"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "3f7d5020-0710-4f3c-858f-0485a2bd2963",+ "name": "width",+ "value": "={{ $('When Executed by Another Workflow').item.json.width || 1024 }}",+ "type": "number"+ },+ {+ "id": "39b906fa-3e0b-45b9-9c1b-95cbc51e195d",+ "name": "prompt",+ "value": "={{ $('When Executed by Another Workflow').item.json.prompt }}",+ "type": "string"+ },+ {+ "id": "3f8593d2-cfb3-437a-a9fc-4430995cb78f",+ "name": "height",+ "value": "={{ $('When Executed by Another Workflow').item.json.height || 1024 }}",+ "type": "number"+ },+ {+ "id": "065181ef-404a-4860-9019-976e6e8391e0",+ "name": "seed",+ "value": "={{ Math.floor(Math.random() * 100000000) }}",+ "type": "number"+ },+ {+ "id": "2c131da3-e708-4468-bb09-d400e7e5f28c",+ "name": "steps",+ "value": "={{ $('When Executed by Another Workflow').item.json.steps || 40 }}",+ "type": "number"+ },+ {+ "id": "95df4de2-196a-4f64-a2ed-3959ede14154",+ "name": "url",+ "value": "={{ ((u) => { let s = u.trim(); if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s; const parts = s.split('/'); return parts[0] + '//' + parts[2]; })($json.MODAL_URL) }}/generate",+ "type": "string"+ },+ {+ "id": "aa3da4e4-9c9e-4cf4-b8bf-f7f08717ec02",+ "name": "guidance_scale",+ "value": "={{ $('When Executed by Another Workflow').item.json.guidance_scale || 3.5 }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -656,+ 0+ ],+ "id": "3e4fadf2-1a32-44eb-8c81-b393a717e224",+ "name": "Setup workflow"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup workflow').item.json.url }}",+ "sendBody": true,+ "bodyParameters": {+ "parameters": [+ {+ "name": "prompt",+ "value": "={{ $('Setup workflow').item.json.prompt }}"+ },+ {+ "name": "width",+ "value": "={{ $('Setup workflow').item.json.width }}"+ },+ {+ "name": "height",+ "value": "={{ $('Setup workflow').item.json.height }}"+ },+ {+ "name": "seed",+ "value": "={{ $('Setup workflow').item.json.seed }}"+ },+ {+ "name": "steps",+ "value": "={{ $('Setup workflow').item.json.steps }}"+ },+ {+ "name": "guidance_scale",+ "value": "={{ $('Setup workflow').item.json.guidance_scale }}"+ }+ ]+ },+ "options": {+ "redirect": {+ "redirect": {}+ }+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 16,+ 0+ ],+ "id": "0a6a94cd-6d62-4f77-b118-f6abf834f4f3",+ "name": "HTTP Request"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "2df0bb38-9912-4978-ad56-3236c5d54126",+ "name": "MODAL_URL",+ "value": "<<insert your modal server url here>>",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -848,+ 0+ ],+ "id": "1732669f-0019-45d7-8c64-34fa2a16db7e",+ "name": "Edit Fields"+ }+ ],+ "pinData": {+ "When Executed by Another Workflow": [+ {+ "json": {+ "prompt": "A cat at the beach",+ "width": 1024,+ "height": 768+ }+ }+ ]+ },+ "connections": {+ "When Executed by Another Workflow": {+ "main": [+ [+ {+ "node": "Edit Fields",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Check image size": {+ "main": [+ [+ {+ "node": "Image > 1 megapixel",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "HTTP Request",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup workflow": {+ "main": [+ [+ {+ "node": "Check image size",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "HTTP Request": {+ "main": [+ []+ ]+ },+ "Edit Fields": {+ "main": [+ [+ {+ "node": "Setup workflow",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "active": false,+ "settings": {+ "executionOrder": "v1"+ },+ "versionId": "086d50f7-ce1e-457c-a1a4-7b46ba68e1cc",+ "meta": {+ "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"+ },+ "id": "J4CdzHvSiRhLbRi4",+ "tags": []+}\ No newline at end of filediff --git a/episode_24/n8n_modal_flux_schnell.json b/episode_24/n8n_modal_flux_schnell.jsonnew file mode 100644index 0000000..de084f4--- /dev/null+++ b/episode_24/n8n_modal_flux_schnell.json@@ -0,0 +1,290 @@+{+ "name": "Modal: flux schnell subworkflow",+ "nodes": [+ {+ "parameters": {+ "workflowInputs": {+ "values": [+ {+ "name": "prompt"+ },+ {+ "name": "width",+ "type": "number"+ },+ {+ "name": "height",+ "type": "number"+ }+ ]+ }+ },+ "type": "n8n-nodes-base.executeWorkflowTrigger",+ "typeVersion": 1.1,+ "position": [+ -1056,+ 0+ ],+ "id": "7b7d7308-c230-454b-aea4-2857b1bfbf0e",+ "name": "When Executed by Another Workflow"+ },+ {+ "parameters": {+ "errorMessage": "The size of the image (width x height) is larger than 1 megapixel"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ 0,+ -288+ ],+ "id": "f447c7aa-ba33-40d9-9131-9ccd7b0546af",+ "name": "Image > 1 megapixel"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "f6e30a82-76cd-4bfd-9bc5-b7fffb15e35c",+ "leftValue": "={{ $json.width * $json.height > 1048576 }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -448,+ -16+ ],+ "id": "648a8c7f-72d5-41c3-b722-f63af8eac4fc",+ "name": "Check image size"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "3f7d5020-0710-4f3c-858f-0485a2bd2963",+ "name": "width",+ "value": "={{ $('When Executed by Another Workflow').item.json.width || 1024 }}",+ "type": "number"+ },+ {+ "id": "39b906fa-3e0b-45b9-9c1b-95cbc51e195d",+ "name": "prompt",+ "value": "={{ $('When Executed by Another Workflow').item.json.prompt }}",+ "type": "string"+ },+ {+ "id": "3f8593d2-cfb3-437a-a9fc-4430995cb78f",+ "name": "height",+ "value": "={{ $('When Executed by Another Workflow').item.json.height || 1024 }}",+ "type": "number"+ },+ {+ "id": "065181ef-404a-4860-9019-976e6e8391e0",+ "name": "seed",+ "value": "={{ Math.floor(Math.random() * 100000000) }}",+ "type": "number"+ },+ {+ "id": "2c131da3-e708-4468-bb09-d400e7e5f28c",+ "name": "steps",+ "value": 4,+ "type": "number"+ },+ {+ "id": "95df4de2-196a-4f64-a2ed-3959ede14154",+ "name": "url",+ "value": "={{ ((u) => { let s = u.trim(); if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s; const parts = s.split('/'); return parts[0] + '//' + parts[2]; })($json.MODAL_URL) }}/generate",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -656,+ 0+ ],+ "id": "9585531d-b5ed-482f-a2f5-a47e819a8388",+ "name": "Setup workflow"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup workflow').item.json.url }}",+ "authentication": "genericCredentialType",+ "genericAuthType": "httpBearerAuth",+ "sendBody": true,+ "bodyParameters": {+ "parameters": [+ {+ "name": "prompt",+ "value": "={{ $('Setup workflow').item.json.prompt }}"+ },+ {+ "name": "width",+ "value": "={{ $('Setup workflow').item.json.width }}"+ },+ {+ "name": "height",+ "value": "={{ $('Setup workflow').item.json.height }}"+ },+ {+ "name": "seed",+ "value": "={{ $('Setup workflow').item.json.seed }}"+ },+ {+ "name": "steps",+ "value": "={{ $('Setup workflow').item.json.steps }}"+ },+ {+ "name": "cfg",+ "value": "1"+ }+ ]+ },+ "options": {+ "redirect": {+ "redirect": {}+ }+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 16,+ 0+ ],+ "id": "9c19e1d4-4037-45bb-92bc-aaf7129cfd34",+ "name": "HTTP Request",+ "credentials": {+ "httpBearerAuth": {+ "id": "GrRG19fsfDRR0wwM",+ "name": "Bearer Auth account 6"+ }+ }+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "2df0bb38-9912-4978-ad56-3236c5d54126",+ "name": "MODAL_URL",+ "value": "<<insert your modal server url here>>",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -848,+ 0+ ],+ "id": "6fd20fb6-9931-44e4-9eab-d057972e4623",+ "name": "Configure me"+ }+ ],+ "pinData": {+ "When Executed by Another Workflow": [+ {+ "json": {+ "prompt": "A cat at the beach",+ "width": 1024,+ "height": 768+ }+ }+ ]+ },+ "connections": {+ "When Executed by Another Workflow": {+ "main": [+ [+ {+ "node": "Configure me",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Check image size": {+ "main": [+ [+ {+ "node": "Image > 1 megapixel",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "HTTP Request",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup workflow": {+ "main": [+ [+ {+ "node": "Check image size",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "HTTP Request": {+ "main": [+ []+ ]+ },+ "Configure me": {+ "main": [+ [+ {+ "node": "Setup workflow",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "active": false,+ "settings": {+ "executionOrder": "v1"+ },+ "versionId": "ebbc7288-a51b-4431-957d-670f8a28c4ed",+ "meta": {+ "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"+ },+ "id": "7xU7Q9gCrLxWxtqm",+ "tags": []+}\ No newline at end of filediff --git a/episode_24/n8n_modal_qwen.json b/episode_24/n8n_modal_qwen.jsonnew file mode 100644index 0000000..3a2232d--- /dev/null+++ b/episode_24/n8n_modal_qwen.json@@ -0,0 +1,299 @@+{+ "name": "Modal: flux qwen subworkflow",+ "nodes": [+ {+ "parameters": {+ "workflowInputs": {+ "values": [+ {+ "name": "prompt"+ },+ {+ "name": "width",+ "type": "number"+ },+ {+ "name": "height",+ "type": "number"+ },+ {+ "name": "steps",+ "type": "number"+ },+ {+ "name": "true_cfg_scale",+ "type": "number"+ },+ {+ "name": "negative_prompt"+ }+ ]+ }+ },+ "type": "n8n-nodes-base.executeWorkflowTrigger",+ "typeVersion": 1.1,+ "position": [+ -1056,+ 0+ ],+ "id": "83a7b193-4906-4cd8-a7e0-56934eaee9fc",+ "name": "When Executed by Another Workflow"+ },+ {+ "parameters": {+ "errorMessage": "The size of the image (width x height) is larger than 1 megapixel"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ 0,+ -288+ ],+ "id": "99a717f0-1d19-42b6-aed7-14041055fb83",+ "name": "Image > 1 megapixel"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "f6e30a82-76cd-4bfd-9bc5-b7fffb15e35c",+ "leftValue": "={{ $json.width * $json.height > 1048576 }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -448,+ -16+ ],+ "id": "35bdd391-b905-4d87-be0d-8d0c258b01d0",+ "name": "Check image size"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "3f7d5020-0710-4f3c-858f-0485a2bd2963",+ "name": "width",+ "value": "={{ $('When Executed by Another Workflow').item.json.width || 1024 }}",+ "type": "number"+ },+ {+ "id": "39b906fa-3e0b-45b9-9c1b-95cbc51e195d",+ "name": "prompt",+ "value": "={{ $('When Executed by Another Workflow').item.json.prompt }}",+ "type": "string"+ },+ {+ "id": "3f8593d2-cfb3-437a-a9fc-4430995cb78f",+ "name": "height",+ "value": "={{ $('When Executed by Another Workflow').item.json.height || 1024 }}",+ "type": "number"+ },+ {+ "id": "065181ef-404a-4860-9019-976e6e8391e0",+ "name": "seed",+ "value": "={{ Math.floor(Math.random() * 100000000) }}",+ "type": "number"+ },+ {+ "id": "95df4de2-196a-4f64-a2ed-3959ede14154",+ "name": "url",+ "value": "={{ ((u) => { let s = u.trim(); if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s; const parts = s.split('/'); return parts[0] + '//' + parts[2]; })($json.MODAL_URL) }}/generate",+ "type": "string"+ },+ {+ "id": "aa3da4e4-9c9e-4cf4-b8bf-f7f08717ec02",+ "name": "true_cfg_scale",+ "value": "={{ $('When Executed by Another Workflow').item.json.true_cfg_scale || 1 }}",+ "type": "string"+ },+ {+ "id": "eb6faa0a-c27d-4c8a-946d-eded3387c803",+ "name": "negative_prompt",+ "value": "={{ $('When Executed by Another Workflow').item.json.negative_prompt || \"\" }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -656,+ 0+ ],+ "id": "b2378616-69a8-4775-b806-9c23369303b1",+ "name": "Setup workflow"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup workflow').item.json.url }}",+ "sendBody": true,+ "bodyParameters": {+ "parameters": [+ {+ "name": "prompt",+ "value": "={{ $('Setup workflow').item.json.prompt }}"+ },+ {+ "name": "width",+ "value": "={{ $('Setup workflow').item.json.width }}"+ },+ {+ "name": "height",+ "value": "={{ $('Setup workflow').item.json.height }}"+ },+ {+ "name": "seed",+ "value": "={{ $('Setup workflow').item.json.seed }}"+ },+ {+ "name": "negative_prompt",+ "value": "={{ $('Setup workflow').item.json.negative_prompt }}"+ },+ {+ "name": "true_cfg_scale",+ "value": "={{ $('Setup workflow').item.json.true_cfg_scale }}"+ }+ ]+ },+ "options": {+ "redirect": {+ "redirect": {}+ }+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ 16,+ 0+ ],+ "id": "0e2e959b-fcde-4f11-b429-f4c09de03a8b",+ "name": "HTTP Request"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "2df0bb38-9912-4978-ad56-3236c5d54126",+ "name": "MODAL_URL",+ "value": "<<insert your modal server url here>>",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -848,+ 0+ ],+ "id": "5f6d968a-6f40-4c57-867a-dc52f8fb0407",+ "name": "Configure me"+ }+ ],+ "pinData": {+ "When Executed by Another Workflow": [+ {+ "json": {+ "prompt": "A cat at the beach",+ "width": 1024,+ "height": 768+ }+ }+ ]+ },+ "connections": {+ "When Executed by Another Workflow": {+ "main": [+ [+ {+ "node": "Configure me",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Check image size": {+ "main": [+ [+ {+ "node": "Image > 1 megapixel",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "HTTP Request",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup workflow": {+ "main": [+ [+ {+ "node": "Check image size",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "HTTP Request": {+ "main": [+ []+ ]+ },+ "Configure me": {+ "main": [+ [+ {+ "node": "Setup workflow",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "active": false,+ "settings": {+ "executionOrder": "v1"+ },+ "versionId": "a99d7e4b-b50e-4380-a911-5b18808f4b28",+ "meta": {+ "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"+ },+ "id": "xKTb9cV6MWLzJAo0",+ "tags": []+}\ No newline at end of filediff --git a/episode_24/n8n_tiktok_scary.json b/episode_24/n8n_tiktok_scary.jsonnew file mode 100644index 0000000..9a212dd--- /dev/null+++ b/episode_24/n8n_tiktok_scary.json@@ -0,0 +1,2050 @@+{+ "name": "Scary Stories TikTok video - flux",+ "nodes": [+ {+ "parameters": {+ "options": {}+ },+ "type": "n8n-nodes-base.splitInBatches",+ "typeVersion": 3,+ "position": [+ -2624,+ 1920+ ],+ "id": "7bb1ad9e-f7e7-461e-b09d-bb717723b8da",+ "name": "Loop Over Items"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage",+ "sendBody": true,+ "contentType": "multipart-form-data",+ "bodyParameters": {+ "parameters": [+ {+ "parameterType": "formBinaryData",+ "name": "file",+ "inputDataFieldName": "data"+ },+ {+ "name": "media_type",+ "value": "image"+ }+ ]+ },+ "options": {+ "timeout": 10000+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1936,+ 1664+ ],+ "id": "ad740a94-fea2-473d-a695-067179b4b202",+ "name": "Upload image to server",+ "retryOnFail": true+ },+ {+ "parameters": {+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage/{{ $('Start generating TTS (chatterbox)').item.json.file_id }}/status",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1264,+ 1728+ ],+ "id": "80eb632c-8fd9-4455-b1ea-6aabcf78f4b4",+ "name": "Get status of TTS generation",+ "retryOnFail": true+ },+ {+ "parameters": {+ "rules": {+ "values": [+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "leftValue": "={{ $json.status }}",+ "rightValue": "ready",+ "operator": {+ "type": "string",+ "operation": "equals"+ },+ "id": "91402596-3978-4dfc-91b7-9ffe3521b862"+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "ready"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "0c29765e-4213-434c-9bf3-c5e854dd6ee8",+ "leftValue": "={{ $json.status }}",+ "rightValue": "processing",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "processing"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "4a6cfd86-e690-417e-aa6d-ae497e1177ae",+ "leftValue": "={{ $json.status }}",+ "rightValue": "not_found",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "failed"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.switch",+ "typeVersion": 3.2,+ "position": [+ -1088,+ 1728+ ],+ "id": "bae1224f-5fd3-4575-9dca-b1bdeb43597b",+ "name": "TTS status switch"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/video-tools/generate/tts-captioned-video",+ "sendBody": true,+ "contentType": "form-urlencoded",+ "specifyBody": "string",+ "body": "={{ \n\n[\n `background_id=${$('Upload image to server').last().json.file_id}`,\n `audio_id=${$json.tts_audio_id}`,\n `text=${encodeURIComponent($('Loop Over Items').last().json.text)}`,\n 'caption_config_line_count=2',\n 'caption_config_line_max_length=15',\n 'caption_config_font_size=80',\n 'caption_config_font_bold=true',\n 'caption_config_font_color=ffffff',\n 'caption_config_subtitle_position=bottom',\n 'image_effect=pan'\n].filter(Boolean).join('&')\n\n}}",+ "options": {+ "redirect": {+ "redirect": {}+ }+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -688,+ 1760+ ],+ "id": "34c51c19-4045-4a34-aad4-bec2b72c6e0f",+ "name": "Start generating captioned TTS video"+ },+ {+ "parameters": {+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage/{{ $('Start generating captioned TTS video').item.json.file_id }}/status",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -288,+ 1792+ ],+ "id": "ed38c5ff-b2a1-473e-b8d2-361112bd4100",+ "name": "Get video generation status",+ "retryOnFail": true+ },+ {+ "parameters": {+ "rules": {+ "values": [+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "leftValue": "={{ $json.status }}",+ "rightValue": "ready",+ "operator": {+ "type": "string",+ "operation": "equals"+ },+ "id": "91402596-3978-4dfc-91b7-9ffe3521b862"+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "ready"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "0c29765e-4213-434c-9bf3-c5e854dd6ee8",+ "leftValue": "={{ $json.status }}",+ "rightValue": "processing",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "processing"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "4a6cfd86-e690-417e-aa6d-ae497e1177ae",+ "leftValue": "={{ $json.status }}",+ "rightValue": "not_found",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "failed"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.switch",+ "typeVersion": 3.2,+ "position": [+ -96,+ 1760+ ],+ "id": "59c6e307-eac3-492f-9a71-271a0c2a3465",+ "name": "Video generation switch"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "a7fdacca-749e-4f69-84fd-50075e0e3409",+ "name": "video_id",+ "value": "={{ $('Start generating captioned TTS video').item.json.file_id }}",+ "type": "string"+ },+ {+ "id": "6c99c267-5c41-4697-ba19-b51d9e8c9a4e",+ "name": "tts_id",+ "value": "={{ $('Setup TTS file_id').item.json.tts_audio_id }}",+ "type": "string"+ },+ {+ "id": "21dd08a7-f785-4829-8609-a99950f21572",+ "name": "image_id",+ "value": "={{ $('Upload image to server').item.json.file_id }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ 160,+ 1776+ ],+ "id": "25bd04bf-d19d-4468-b782-c3eff45aca06",+ "name": "Setup media fields"+ },+ {+ "parameters": {+ "aggregate": "aggregateAllItemData",+ "options": {}+ },+ "type": "n8n-nodes-base.aggregate",+ "typeVersion": 1,+ "position": [+ -2176,+ 2128+ ],+ "id": "bb41b15b-8a6c-47a0-bbab-a9fc83c28e74",+ "name": "Combine loop items"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/video-tools/merge",+ "sendBody": true,+ "contentType": "form-urlencoded",+ "bodyParameters": {+ "parameters": [+ {+ "name": "video_ids",+ "value": "={{ $json.data.map(item => item.video_id).join(',') }}"+ },+ {+ "name": "background_music_id",+ "value": "={{ $('Set background music id').first().json.background_music_id ?? '' }}"+ },+ {+ "name": "background_music_volume",+ "value": "={{ $('Configure me').first().json.background_music_volume }}"+ }+ ]+ },+ "options": {+ "redirect": {+ "redirect": {}+ }+ }+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1984,+ 2128+ ],+ "id": "85848992-ca2f-4e40-8def-b3e350130f36",+ "name": "Start merging the videos"+ },+ {+ "parameters": {+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage/{{ $('Start merging the videos').item.json.file_id }}/status",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1568,+ 2160+ ],+ "id": "4fe08b74-4a8d-4746-acdc-81d7ef1a3391",+ "name": "Get status of the video merge"+ },+ {+ "parameters": {+ "rules": {+ "values": [+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "leftValue": "={{ $json.status }}",+ "rightValue": "ready",+ "operator": {+ "type": "string",+ "operation": "equals"+ },+ "id": "91402596-3978-4dfc-91b7-9ffe3521b862"+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "ready"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "0c29765e-4213-434c-9bf3-c5e854dd6ee8",+ "leftValue": "={{ $json.status }}",+ "rightValue": "processing",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "processing"+ },+ {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "4a6cfd86-e690-417e-aa6d-ae497e1177ae",+ "leftValue": "={{ $json.status }}",+ "rightValue": "not_found",+ "operator": {+ "type": "string",+ "operation": "equals",+ "name": "filter.operator.equals"+ }+ }+ ],+ "combinator": "and"+ },+ "renameOutput": true,+ "outputKey": "failed"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.switch",+ "typeVersion": 3.2,+ "position": [+ -1376,+ 2160+ ],+ "id": "e85c1098-6b51-4ff4-94bd-d47d585be80a",+ "name": "Video merge status switch"+ },+ {+ "parameters": {+ "amount": 1+ },+ "type": "n8n-nodes-base.wait",+ "typeVersion": 1.1,+ "position": [+ -1440,+ 1728+ ],+ "id": "ed85c87d-7c8a-4c6c-bb89-8a69cd65e824",+ "name": "Wait until the TTS gets generated",+ "webhookId": "2514de72-3647-43da-b9b3-a42643e20fad"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/audio-tools/tts/chatterbox",+ "sendBody": true,+ "contentType": "multipart-form-data",+ "bodyParameters": {+ "parameters": [+ {+ "name": "text",+ "value": "={{ $('Loop Over Items').item.json.text }}"+ },+ {+ "name": "sample_audio_id",+ "value": "={{ $('Set sample voice id').first().json.sample_audio_id ?? '' }}"+ },+ {+ "name": "exaggeration",+ "value": "={{ $('Configure me').first().json.chatterbox_exaggeration }}"+ },+ {+ "name": "cfg_weight",+ "value": "={{ $('Configure me').first().json.chatterbox_cfg_weight }}"+ },+ {+ "name": "temperature",+ "value": "={{ $('Configure me').first().json.chatterbox_temperature }}"+ },+ {+ "name": "chunk_chars",+ "value": "256"+ },+ {+ "name": "chunk_silence_ms",+ "value": "350"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1616,+ 1728+ ],+ "id": "c777c647-92d3-4004-a14a-79430bb44ffc",+ "name": "Start generating TTS (chatterbox)"+ },+ {+ "parameters": {+ "amount": 1+ },+ "type": "n8n-nodes-base.wait",+ "typeVersion": 1.1,+ "position": [+ -480,+ 1792+ ],+ "id": "6a1399c4-40cd-495a-9ab0-0e02590e2796",+ "name": "Wait until the video gets generated",+ "webhookId": "0a15a64e-4548-44d6-8a6c-ac3a2290489d"+ },+ {+ "parameters": {+ "amount": 1+ },+ "type": "n8n-nodes-base.wait",+ "typeVersion": 1.1,+ "position": [+ -1760,+ 2160+ ],+ "id": "91d454ac-e1ae-4599-bf53-b3c870f913f6",+ "name": "Wait until the videos gets merged together",+ "webhookId": "9bddef78-bb8b-4743-ba72-d3771dfd1295"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "d41f1ef6-7591-41b7-805d-94b58caba5c4",+ "name": "tts_audio_id",+ "value": "={{ $('Start generating TTS (chatterbox)').item.json.file_id }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -896,+ 1760+ ],+ "id": "329fb792-f51c-45fa-9056-944e137598d8",+ "name": "Setup TTS file_id"+ },+ {+ "parameters": {+ "model": {+ "__rl": true,+ "value": "gpt-4.1",+ "mode": "list",+ "cachedResultName": "gpt-4.1"+ },+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",+ "typeVersion": 1.2,+ "position": [+ 320,+ 240+ ],+ "id": "65b879a2-79eb-44ea-adb4-38a1ca365a36",+ "name": "OpenAI Chat Model",+ "credentials": {+ "openAiApi": {+ "id": "tGvJRP2th9CbI2oq",+ "name": "OpenAi account 2"+ }+ }+ },+ {+ "parameters": {+ "content": "# Pick your choice of LLM ⚠️\n⚠️ Make sure to deactive/delete the rest of the LLMs after selecting one",+ "height": 700,+ "width": 700,+ "color": 3+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -224,+ 112+ ],+ "id": "dc3256c3-1ddf-42a6-8f18-4e74347f598f",+ "name": "Sticky Note2"+ },+ {+ "parameters": {+ "model": "qwen3:32b",+ "options": {+ "numCtx": 16048+ }+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatOllama",+ "typeVersion": 1,+ "position": [+ -144,+ 240+ ],+ "id": "78e68b27-9047-4e50-9285-7b352c68fee5",+ "name": "Ollama Chat Model",+ "credentials": {+ "ollamaApi": {+ "id": "cWXUsJ0LsqnzOEx0",+ "name": "Ollama account"+ }+ },+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",+ "typeVersion": 1,+ "position": [+ 192,+ 240+ ],+ "id": "db1793ef-ca22-45d4-a092-495e104db90f",+ "name": "DeepSeek Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "model": "tngtech/deepseek-r1t-chimera:free",+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",+ "typeVersion": 1,+ "position": [+ 320,+ 592+ ],+ "id": "96000b7d-c063-4205-99fc-f11341f05f21",+ "name": "OpenRouter Chat Model",+ "credentials": {+ "openRouterApi": {+ "id": "pKxg2Rhtt3cG3h19",+ "name": "OpenRouter account"+ }+ },+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",+ "typeVersion": 1,+ "position": [+ -144,+ 592+ ],+ "id": "ba7deb6e-4c78-4a9c-8d21-2798b3a2c65c",+ "name": "Google Gemini Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",+ "typeVersion": 1,+ "position": [+ -144,+ 400+ ],+ "id": "81494eda-37f5-4fb8-ace5-e5bbbb702d68",+ "name": "Azure OpenAI Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatXAiGrok",+ "typeVersion": 1,+ "position": [+ 32,+ 400+ ],+ "id": "d33c9aec-e487-4eeb-9ea1-1b11d3651318",+ "name": "xAI Grok Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "model": {+ "__rl": true,+ "mode": "list",+ "value": "claude-sonnet-4-20250514",+ "cachedResultName": "Claude 4 Sonnet"+ },+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",+ "typeVersion": 1.3,+ "position": [+ 192,+ 400+ ],+ "id": "a5703c35-4f28-462e-884c-a5e058879068",+ "name": "Anthropic Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatXAiGrok",+ "typeVersion": 1,+ "position": [+ 320,+ 400+ ],+ "id": "46e14cef-fd8a-4218-8dc5-9577ec9e2fb6",+ "name": "xAI Grok Chat Model1",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatGroq",+ "typeVersion": 1,+ "position": [+ 192,+ 592+ ],+ "id": "88518290-e488-480d-819d-25c1c0f56906",+ "name": "Groq Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatAwsBedrock",+ "typeVersion": 1,+ "position": [+ 32,+ 240+ ],+ "id": "17a41b19-6234-443d-a19e-6502e859c13f",+ "name": "AWS Bedrock Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "options": {}+ },+ "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",+ "typeVersion": 1,+ "position": [+ 32,+ 592+ ],+ "id": "6f96334e-9623-44db-b58e-0fe2de6e3346",+ "name": "Mistral Cloud Chat Model",+ "disabled": true+ },+ {+ "parameters": {+ "content": "# 2. Create script from the story",+ "height": 560,+ "width": 360+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -144,+ 848+ ],+ "id": "a0ba9903-999d-402b-b5bd-380fbdd18e7c",+ "name": "Sticky Note5"+ },+ {+ "parameters": {+ "content": "# 6. Merge the videos",+ "height": 360,+ "width": 1180+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -2288,+ 2000+ ],+ "id": "52d3b545-4559-44e8-bbc5-4a57a544cc24",+ "name": "Sticky Note6"+ },+ {+ "parameters": {+ "content": "# 3. Generate an image with Flux ⚠️",+ "height": 520,+ "width": 580+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -2288,+ 1440+ ],+ "id": "f397feda-e78d-4255-abea-2c3cdb8fb235",+ "name": "Sticky Note7"+ },+ {+ "parameters": {+ "content": "# 4. Create speech from text",+ "height": 520,+ "width": 900+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1664,+ 1440+ ],+ "id": "34b0736b-f068-4622-afa4-fa2c895b3f49",+ "name": "Sticky Note8"+ },+ {+ "parameters": {+ "content": "# 5. Generate captioned video",+ "height": 520,+ "width": 1040+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -720,+ 1440+ ],+ "id": "2eb3991d-d59d-4c4a-8a64-3b1007cfc593",+ "name": "Sticky Note9"+ },+ {+ "parameters": {+ "text": "=<Instructions>\nUsing the inspirations below, write a completely new scary story. \n\nUse the following structure for the story, and make sure it's coherent and the reading level is 8th grade. Make it sound like a camp counsellor telling the story to people around the campfire. Don't greet/address the audience, just start telling the story. Don't mention the campfire.\n\n1. Act 1: Set the scene with the protagonist and the antagonist. Start building up the sense of unease or the source of fear.\n2. Act 2: Growing tension between the protagonist and the antagonist\n3. Act 3: Conflict goes to a head\n4. Act 4: Aftermath\n\n\nFor each scene, create an image prompt that we'll use with an image generation tool.\n\nCreate the image generation prompt using the ImageTemplate below.\nAdd \"Do not add text or characters to the final image.\" to the end of each image prompt.\n\nUse the following art style for the images:\n\n{{ $('Configure me').first().json.art_style }}\n</Instructions>\n\n<ImageTemplate>\nGenerate an image that matches the following story scene, using the provided art style.\n\nStory scene:\n{ADD_STORY_SCENE_HERE}\n</ImageTemplate>\n\n<Inspirations>\n{{ $json.items.map(item => `<Story>\n${item.title}\n\n${item.selftext}\n</Story>`).join('\\n') }}\n</Inspirations>",+ "schemaType": "manual",+ "inputSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"scenes\": {\n \"type\": \"array\",\n \"description\": \"Scenes for the story\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"text\": {\n \"type\": \"string\",\n \"description\": \"the text of the scene, it will be used for TTS\"\n },\n \"image_prompt\": {\n \"type\": \"string\",\n \"description\": \"prompt for image generation\"\n }\n },\n \"required\": [\n \"text\",\n \"image_prompt\"\n ]\n }\n },\n \"title\": {\n \"type\": \"string\",\n \"description\": \"the title of the tiktok video\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"the description of the tiktok video\"\n },\n \"tags\": {\n \"type\": \"array\",\n \"description\": \"tags for sharing the video on tiktok\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"scenes\",\n \"title\",\n \"description\",\n \"tags\"\n ]\n}",+ "options": {+ "systemPromptTemplate": "You are an expert copywriter. You write exciting short stories."+ }+ },+ "type": "@n8n/n8n-nodes-langchain.informationExtractor",+ "typeVersion": 1.1,+ "position": [+ -80,+ 1008+ ],+ "id": "e87bc792-ee55-43d2-8297-cff392be0b63",+ "name": "Create the script",+ "retryOnFail": true+ },+ {+ "parameters": {+ "fieldToSplitOut": "output.scenes",+ "options": {}+ },+ "type": "n8n-nodes-base.splitOut",+ "typeVersion": 1,+ "position": [+ -16,+ 1232+ ],+ "id": "88d3906a-eac4-44f8-96b7-88883bde62d8",+ "name": "Split Out"+ },+ {+ "parameters": {+ "content": "# How to set up this automation?\n\n## Make sure to use n8n `1.97.1` or higher, lower versions could break the stuctured output node\n\n## 1. Add the AI Agents No-Code Tools server URL to the Configure me node, and optionally your Postiz server URL\n## 2. Select the LLM you want to use, make sure to deactivate the rest\n## 3. Add your free Together.ai API key to the Generate AI image node\n## 4. Setup the Postiz nodes with your credentials\n",+ "height": 360,+ "width": 1680,+ "color": 6+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1936,+ 448+ ],+ "id": "14e0156c-faae-4f00-9087-4a76d4faf36b",+ "name": "Sticky Note14"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "7bbb518a-c4f1-49a5-9e72-3e9d939b131b",+ "name": "AI_AGENTS_NO_CODE_TOOLS_URL",+ "value": "<<insert your server url here>>",+ "type": "string"+ },+ {+ "id": "34f8b468-b669-46ed-be9d-e77e15f36380",+ "name": "background_music_volume",+ "value": 0.1,+ "type": "number"+ },+ {+ "id": "a725aaf1-c91e-4d5b-87f9-d540d309098c",+ "name": "chatterbox_exaggeration",+ "value": 0.5,+ "type": "number"+ },+ {+ "id": "d048e31d-f1cb-48ac-9ff2-13f1028c843e",+ "name": "chatterbox_cfg_weight",+ "value": 0.5,+ "type": "number"+ },+ {+ "id": "96943158-11f6-4731-9d4b-dbae0862d7ab",+ "name": "chatterbox_temperature",+ "value": 0.8,+ "type": "number"+ },+ {+ "id": "fd0df44b-b7d3-45af-8556-bd77ef83b2db",+ "name": "art_style",+ "value": "=Scene: Highly cinematic with a moody, noir atmosphere, inspired by detective and crime thriller films from the 1970s and 1980s. The setting can be anything, from an interior room to a suburban street, depicted in a tense, suspenseful moment. Emphasize the following details:\n\n- **Lighting:** Strong directional lighting with deep shadows; use cool blue and teal color grading with subtle hints of warm light from lamps or windows. The lighting should cast dramatic shadows across the scene.\n- **Mood:** Mysterious, somber, and slightly surreal ambiance, evoking a sense of unease or suspense.\n- **Subjects:** Human figures should appear contemplative, searching, tense, or whatever the scene calls for.\n- **Color Palette:** Dominant cold blues and teals contrasted by occasional soft warm light from lamps or daylight through curtains. The overall tone should be desaturated and muted.\n- **Cinematic Framing:** Framed like a movie still, with careful composition and leading lines, sometimes viewed through doorways or windows for added depth.\n- **Exterior Scenes:** Overcast skies, muted and overexposed daylight.\n\n**Style influences:** Denis Villeneuve, David Fincher, *Zodiac*, *Mindhunter*, *True Detective*, Gregory Crewdson, neo-noir photography.",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -2176,+ 1088+ ],+ "id": "fe266c64-8433-4e1f-af6a-d6e329060281",+ "name": "Configure me"+ },+ {+ "parameters": {+ "content": "# Configure me ⚠️\n",+ "height": 560,+ "width": 300,+ "color": 3+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -2288,+ 848+ ],+ "id": "b0271d3b-3d8e-4ba1-9c30-1f7ae5fdae59",+ "name": "Sticky Note12"+ },+ {+ "parameters": {+ "url": "={{ $json.AI_AGENTS_NO_CODE_TOOLS_URL }}/health",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1696,+ 1008+ ],+ "id": "5e6d028d-0abc-44c6-bf0b-48e75e19d00e",+ "name": "HTTP Request",+ "onError": "continueErrorOutput"+ },+ {+ "parameters": {+ "errorMessage": "The server is not running or isn't configured"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ -1696,+ 1232+ ],+ "id": "dff13334-1273-486b-a857-9ca00bfc3ffa",+ "name": "Server isn't ready"+ },+ {+ "parameters": {+ "content": "# Test connection",+ "height": 560,+ "width": 420,+ "color": 7+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1936,+ 848+ ],+ "id": "b7d65dfe-ac4f-45cc-90fd-7fa205ecbe91",+ "name": "Sticky Note15"+ },+ {+ "parameters": {+ "content": "# 📚 [Join our Skool community for support, premium content and more!](https://www.skool.com/ai-agents-az/about?w9)\n\n## Get premium variations of this workflow!\n\n## Be part of a growing community and help us create more content like this",+ "height": 300,+ "width": 700,+ "color": 6+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -2688,+ 512+ ],+ "id": "aa2d1cdf-d633-4a73-aab6-f3d9aa9dd81d",+ "name": "Sticky Note16"+ },+ {+ "parameters": {+ "formTitle": "Scary story creator for TikTok",+ "formFields": {+ "values": [+ {+ "fieldLabel": "Background music",+ "fieldType": "file",+ "multipleFiles": false,+ "acceptFileTypes": ".mp3"+ },+ {+ "fieldLabel": "Sample voice",+ "fieldType": "file",+ "multipleFiles": false,+ "acceptFileTypes": ".wav, .mp3"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.formTrigger",+ "typeVersion": 2.2,+ "position": [+ -2528,+ 1088+ ],+ "id": "360885ec-8f03-4537-9af2-59aa016ee80f",+ "name": "On form submission",+ "webhookId": "ca95244d-4bdb-4f80-ae49-e5e723d5ef90"+ },+ {+ "parameters": {+ "jsCode": "return $('On form submission').first()"+ },+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ -1248,+ 928+ ],+ "id": "83ba55e0-f0a9-46d5-8b59-03f94e352949",+ "name": "Relay background music"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "7aec0c26-8c27-4aa6-bec7-1f65d9fe3aaf",+ "name": "background_music_id",+ "value": "={{ $json.file_id ?? '' }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -1248,+ 1232+ ],+ "id": "d5c83051-6f0d-4408-b7c3-58ff5a711050",+ "name": "Set background music id"+ },+ {+ "parameters": {+ "jsCode": "return $('On form submission').first()"+ },+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ -800,+ 928+ ],+ "id": "d1cf82c5-6e1e-4313-9535-260cc1199ea3",+ "name": "Relay sample audio"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "7aec0c26-8c27-4aa6-bec7-1f65d9fe3aaf",+ "name": "sample_audio_id",+ "value": "={{ $json.file_id ?? '' }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -800,+ 1248+ ],+ "id": "9ee57fc4-0761-4659-bb30-a7f75aee044b",+ "name": "Set sample voice id"+ },+ {+ "parameters": {+ "content": "# Upload background music",+ "height": 560,+ "width": 400,+ "color": 7+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1488,+ 848+ ],+ "id": "5cdd589d-6c34-47e5-b052-5bc49f836e0c",+ "name": "Sticky Note17"+ },+ {+ "parameters": {+ "content": "# Upload voice sample",+ "height": 560,+ "width": 400,+ "color": 7+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1040,+ 848+ ],+ "id": "3e1eabc4-3f15-4469-b467-d36f12e85ccb",+ "name": "Sticky Note18"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage",+ "sendBody": true,+ "contentType": "multipart-form-data",+ "bodyParameters": {+ "parameters": [+ {+ "parameterType": "formBinaryData",+ "name": "file",+ "inputDataFieldName": "=Background_music"+ },+ {+ "name": "media_type",+ "value": "audio"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -1248,+ 1072+ ],+ "id": "e81f08fe-2136-43c3-b00b-d346a1eb7d08",+ "name": "Upload background music to the server"+ },+ {+ "parameters": {+ "method": "POST",+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage",+ "sendBody": true,+ "contentType": "multipart-form-data",+ "bodyParameters": {+ "parameters": [+ {+ "parameterType": "formBinaryData",+ "name": "file",+ "inputDataFieldName": "=Sample_voice"+ },+ {+ "name": "media_type",+ "value": "audio"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -800,+ 1072+ ],+ "id": "c528ff58-868a-484e-9f20-062b04ecb227",+ "name": "Upload voice sample to the server"+ },+ {+ "parameters": {+ "assignments": {+ "assignments": [+ {+ "id": "7d55d6da-a78c-4a28-9343-0ea9035a0aa3",+ "name": "AI_AGENTS_NO_CODE_TOOLS_URL",+ "value": "={{ ((u) => { let s = u.trim(); if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s; const parts = s.split('/'); return parts[0] + '//' + parts[2]; })($json.AI_AGENTS_NO_CODE_TOOLS_URL) }}",+ "type": "string"+ }+ ]+ },+ "options": {}+ },+ "type": "n8n-nodes-base.set",+ "typeVersion": 3.4,+ "position": [+ -1904,+ 1088+ ],+ "id": "478b5803-8984-4422-9791-417a82655ef5",+ "name": "Setup defaults"+ },+ {+ "parameters": {+ "url": "=https://www.reddit.com/r/creepyencounters/top.json?t=year&limit=100",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -528,+ 992+ ],+ "id": "cd076ecb-c2b1-4935-9847-3a7bc762c90d",+ "name": "Get stories from reddit"+ },+ {+ "parameters": {+ "jsCode": "function getRandomItems(A, X) {\n return A\n .slice()\n .sort(() => Math.random() - 0.5)\n .slice(0, X);\n}\n\nconst items = getRandomItems($input.all().map(item => item.json.data), 3);\n\nreturn [{\n json: {\n items\n }\n}]"+ },+ "type": "n8n-nodes-base.code",+ "typeVersion": 2,+ "position": [+ -336,+ 1200+ ],+ "id": "60e2d81c-a878-4d7f-a180-c818cd408a0f",+ "name": "Code"+ },+ {+ "parameters": {+ "content": "# 1. Source inspirations from Reddit",+ "height": 560,+ "width": 420+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -608,+ 848+ ],+ "id": "9cdac72b-3683-42f5-a89b-f6a1f3ab5cd1",+ "name": "Sticky Note11"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "6b9c15f3-2db9-4a1e-a688-4fc4e95ded53",+ "leftValue": "={{ $('On form submission').item.json['Sample voice'] }}",+ "rightValue": "",+ "operator": {+ "type": "object",+ "operation": "exists",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -1008,+ 1072+ ],+ "id": "4ad3e17d-be7f-4fe4-8e39-76b5229b9730",+ "name": "Upload voice sample?"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "6b9c15f3-2db9-4a1e-a688-4fc4e95ded53",+ "leftValue": "={{ $('On form submission').item.json['Background music'] }}",+ "rightValue": "",+ "operator": {+ "type": "object",+ "operation": "exists",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.if",+ "typeVersion": 2.2,+ "position": [+ -1440,+ 1120+ ],+ "id": "3bef1100-48bf-4f3a-8231-60707d6994ce",+ "name": "Upload music?"+ },+ {+ "parameters": {+ "fieldToSplitOut": "data.children",+ "options": {}+ },+ "type": "n8n-nodes-base.splitOut",+ "typeVersion": 1,+ "position": [+ -336,+ 992+ ],+ "id": "611af899-7b53-49b4-b965-c256d70e9d2f",+ "name": "For each post"+ },+ {+ "parameters": {+ "conditions": {+ "options": {+ "caseSensitive": true,+ "leftValue": "",+ "typeValidation": "strict",+ "version": 2+ },+ "conditions": [+ {+ "id": "a6926aaf-b4ac-4e90-ac82-c32796fd7e0c",+ "leftValue": "={{ $json.data.selftext.length }}",+ "rightValue": 1500,+ "operator": {+ "type": "number",+ "operation": "gt"+ }+ },+ {+ "id": "c81af31b-c032-4960-870f-ee7b6a6dc029",+ "leftValue": "={{ $json.data.is_video }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "false",+ "singleValue": true+ }+ },+ {+ "id": "659ef810-1298-4df0-81f4-e049c2c020b1",+ "leftValue": "={{ $json.data.media === null }}",+ "rightValue": "",+ "operator": {+ "type": "boolean",+ "operation": "true",+ "singleValue": true+ }+ }+ ],+ "combinator": "and"+ },+ "options": {}+ },+ "type": "n8n-nodes-base.filter",+ "typeVersion": 2.2,+ "position": [+ -528,+ 1200+ ],+ "id": "8d01995f-c306-456d-9ae5-49364275be07",+ "name": "Remove short ones"+ },+ {+ "parameters": {+ "workflowId": {+ "__rl": true,+ "value": "7xU7Q9gCrLxWxtqm",+ "mode": "list",+ "cachedResultName": "Modal: flux schnell subworkflow"+ },+ "workflowInputs": {+ "mappingMode": "defineBelow",+ "value": {+ "prompt": "={{ $json.image_prompt }}",+ "width": 768,+ "height": 1024+ },+ "matchingColumns": [],+ "schema": [+ {+ "id": "prompt",+ "displayName": "prompt",+ "required": false,+ "defaultMatch": false,+ "display": true,+ "canBeUsedToMatch": true,+ "type": "string"+ },+ {+ "id": "width",+ "displayName": "width",+ "required": false,+ "defaultMatch": false,+ "display": true,+ "canBeUsedToMatch": true,+ "type": "number"+ },+ {+ "id": "height",+ "displayName": "height",+ "required": false,+ "defaultMatch": false,+ "display": true,+ "canBeUsedToMatch": true,+ "type": "number"+ }+ ],+ "attemptToConvertTypes": false,+ "convertFieldsToString": true+ },+ "options": {}+ },+ "type": "n8n-nodes-base.executeWorkflow",+ "typeVersion": 1.2,+ "position": [+ -2176,+ 1664+ ],+ "id": "bc82cee5-9fc8-4eb6-add0-c662b8911233",+ "name": "Execute Workflow",+ "executeOnce": false,+ "retryOnFail": true+ },+ {+ "parameters": {+ "errorMessage": "Error while generating the video"+ },+ "type": "n8n-nodes-base.stopAndError",+ "typeVersion": 1,+ "position": [+ -976,+ 2208+ ],+ "id": "a941a566-550e-467e-9e4c-35330698bece",+ "name": "Stop and Error"+ },+ {+ "parameters": {+ "url": "={{ $('Setup defaults').first().json.AI_AGENTS_NO_CODE_TOOLS_URL }}/api/v1/media/storage/{{ $('Start merging the videos').item.json.file_id }}",+ "options": {}+ },+ "type": "n8n-nodes-base.httpRequest",+ "typeVersion": 4.2,+ "position": [+ -816,+ 2128+ ],+ "id": "a2f9a9a8-8927-4758-a25a-6a583a7ac552",+ "name": "Download the video"+ },+ {+ "parameters": {+ "content": "# 7. Done",+ "height": 360,+ "width": 444,+ "color": 4+ },+ "type": "n8n-nodes-base.stickyNote",+ "typeVersion": 1,+ "position": [+ -1056,+ 2000+ ],+ "id": "451a879e-abda-4e72-95a8-9f5856685ddc",+ "name": "Sticky Note"+ }+ ],+ "pinData": {},+ "connections": {+ "Loop Over Items": {+ "main": [+ [+ {+ "node": "Combine loop items",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Execute Workflow",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Upload image to server": {+ "main": [+ [+ {+ "node": "Start generating TTS (chatterbox)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Get status of TTS generation": {+ "main": [+ [+ {+ "node": "TTS status switch",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "TTS status switch": {+ "main": [+ [+ {+ "node": "Setup TTS file_id",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Wait until the TTS gets generated",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Start generating TTS (chatterbox)",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Start generating captioned TTS video": {+ "main": [+ [+ {+ "node": "Wait until the video gets generated",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Get video generation status": {+ "main": [+ [+ {+ "node": "Video generation switch",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Video generation switch": {+ "main": [+ [+ {+ "node": "Setup media fields",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Wait until the video gets generated",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup media fields": {+ "main": [+ [+ {+ "node": "Loop Over Items",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Combine loop items": {+ "main": [+ [+ {+ "node": "Start merging the videos",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Start merging the videos": {+ "main": [+ [+ {+ "node": "Wait until the videos gets merged together",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Get status of the video merge": {+ "main": [+ [+ {+ "node": "Video merge status switch",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Video merge status switch": {+ "main": [+ [+ {+ "node": "Download the video",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Wait until the videos gets merged together",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Stop and Error",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Wait until the TTS gets generated": {+ "main": [+ [+ {+ "node": "Get status of TTS generation",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Start generating TTS (chatterbox)": {+ "main": [+ [+ {+ "node": "Wait until the TTS gets generated",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Wait until the video gets generated": {+ "main": [+ [+ {+ "node": "Get video generation status",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Wait until the videos gets merged together": {+ "main": [+ [+ {+ "node": "Get status of the video merge",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup TTS file_id": {+ "main": [+ [+ {+ "node": "Start generating captioned TTS video",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "OpenAI Chat Model": {+ "ai_languageModel": [+ [+ {+ "node": "Create the script",+ "type": "ai_languageModel",+ "index": 0+ }+ ]+ ]+ },+ "Create the script": {+ "main": [+ [+ {+ "node": "Split Out",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Split Out": {+ "main": [+ [+ {+ "node": "Loop Over Items",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Configure me": {+ "main": [+ [+ {+ "node": "Setup defaults",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "HTTP Request": {+ "main": [+ [+ {+ "node": "Upload music?",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Server isn't ready",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "On form submission": {+ "main": [+ [+ {+ "node": "Configure me",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Relay background music": {+ "main": [+ [+ {+ "node": "Upload background music to the server",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Set background music id": {+ "main": [+ [+ {+ "node": "Upload voice sample?",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Relay sample audio": {+ "main": [+ [+ {+ "node": "Upload voice sample to the server",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Set sample voice id": {+ "main": [+ [+ {+ "node": "Get stories from reddit",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Upload background music to the server": {+ "main": [+ [+ {+ "node": "Set background music id",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Upload voice sample to the server": {+ "main": [+ [+ {+ "node": "Set sample voice id",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Setup defaults": {+ "main": [+ [+ {+ "node": "HTTP Request",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Get stories from reddit": {+ "main": [+ [+ {+ "node": "For each post",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Code": {+ "main": [+ [+ {+ "node": "Create the script",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Upload voice sample?": {+ "main": [+ [+ {+ "node": "Relay sample audio",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Set sample voice id",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Upload music?": {+ "main": [+ [+ {+ "node": "Relay background music",+ "type": "main",+ "index": 0+ }+ ],+ [+ {+ "node": "Set background music id",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "For each post": {+ "main": [+ [+ {+ "node": "Remove short ones",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Remove short ones": {+ "main": [+ [+ {+ "node": "Code",+ "type": "main",+ "index": 0+ }+ ]+ ]+ },+ "Execute Workflow": {+ "main": [+ [+ {+ "node": "Upload image to server",+ "type": "main",+ "index": 0+ }+ ]+ ]+ }+ },+ "active": false,+ "settings": {+ "executionOrder": "v1"+ },+ "versionId": "e242b853-9f05-4ee3-b30f-6f8dd7e4a97d",+ "meta": {+ "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"+ },+ "id": "IHU8kyc46QVYYVny",+ "tags": [+ {+ "createdAt": "2025-06-18T16:25:08.935Z",+ "updatedAt": "2025-06-18T16:25:08.935Z",+ "id": "1t0O0JsvnM933ez8",+ "name": "youtube"+ }+ ]+}\ No newline at end of file