Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Originals O2: Fuobe Soul, Soul HD and Soul Cinema as one model on both engines

Claudecd383a69e4d3
diff --git a/docs/research/fuobe-originals-recipes-5.json b/docs/research/fuobe-originals-recipes-5.json
index a48bf150..ebde7bf9 100644
--- a/docs/research/fuobe-originals-recipes-5.json
+++ b/docs/research/fuobe-originals-recipes-5.json
@@ -280,7 +280,174 @@
"acceleration": "string default=\"regular\" enum=[\"none\", \"regular\", \"high\"]",
"image_size": "anyOf[object {height:integer default=512 maximum=14142; width:integer default=512 maximum=14142}, string enum=[\"square_hd\", \"square\", \"portrait_4_3\", \"portrait_"
},
- "pathAccepts": "URL, HuggingFace repo ID (owner/repo) to lora weights."
+ "pathAccepts": "URL, HuggingFace repo ID (owner/repo) to lora weights.",
+ "inputs": {
+ "prompt": {
+ "type": "string",
+ "required": true,
+ "desc": "The prompt to generate an image from.",
+ "examples": [
+ "A young Asian woman with long, vibrant purple hair stands on a sunlit sandy beach, posing confidently with her left hand resting on her hip. She gazes directly at the camera with a neutral expression. A sleek black ribbon bow is tied neatly on the right side of her head, just above her ear. She wears a flowing white cotton dress with a fitted bodice and a flared skirt that reaches mid-calf, slightly lifted by a gentle sea breeze. The beach behind her features fine, pale golden sand with subtle footprints, leading to calm turquoise waves under a clear blue sky with soft, wispy clouds. The lighting is natural daylight, casting soft shadows to her left, indicating late afternoon sun. The horizon line is visible in the background, with a faint silhouette of distant dunes. Her skin tone is fair with a natural glow, and her facial features are delicately defined. The composition is centered on her figure, framed from mid-thigh up, with shallow depth of field blurring the distant waves slightly."
+ ]
+ },
+ "image_size": {
+ "type": "union",
+ "variants": [
+ {
+ "type": "object",
+ "fields": {
+ "width": {
+ "type": "integer",
+ "required": false,
+ "default": 512,
+ "maximum": 14142,
+ "minimumExclusive": 0,
+ "desc": "The width of the generated image."
+ },
+ "height": {
+ "type": "integer",
+ "required": false,
+ "default": 512,
+ "maximum": 14142,
+ "minimumExclusive": 0,
+ "desc": "The height of the generated image."
+ }
+ },
+ "required": false
+ },
+ {
+ "type": "enum",
+ "values": [
+ "square_hd",
+ "square",
+ "portrait_4_3",
+ "portrait_16_9",
+ "landscape_4_3",
+ "landscape_16_9",
+ "auto"
+ ],
+ "valueType": "string",
+ "required": false
+ }
+ ],
+ "default": "auto",
+ "desc": "The size of the generated image."
+ },
+ "num_inference_steps": {
+ "type": "integer",
+ "required": false,
+ "default": 8,
+ "minimum": 1,
+ "maximum": 8,
+ "desc": "The number of inference steps to perform."
+ },
+ "seed": {
+ "nullable": true,
+ "type": "integer",
+ "required": false,
+ "desc": "\n The same seed and the same prompt given to the same version of the model\n will output the same image every time.\n "
+ },
+ "sync_mode": {
+ "type": "boolean",
+ "required": false,
+ "default": false,
+ "desc": "If `True`, the media will be returned as a data URI and the output data won't be available in the request history."
+ },
+ "num_images": {
+ "type": "integer",
+ "required": false,
+ "default": 1,
+ "minimum": 1,
+ "maximum": 4,
+ "desc": "The number of images to generate."
+ },
+ "enable_safety_checker": {
+ "type": "boolean",
+ "required": false,
+ "default": true,
+ "desc": "If set to true, the safety checker will be enabled. Disabling it requires account authorization; unauthorized requests are always checked, and images flagged as unsafe are returned as black images."
+ },
+ "output_format": {
+ "type": "enum",
+ "values": [
+ "jpeg",
+ "png",
+ "webp"
+ ],
+ "valueType": "string",
+ "required": false,
+ "default": "png",
+ "desc": "The format of the generated image."
+ },
+ "acceleration": {
+ "type": "enum",
+ "values": [
+ "none",
+ "regular",
+ "high"
+ ],
+ "valueType": "string",
+ "required": false,
+ "default": "regular",
+ "desc": "The acceleration level to use."
+ },
+ "enable_prompt_expansion": {
+ "type": "boolean",
+ "required": false,
+ "default": false,
+ "desc": "Whether to enable prompt expansion. Note: this will increase the price by 0.0025 credits per request."
+ },
+ "image_url": {
+ "type": "string",
+ "required": true,
+ "desc": "URL of Image for Image-to-Image generation.",
+ "examples": [
+ "https://storage.googleapis.com/falserverless/example_inputs/z-image-turbo-i2i-input.png"
+ ]
+ },
+ "strength": {
+ "type": "number",
+ "required": false,
+ "default": 0.6,
+ "maximum": 1,
+ "minimumExclusive": 0,
+ "desc": "The strength of the image-to-image conditioning."
+ },
+ "loras": {
+ "type": "array",
+ "items": "object",
+ "itemSchema": {
+ "path": {
+ "type": "string",
+ "required": false,
+ "desc": "URL, HuggingFace repo ID (owner/repo) to lora weights."
+ },
+ "scale": {
+ "type": "number",
+ "required": false,
+ "default": 1,
+ "minimum": 0,
+ "maximum": 4,
+ "desc": "Scale factor for LoRA application (0.0 to 4.0)."
+ }
+ },
+ "itemRequired": [
+ "path"
+ ],
+ "required": false,
+ "default": [],
+ "desc": "List of LoRA weights to apply (maximum 3)."
+ }
+ },
+ "keyFields": {
+ "prompt": "prompt",
+ "seed": "seed",
+ "numOutputs": "num_images",
+ "loras": "loras",
+ "image": "image_url"
+ },
+ "output": "video.url",
+ "inputsChecked": "2026-10-25"
},
{
"provider": "fal",
diff --git a/scripts/fetch-hosted-schemas.py b/scripts/fetch-hosted-schemas.py
index 06484a76..8b7f3570 100644
--- a/scripts/fetch-hosted-schemas.py
+++ b/scripts/fetch-hosted-schemas.py
@@ -13,6 +13,7 @@ keyFields (which input is the prompt, the image, the clip…) are this script's
earlier research files. scripts/gen-cloud-models.py reads both lists.
Run: python3 scripts/fetch-hosted-schemas.py
+ python3 scripts/fetch-hosted-schemas.py --only fal-ai/z-image/turbo/image-to-image/lora (one endpoint, the rest kept)
"""
import datetime
import json
@@ -44,6 +45,8 @@ LORA = {
"numFrames": "num_frames", "seed": "seed", "loras": "loras"},
"fal-ai/wan/v2.2-a14b/text-to-image/lora": {"prompt": "prompt", "negativePrompt": "negative_prompt", "aspectRatio": "image_size", "seed": "seed", "loras": "loras"},
"fal-ai/z-image/turbo/lora": {k: v for k, v in T2I.items() if k != "negativePrompt"},
+ # Fuobe Soul's edit route (O2): image-to-image with the look's LoRAs; image_size "auto" keeps the picture's shape.
+ "fal-ai/z-image/turbo/image-to-image/lora": {**{k: v for k, v in T2I.items() if k not in ("negativePrompt", "aspectRatio")}, "image": "image_url"},
"fal-ai/qwen-image-2512/lora": T2I,
"prunaai/z-image-turbo-lora": {"prompt": "prompt", "width": "width", "height": "height", "seed": "seed"},
}
@@ -161,7 +164,10 @@ def main():
raw = FILE.read_text(encoding="utf-8")
data = json.loads(raw)
by_id = {e["id"]: e for e in data["hostedLoraEndpoints"]}
+ only = sys.argv[sys.argv.index("--only") + 1:] if "--only" in sys.argv else None
for ep, kf in LORA.items():
+ if only and ep not in only:
+ continue
rec = by_id.get(ep)
if not rec:
sys.exit(f"{ep} is not in hostedLoraEndpoints")
@@ -175,6 +181,9 @@ def main():
rec["output"] = "output[]"
rec["inputsChecked"] = TODAY
print(f"{ep}: {len(rec['inputs'])} inputs")
+ if only:
+ FILE.write_text(json.dumps(data, indent=1, ensure_ascii=False) + "\n", encoding="utf-8")
+ return
base = []
for ep, (op, kf) in BASE.items():
inputs = fal(ep)
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index bb259bf4..d0429bd2 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -69,7 +69,7 @@ M = []
def model(id, name, vendor, family, kind, tagline, routes, badges=None, pricing=None, defaults=None, options=None, fixed=None, hidden=False,
sliders=None, controls=None, api_defaults=None, formats=None, ranged_durations=False, fit_values=False, fps_targets=None, upscale_tiers=None,
- frame_step=None):
+ frame_step=None, original=False, sizes=None):
"""sliders / controls: [(field, label)] read from each route's research inputs (dotted = nested field):
numeric fields with minimum/maximum become sliders, enums become composer controls; both travel as params.extra.
fixed: fields always sent. api_defaults: fields sent unless the request sets them (FieldMap.defaults).
@@ -82,13 +82,16 @@ def model(id, name, vendor, family, kind, tagline, routes, badges=None, pricing=
upscale_tiers: resolutions offered to an upscaler that takes a factor ("Original", "1080p", "4K"): FieldMap.upscaleFactor
turns the tier into target ÷ the clip's shorter edge, within the factor field's limits.
frame_step: video models whose length is a frame count (Wan 2.2: 4n+1, LTX: 8n+1): FieldMap.numFrames.step.
+ original: a Fuobe Original's cloud half (written to ORIGINAL_CLOUD; models.ts joins it to the ComfyUI routes).
+ sizes: {tier: {aspect: [w, h]}}: exact sizes per resolution tier (Fuobe Soul's table): FieldMap.size.table, sent
+ as width / height fields or as one {width, height} object field (fal's image_size); the tiers become the resolutions.
A route's options dict may also set max_images (FieldMap.maxImages), note, loraEndpoint (the same model with LoRAs:
FieldMap.loras comes from its research record) and pin (a Replicate model run by version: the research's version)."""
M.append(dict(id=id, name=name, vendor=vendor, family=family, kind=kind, tagline=tagline, routes=routes,
badges=badges or [], pricing=pricing, defaults=defaults or {}, options=options or {}, fixed=fixed or {}, hidden=hidden,
sliders=sliders or [], controls=controls or [], api_defaults=api_defaults or {}, formats=formats or {},
ranged_durations=ranged_durations, fit_values=fit_values, fps_targets=fps_targets or [], upscale_tiers=upscale_tiers or [],
- frame_step=frame_step))
+ frame_step=frame_step, original=original, sizes=sizes))
# ----- Image
@@ -190,6 +193,35 @@ model("flux-2-klein-4b-cloud", "FLUX.2 [klein] 4B (hosted)", "Black Forest Labs"
model("wan-2-2-a14b-image-cloud", "Wan 2.2 A14B Image (hosted)", "Alibaba Wan", "wan", "image",
"Open-weights Wan 2.2 stills that take Wan LoRAs",
[("t2i", "fal-ai/wan/v2.2-a14b/text-to-image/lora", "fal")], defaults={"aspectRatio": "16:9"})
+# ----- Originals (O2): Fuobe Soul's cloud halves on hosted open weights (docs/research/fuobe-originals-recipes-5.md §4).
+# models.ts joins each to its ComfyUI routes as one model that runs on both engines (ModelDef.engines). Sizes are
+# Soul's table per tier (soul.settings.comfyui.sizes); steps, prompt expansion and format follow the recipe (§4.3).
+SOUL_TIERS = {"720p": "720p tier", "1080p": "1080p tier"}
+SOUL_SIZES = {tier: {a: [int(x) for x in wh.split("x")] for a, wh in next(v for k, v in ORIGINALS["soul"]["settings"]["comfyui"]["sizes"].items() if k.startswith(prefix)).items()}
+ for tier, prefix in SOUL_TIERS.items()}
+SOUL_FAL = {"num_inference_steps": ORIGINALS["soul"]["settings"]["fal"]["num_inference_steps"],
+ "enable_prompt_expansion": ORIGINALS["soul"]["settings"]["fal"]["enable_prompt_expansion"],
+ "output_format": ORIGINALS["soul"]["settings"]["fal"]["output_format"]}
+# Replicate's Z-Image LoRA build: the same 8 steps, a PNG (its default is jpg); guidance stays at its Turbo default 0.
+SOUL_REPLICATE = {"num_inference_steps": SOUL_FAL["num_inference_steps"], "output_format": "png"}
+model("fuobe-soul", "Fuobe Soul", "Fuobe Original", "fuobe-soul", "image",
+ "Soul's 139 looks on open weights: Z-Image Turbo with up to three LoRAs",
+ [("t2i", "fal-ai/z-image/turbo", "fal", {"loraEndpoint": "fal-ai/z-image/turbo/lora", "fixed": SOUL_FAL}),
+ ("t2i", "prunaai/z-image-turbo-lora", "replicate", {"pin": True, "fixed": SOUL_REPLICATE}),
+ # Restyle a picture with the look; the result keeps the picture's shape. strength = how much changes.
+ ("edit", "fal-ai/z-image/turbo/image-to-image", "fal",
+ {"loraEndpoint": "fal-ai/z-image/turbo/image-to-image/lora", "keepSize": True, "fixed": {k: v for k, v in SOUL_FAL.items() if k != "num_inference_steps"}})],
+ original=True, sizes=SOUL_SIZES, sliders=[("strength", "Change")], defaults={"aspectRatio": "3:4", "resolution": "720p"})
+model("fuobe-soul-hd", "Fuobe Soul HD", "Fuobe Original", "fuobe-soul", "image",
+ "Soul's looks on Qwen-Image 2512: clean lettering for posters and signs",
+ [("t2i", "fal-ai/qwen-image-2512", "fal", {"loraEndpoint": "fal-ai/qwen-image-2512/lora", "fixed": {"output_format": "png"}})],
+ original=True, sizes=SOUL_SIZES, pricing=("megapixel", 0.02, "rounded up to whole megapixels", {"roundUp": True}),
+ defaults={"aspectRatio": "3:4", "resolution": "720p"})
+model("fuobe-soul-cinema", "Fuobe Soul Cinema", "Fuobe Original", "fuobe-soul", "image",
+ "One film look: wide cinematic stills with film grain",
+ [("t2i", "fal-ai/z-image/turbo", "fal", {"loraEndpoint": "fal-ai/z-image/turbo/lora", "fixed": SOUL_FAL}),
+ ("t2i", "prunaai/z-image-turbo-lora", "replicate", {"pin": True, "fixed": SOUL_REPLICATE})],
+ original=True, sizes=SOUL_SIZES, defaults={"aspectRatio": "16:9", "resolution": "720p"})
model("imagen-4", "Imagen 4", "Google", "imagen", "image", "Google's photoreal text-to-image",
[("t2i", "google/imagen-4", "replicate")], defaults={"aspectRatio": "1:1"})
@@ -1038,7 +1070,7 @@ def map_fields(fmap):
elif k == "loras":
out += lora_field_names(v)
elif k == "size":
- out += [v["width"], v["height"]]
+ out += [v["key"]] if v.get("key") else [v["width"], v["height"]]
elif k in ("seedRange", "maskFormat", "ranges", "ignore", "maxImages", "omitEmptyPrompt"):
continue
elif isinstance(v, str):
@@ -1421,6 +1453,23 @@ def build_route(op, ep, provider, m, opts, ropts=None):
fmap["size"] = {"width": kf["width"], "height": kf["height"], "multiple": 16, **({"max": min(mx)} if mx else {}),
**({"base": num(w.get("default"))} if num(w.get("default")) else {})}
opts["aspectRatios"] = union(opts.get("aspectRatios", []), IMG_AR)
+ # Exact sizes per tier (Fuobe Soul's table): one {width, height} object field (fal's image_size, whose union takes
+ # an object) or the width / height fields above; the tiers are the model's resolutions.
+ if m.get("sizes") and not ropts.get("keepSize"):
+ spec = inputs.get(kf.get("aspectRatio") or "image_size") or {}
+ takes_object = spec.get("type") == "union" and any((v == "object{width,height}") or (isinstance(v, dict) and v.get("type") == "object") for v in spec.get("variants") or [])
+ if "size" in fmap:
+ fmap["size"]["table"] = m["sizes"]
+ elif takes_object:
+ fmap["size"] = {"key": kf.get("aspectRatio") or "image_size", "multiple": 16, "table": m["sizes"]}
+ kf.pop("aspectRatio", None)
+ else:
+ warn(f"{m['id']}: {ep} takes neither width / height nor an image_size object for its size table")
+ opts["aspectRatios"] = union(opts.get("aspectRatios", []), list(next(iter(m["sizes"].values())).keys()))
+ opts["resolutions"] = union(opts.get("resolutions", []), list(m["sizes"].keys()))
+ elif ropts.get("keepSize"):
+ # The result keeps the input picture's shape (image_size "auto", the API's default).
+ kf.pop("aspectRatio", None)
part4_slots(op, kf, inputs, m, opts, fmap)
# Frame rates an upscaler (or FPS Boost) can reach: params.targetFps -> its target_fps field.
if m.get("fps_targets") and op in ("interpolate", "upscale-video"):
@@ -1613,6 +1662,7 @@ def parse_price(e):
out = []
+originals = []
for m in M:
opts = {}
routes = []
@@ -1692,12 +1742,14 @@ for m in M:
d["pricing"] = pricing
if m["hidden"]:
d["hidden"] = True
- out.append(d)
+ (originals if m["original"] else out).append(d)
ts = (
"// Generated by scripts/gen-cloud-models.py from docs/research/paid-model-apis(-2,-3,-4).json — do not edit by hand.\n"
'import type { ModelDef } from "./types";\n\n'
- f"export const CLOUD_MODELS: ModelDef[] = {json.dumps(out, indent=2)};\n"
+ f"export const CLOUD_MODELS: ModelDef[] = {json.dumps(out, indent=2)};\n\n"
+ "/** The Fuobe Originals' cloud halves (hosted open weights): models.ts joins each to its ComfyUI routes. */\n"
+ f"export const ORIGINAL_CLOUD: ModelDef[] = {json.dumps(originals, indent=2)};\n"
)
(ROOT / "src/lib/catalog/cloud-models.generated.ts").write_text(ts)
-print(f"wrote {len(out)} cloud models")
+print(f"wrote {len(out)} cloud models and {len(originals)} Originals' cloud halves")
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index 8eb96a4c..a2772606 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -16038,3 +16038,593 @@ export const CLOUD_MODELS: ModelDef[] = [
}
}
];
+
+/** The Fuobe Originals' cloud halves (hosted open weights): models.ts joins each to its ComfyUI routes. */
+export const ORIGINAL_CLOUD: ModelDef[] = [
+ {
+ "id": "fuobe-soul",
+ "name": "Fuobe Soul",
+ "vendor": "Fuobe Original",
+ "family": "fuobe-soul",
+ "engine": "cloud",
+ "kind": "image",
+ "tagline": "Soul's 139 looks on open weights: Z-Image Turbo with up to three LoRAs",
+ "routes": [
+ {
+ "op": "t2i",
+ "provider": "fal",
+ "endpoint": "fal-ai/z-image/turbo",
+ "map": {
+ "numOutputs": "num_images",
+ "seed": "seed",
+ "size": {
+ "key": "image_size",
+ "multiple": 16,
+ "table": {
+ "720p": {
+ "1:1": [
+ 1024,
+ 1024
+ ],
+ "3:4": [
+ 896,
+ 1152
+ ],
+ "4:3": [
+ 1152,
+ 896
+ ],
+ "2:3": [
+ 832,
+ 1248
+ ],
+ "3:2": [
+ 1248,
+ 832
+ ],
+ "9:16": [
+ 768,
+ 1344
+ ],
+ "16:9": [
+ 1344,
+ 768
+ ]
+ },
+ "1080p": {
+ "1:1": [
+ 1440,
+ 1440
+ ],
+ "3:4": [
+ 1248,
+ 1664
+ ],
+ "4:3": [
+ 1664,
+ 1248
+ ],
+ "2:3": [
+ 1184,
+ 1776
+ ],
+ "3:2": [
+ 1776,
+ 1184
+ ],
+ "9:16": [
+ 1088,
+ 1920
+ ],
+ "16:9": [
+ 1920,
+ 1088
+ ]
+ }
+ }
+ },
+ "fixed": {
+ "num_inference_steps": 8,
+ "enable_prompt_expansion": false,
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "items",
+ "key": "loras",
+ "max": 3,
+ "range": {
+ "min": 0,
+ "max": 4
+ }
+ }
+ },
+ "loraEndpoint": "fal-ai/z-image/turbo/lora"
+ },
+ {
+ "op": "t2i",
+ "provider": "replicate",
+ "endpoint": "prunaai/z-image-turbo-lora:29c866f1269ef45b736fbcdff00d6da2a555ecf5f4e575c93ab38c2a2f2693a1",
+ "map": {
+ "seed": "seed",
+ "size": {
+ "width": "width",
+ "height": "height",
+ "multiple": 16,
+ "max": 1440,
+ "base": 1024,
+ "table": {
+ "720p": {
+ "1:1": [
+ 1024,
+ 1024
+ ],
+ "3:4": [
+ 896,
+ 1152
+ ],
+ "4:3": [
+ 1152,
+ 896
+ ],
+ "2:3": [
+ 832,
+ 1248
+ ],
+ "3:2": [
+ 1248,
+ 832
+ ],
+ "9:16": [
+ 768,
+ 1344
+ ],
+ "16:9": [
+ 1344,
+ 768
+ ]
+ },
+ "1080p": {
+ "1:1": [
+ 1440,
+ 1440
+ ],
+ "3:4": [
+ 1248,
+ 1664
+ ],
+ "4:3": [
+ 1664,
+ 1248
+ ],
+ "2:3": [
+ 1184,
+ 1776
+ ],
+ "3:2": [
+ 1776,
+ 1184
+ ],
+ "9:16": [
+ 1088,
+ 1920
+ ],
+ "16:9": [
+ 1920,
+ 1088
+ ]
+ }
+ }
+ },
+ "fixed": {
+ "num_inference_steps": 8,
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "arrays",
+ "weights": "lora_weights",
+ "scales": "lora_scales"
+ }
+ }
+ },
+ {
+ "op": "edit",
+ "provider": "fal",
+ "endpoint": "fal-ai/z-image/turbo/image-to-image",
+ "map": {
+ "image": "image_url",
+ "numOutputs": "num_images",
+ "seed": "seed",
+ "fixed": {
+ "enable_prompt_expansion": false,
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "items",
+ "key": "loras",
+ "max": 3,
+ "range": {
+ "min": 0,
+ "max": 4
+ }
+ }
+ },
+ "loraEndpoint": "fal-ai/z-image/turbo/image-to-image/lora"
+ }
+ ],
+ "options": {
+ "aspectRatios": [
+ "1:1",
+ "3:4",
+ "4:3",
+ "2:3",
+ "3:2",
+ "9:16",
+ "16:9",
+ "21:9",
+ "5:4",
+ "4:5"
+ ],
+ "resolutions": [
+ "720p",
+ "1080p"
+ ],
+ "seed": true,
+ "maxOutputs": 4,
+ "maxImages": 1
+ },
+ "defaults": {
+ "aspectRatio": "3:4",
+ "resolution": "720p"
+ },
+ "pricing": {
+ "unit": "megapixel",
+ "usd": 0.005,
+ "withLoras": 0.0085
+ }
+ },
+ {
+ "id": "fuobe-soul-hd",
+ "name": "Fuobe Soul HD",
+ "vendor": "Fuobe Original",
+ "family": "fuobe-soul",
+ "engine": "cloud",
+ "kind": "image",
+ "tagline": "Soul's looks on Qwen-Image 2512: clean lettering for posters and signs",
+ "routes": [
+ {
+ "op": "t2i",
+ "provider": "fal",
+ "endpoint": "fal-ai/qwen-image-2512",
+ "map": {
+ "negativePrompt": "negative_prompt",
+ "numOutputs": "num_images",
+ "seed": "seed",
+ "size": {
+ "key": "image_size",
+ "multiple": 16,
+ "table": {
+ "720p": {
+ "1:1": [
+ 1024,
+ 1024
+ ],
+ "3:4": [
+ 896,
+ 1152
+ ],
+ "4:3": [
+ 1152,
+ 896
+ ],
+ "2:3": [
+ 832,
+ 1248
+ ],
+ "3:2": [
+ 1248,
+ 832
+ ],
+ "9:16": [
+ 768,
+ 1344
+ ],
+ "16:9": [
+ 1344,
+ 768
+ ]
+ },
+ "1080p": {
+ "1:1": [
+ 1440,
+ 1440
+ ],
+ "3:4": [
+ 1248,
+ 1664
+ ],
+ "4:3": [
+ 1664,
+ 1248
+ ],
+ "2:3": [
+ 1184,
+ 1776
+ ],
+ "3:2": [
+ 1776,
+ 1184
+ ],
+ "9:16": [
+ 1088,
+ 1920
+ ],
+ "16:9": [
+ 1920,
+ 1088
+ ]
+ }
+ }
+ },
+ "fixed": {
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "items",
+ "key": "loras",
+ "max": 3,
+ "range": {
+ "min": 0,
+ "max": 4
+ }
+ }
+ },
+ "loraEndpoint": "fal-ai/qwen-image-2512/lora"
+ }
+ ],
+ "options": {
+ "aspectRatios": [
+ "1:1",
+ "3:4",
+ "4:3",
+ "2:3",
+ "3:2",
+ "9:16",
+ "16:9"
+ ],
+ "resolutions": [
+ "720p",
+ "1080p"
+ ],
+ "negativePrompt": true,
+ "seed": true,
+ "maxOutputs": 4
+ },
+ "defaults": {
+ "aspectRatio": "3:4",
+ "resolution": "720p"
+ },
+ "pricing": {
+ "unit": "megapixel",
+ "usd": 0.02,
+ "note": "rounded up to whole megapixels",
+ "roundUp": true,
+ "withLoras": 0.035
+ }
+ },
+ {
+ "id": "fuobe-soul-cinema",
+ "name": "Fuobe Soul Cinema",
+ "vendor": "Fuobe Original",
+ "family": "fuobe-soul",
+ "engine": "cloud",
+ "kind": "image",
+ "tagline": "One film look: wide cinematic stills with film grain",
+ "routes": [
+ {
+ "op": "t2i",
+ "provider": "fal",
+ "endpoint": "fal-ai/z-image/turbo",
+ "map": {
+ "numOutputs": "num_images",
+ "seed": "seed",
+ "size": {
+ "key": "image_size",
+ "multiple": 16,
+ "table": {
+ "720p": {
+ "1:1": [
+ 1024,
+ 1024
+ ],
+ "3:4": [
+ 896,
+ 1152
+ ],
+ "4:3": [
+ 1152,
+ 896
+ ],
+ "2:3": [
+ 832,
+ 1248
+ ],
+ "3:2": [
+ 1248,
+ 832
+ ],
+ "9:16": [
+ 768,
+ 1344
+ ],
+ "16:9": [
+ 1344,
+ 768
+ ]
+ },
+ "1080p": {
+ "1:1": [
+ 1440,
+ 1440
+ ],
+ "3:4": [
+ 1248,
+ 1664
+ ],
+ "4:3": [
+ 1664,
+ 1248
+ ],
+ "2:3": [
+ 1184,
+ 1776
+ ],
+ "3:2": [
+ 1776,
+ 1184
+ ],
+ "9:16": [
+ 1088,
+ 1920
+ ],
+ "16:9": [
+ 1920,
+ 1088
+ ]
+ }
+ }
+ },
+ "fixed": {
+ "num_inference_steps": 8,
+ "enable_prompt_expansion": false,
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "items",
+ "key": "loras",
+ "max": 3,
+ "range": {
+ "min": 0,
+ "max": 4
+ }
+ }
+ },
+ "loraEndpoint": "fal-ai/z-image/turbo/lora"
+ },
+ {
+ "op": "t2i",
+ "provider": "replicate",
+ "endpoint": "prunaai/z-image-turbo-lora:29c866f1269ef45b736fbcdff00d6da2a555ecf5f4e575c93ab38c2a2f2693a1",
+ "map": {
+ "seed": "seed",
+ "size": {
+ "width": "width",
+ "height": "height",
+ "multiple": 16,
+ "max": 1440,
+ "base": 1024,
+ "table": {
+ "720p": {
+ "1:1": [
+ 1024,
+ 1024
+ ],
+ "3:4": [
+ 896,
+ 1152
+ ],
+ "4:3": [
+ 1152,
+ 896
+ ],
+ "2:3": [
+ 832,
+ 1248
+ ],
+ "3:2": [
+ 1248,
+ 832
+ ],
+ "9:16": [
+ 768,
+ 1344
+ ],
+ "16:9": [
+ 1344,
+ 768
+ ]
+ },
+ "1080p": {
+ "1:1": [
+ 1440,
+ 1440
+ ],
+ "3:4": [
+ 1248,
+ 1664
+ ],
+ "4:3": [
+ 1664,
+ 1248
+ ],
+ "2:3": [
+ 1184,
+ 1776
+ ],
+ "3:2": [
+ 1776,
+ 1184
+ ],
+ "9:16": [
+ 1088,
+ 1920
+ ],
+ "16:9": [
+ 1920,
+ 1088
+ ]
+ }
+ }
+ },
+ "fixed": {
+ "num_inference_steps": 8,
+ "output_format": "png"
+ },
+ "loras": {
+ "shape": "arrays",
+ "weights": "lora_weights",
+ "scales": "lora_scales"
+ }
+ }
+ }
+ ],
+ "options": {
+ "aspectRatios": [
+ "1:1",
+ "3:4",
+ "4:3",
+ "2:3",
+ "3:2",
+ "9:16",
+ "16:9",
+ "21:9",
+ "5:4",
+ "4:5"
+ ],
+ "resolutions": [
+ "720p",
+ "1080p"
+ ],
+ "seed": true,
+ "maxOutputs": 4
+ },
+ "defaults": {
+ "aspectRatio": "16:9",
+ "resolution": "720p"
+ },
+ "pricing": {
+ "unit": "megapixel",
+ "usd": 0.005,
+ "withLoras": 0.0085
+ }
+ }
+];
diff --git a/src/lib/catalog/engines.ts b/src/lib/catalog/engines.ts
new file mode 100644
index 00000000..f9b04544
--- /dev/null
+++ b/src/lib/catalog/engines.ts
@@ -0,0 +1,59 @@
+/**
+ * Which engine a model runs on. Most models run on one (ModelDef.engine). A Fuobe Original runs on both
+ * (ModelDef.engines): its ComfyUI routes on the user's GPU, its hosted open-weight routes on fal / Replicate.
+ * The composer's engine switch picks one (GenerationRequest.engine); onEngine() gives the model as it runs
+ * there, so the rest of the app (planning, prices, route choice, the stored row) sees a one-engine model.
+ * Pure, no catalog import: the browser and the server both use it.
+ */
+import type { Engine, ModelDef, ModelRoute, ProviderId } from "./types";
+
+/** The engines a model runs on. */
+export const enginesOf = (m: Pick<ModelDef, "engine" | "engines">): Engine[] => m.engines ?? [m.engine];
+
+/** Runs on this engine (a Fuobe Original runs on both). */
+export const runsOn = (m: Pick<ModelDef, "engine" | "engines">, engine: Engine): boolean => enginesOf(m).includes(engine);
+
+/** A model that runs on both engines. */
+export const dualEngine = (m: Pick<ModelDef, "engines"> | undefined): boolean => (m?.engines?.length ?? 0) > 1;
+
+/** The engine a provider runs on: ComfyUI and the browser are the open engine, the rest the cloud. */
+export const providerEngine = (p: ProviderId): Engine => (p === "comfyui" || p === "local" ? "open" : "cloud");
+
+const views = new WeakMap<ModelDef, Partial<Record<Engine, ModelDef>>>();
+
+/**
+ * The model as it runs on `engine`: an Original keeps that engine's routes only (the same object every time,
+ * so React memos and caches stay put). Any other model comes back as it is.
+ */
+export function onEngine(m: ModelDef, engine: Engine): ModelDef {
+ if (!dualEngine(m) || !runsOn(m, engine)) return m;
+ let cached = views.get(m);
+ if (!cached) views.set(m, (cached = {}));
+ return (cached[engine] ??= { ...m, engine, routes: m.routes.filter((r: ModelRoute) => providerEngine(r.provider) === engine) });
+}
+
+/**
+ * The engine an Original runs on for a request: the one asked for, else the install's engine mode, else the
+ * first one that has a provider connected (the user's GPU first: it is free), else the model's own (a demo).
+ * Throws when the install's engine mode rules out the engine asked for.
+ */
+export function pickEngine(
+ m: ModelDef,
+ asked: Engine | undefined,
+ mode: Engine | "both",
+ ready: (engine: Engine) => boolean,
+): Engine {
+ const engines = enginesOf(m);
+ if (asked && engines.includes(asked)) {
+ if (mode !== "both" && asked !== mode) {
+ throw new Error(
+ mode === "open"
+ ? `${m.name} on the cloud isn't available: this install is set to open source only (Settings → Engine mode). Switch to Open source to run it on your GPU`
+ : `${m.name} on your GPU isn't available: this install is set to paid cloud APIs only (Settings → Engine mode). Switch to Cloud to run it there`,
+ );
+ }
+ return asked;
+ }
+ if (mode !== "both" && engines.includes(mode)) return mode;
+ return engines.find(ready) ?? m.engine;
+}
diff --git a/src/lib/catalog/index.ts b/src/lib/catalog/index.ts
index 7d7c80cb..6486211c 100644
--- a/src/lib/catalog/index.ts
+++ b/src/lib/catalog/index.ts
@@ -3,6 +3,7 @@ import { EFFECTS as RAW_EFFECTS, MOTIONS as RAW_MOTIONS } from "./motions";
import { MODELS } from "./models";
import { LLM_MODELS } from "./llm-models";
import { OSS_LORAS } from "./oss-loras.generated";
+import { runsOn } from "./engines";
import type { Engine, MediaKind, ModelDef, Operation, Preset } from "./types";
MODELS.push(...LLM_MODELS.filter((m) => !MODELS.some((x) => x.id === m.id))); // text steps (translate, write) on the configured LLM; once per hot reload
@@ -99,7 +100,7 @@ export function modelsFor(opts: { kind?: MediaKind; ops?: Operation[]; engine?:
(m) =>
!m.hidden &&
(!opts.kind || m.kind === opts.kind) &&
- (!opts.engine || opts.engine === "all" || m.engine === opts.engine) &&
+ (!opts.engine || opts.engine === "all" || runsOn(m, opts.engine)) &&
(!opts.ops || m.routes.some((r) => opts.ops!.includes(r.op))),
);
}
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 6296ee54..3e3cba85 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1,9 +1,10 @@
-import { CLOUD_MODELS } from "./cloud-models.generated";
+import { CLOUD_MODELS, ORIGINAL_CLOUD } from "./cloud-models.generated";
import { HIGGSFIELD_MODELS, HIGGSFIELD_ROUTES } from "./higgsfield-models.generated";
import { pricingAt } from "./plan";
import { DEFAULT_FPS_TARGET, FPS_TARGETS, SLOW_MOTION } from "@/lib/av/fps";
import { ASR_LANGUAGES, WHISPER_LANGUAGES } from "../speech-languages";
-import { LAST_FRAME_CHAIN, type ModelDef, type ModelRoute, type Operation } from "./types";
+import { SOUL_ASPECTS, SOUL_TIERS } from "./soul";
+import { LAST_FRAME_CHAIN, type ModelDef, type ModelOptions, type ModelRoute, type Operation } from "./types";
/*
* Model catalog.
@@ -1450,6 +1451,52 @@ const cloud: ModelDef[] = [
...cloudTools,
];
+// ---------------------------------------------------------------------------
+// Fuobe Originals: one model on both engines
+
+const ORIGINAL_HALVES = new Map(ORIGINAL_CLOUD.map((m) => [m.id, m]));
+
+/**
+ * A Fuobe Original (build plan O2+): its ComfyUI routes on the user's GPU and its cloud half on hosted open weights
+ * (generated from the research by scripts/gen-cloud-models.py), as one model that runs on both engines. The open
+ * engine is listed first: it's free. The options are the Original's own (the same on both engines).
+ */
+function original(spec: { id: string; open: ModelRoute[]; options: ModelOptions; tagline?: string }): ModelDef {
+ const cloud = ORIGINAL_HALVES.get(spec.id);
+ if (!cloud) throw new Error(`${spec.id} has no cloud half in cloud-models.generated.ts (run pnpm gen:catalog)`);
+ return {
+ ...cloud,
+ engine: "open",
+ engines: ["open", "cloud"],
+ tagline: spec.tagline ?? cloud.tagline,
+ badges: ["new"],
+ routes: [...spec.open, ...cloud.routes],
+ options: spec.options,
+ };
+}
+
+/** Soul's options on both engines (research §4.3): 7 shapes, a 720p (about 1 MP) and a 1080p (about 2 MP) tier, 1–4 images. */
+const SOUL_OPTIONS: ModelOptions = { aspectRatios: SOUL_ASPECTS, resolutions: SOUL_TIERS, seed: true, maxOutputs: 4 };
+
+/** Fuobe Soul, Soul HD and Soul Cinema (src/lib/catalog/soul.ts applies the look). */
+const originals: ModelDef[] = [
+ original({
+ id: "fuobe-soul",
+ open: [comfy("t2i", "z-image-turbo-t2i", "Z-Image Turbo with the look's LoRAs")],
+ options: { ...SOUL_OPTIONS, looks: { label: "Look" } },
+ }),
+ original({
+ id: "fuobe-soul-hd",
+ open: [comfy("t2i", "qwen-image-2512-t2i", "Qwen-Image 2512: the look's words, clean lettering")],
+ options: { ...SOUL_OPTIONS, looks: { label: "Look" }, negativePrompt: true },
+ }),
+ original({
+ id: "fuobe-soul-cinema",
+ open: [comfy("t2i", "z-image-turbo-t2i", "Z-Image Turbo with the film-still LoRAs")],
+ options: SOUL_OPTIONS,
+ }),
+];
+
/** Tools that run entirely in the browser; recorded in the library like any other result. */
const local: ModelDef[] = [
{
@@ -1506,4 +1553,4 @@ const local: ModelDef[] = [
}),
];
-export const MODELS: ModelDef[] = [...cloud, ...open, ...local];
+export const MODELS: ModelDef[] = [...originals, ...cloud, ...open, ...local];
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index 56dff2d3..c157e386 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -93,13 +93,19 @@ export function framedLength(f: FieldMap["numFrames"] | undefined, seconds: numb
return Math.abs(made - seconds) > 0.25 ? made : undefined;
}
-/** Width and height for an aspect ratio on a `base`×`base` pixel budget (FieldMap.size). */
-export function sizeValue(f: NonNullable<FieldMap["size"]>, aspectRatio: string | undefined): { width: number; height: number } {
+/**
+ * Width and height for an aspect ratio (FieldMap.size): the table's size for the tier and shape when it has one
+ * (Fuobe Soul: its first tier when the tier is unknown), else the shape on a `base`×`base` pixel budget; neither
+ * side above `max` (Replicate's Z-Image takes 1440).
+ */
+export function sizeValue(f: NonNullable<FieldMap["size"]>, aspectRatio: string | undefined, resolution?: string): { width: number; height: number } {
const base = f.base ?? 1024;
const ratio = (aspectRatio && ratioOf(aspectRatio)) || 1;
const round = (v: number) => Math.max(f.multiple, Math.round(v / f.multiple) * f.multiple);
- let width = round(base * Math.sqrt(ratio));
- let height = round(base / Math.sqrt(ratio));
+ const tier = f.table && (f.table[resolution ?? ""] ?? Object.values(f.table)[0]);
+ const exact = tier && aspectRatio ? tier[aspectRatio] : undefined;
+ let width = exact ? exact[0] : round(base * Math.sqrt(ratio));
+ let height = exact ? exact[1] : round(base / Math.sqrt(ratio));
if (f.max !== undefined && Math.max(width, height) > f.max) {
const k = f.max / Math.max(width, height);
width = Math.min(f.max, round(width * k));
@@ -344,9 +350,10 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
if (map.numLayers && input.numLayers !== undefined) out[map.numLayers] = input.numLayers;
if (map.palette && input.palette?.length) out[map.palette.key] = paletteValue(map.palette.format, input.palette);
if (map.size) {
- const { width, height } = sizeValue(map.size, input.aspectRatio);
- out[map.size.width] = width;
- out[map.size.height] = height;
+ const { width, height } = sizeValue(map.size, input.aspectRatio, input.resolution);
+ if (map.size.key) out[map.size.key] = { width, height };
+ if (map.size.width) out[map.size.width] = width;
+ if (map.size.height) out[map.size.height] = height;
}
// LoRAs (a look, a motion, a trained identity) in the API's shape; the provider calls the route's LoRA endpoint then.
if (map.loras && input.loras?.length) Object.assign(out, loraFields(map.loras, input.loras));
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index 528d6d05..0501309e 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -13,6 +13,7 @@ import type {
} from "./types";
import { chainGapProblem, chainTiming, FIRST_AT_ZERO, frameTimes, keyframeChain, MAX_KEYFRAMES, spread } from "./keyframes";
import { cloudPath, fitLoras, gated, localOnly, loraCapacity, needsToken, routeLoraField } from "./loras";
+import { soulKind, soulMegapixels, soulRecipe, soulSize, type SoulOverlay } from "./soul";
/** Infer the operation from what the user attached. */
export function inferOperation(model: ModelDef, req: Pick<GenerationRequest, "op" | "inputs" | "params">): Operation {
@@ -108,6 +109,14 @@ export interface Plan {
/** Number of separate provider jobs (models that can't batch need several). */
jobs: number;
perJobOutputs: number;
+ /** What the plan changed or left out, said before the run (a look's LoRAs that don't fit this base). */
+ notes?: string[];
+ /**
+ * A Fuobe Soul run (src/lib/catalog/soul.ts): the look applied, the user's words inside the prompt (the enhancer
+ * expands them, the look stays), the look's LoRA triggers at the front (in order), and what happens after
+ * generation (the grade, an overlay) that the result's meta carries.
+ */
+ soul?: { look?: string; words: string; triggers: string[]; grade?: string; overlay?: SoulOverlay };
}
/** Operations that work from their inputs alone. */
@@ -150,10 +159,12 @@ export function planGeneration(
getModel: (id: string) => ModelDef | undefined,
getPreset: (id: string) => Preset | undefined,
): Plan {
- const preset = req.presetId ? getPreset(req.presetId) : undefined;
- if (req.presetId && !preset) throw new Error(`Unknown preset ${req.presetId}`);
const model = getModel(req.modelId);
if (!model) throw new Error(`Unknown model ${req.modelId}`);
+ // Fuobe Soul takes a look (its presetId is a look id, not an app, motion or effect).
+ const soul = soulKind(model);
+ const preset = req.presetId && !soul ? getPreset(req.presetId) : undefined;
+ if (req.presetId && !soul && !preset) throw new Error(`Unknown preset ${req.presetId}`);
let prompt = req.prompt?.trim() ?? "";
let params: GenParams = { ...model.defaults, ...req.params };
@@ -199,7 +210,30 @@ export function planGeneration(
// The user's own LoRAs (an @character's trained identity) go first: on an API that takes so many, the first
// ones win, so a look's or motion's LoRAs give way to them (fitLoras).
- if (req.loras?.length) loras = [...req.loras, ...loras];
+ let soulPlan: Plan["soul"];
+ const notes: string[] = [];
+ if (soul) {
+ const extra = params.extra ?? {};
+ const charStrength = typeof extra.characterStrength === "number" ? extra.characterStrength : undefined;
+ const r = soulRecipe(soul, prompt, { look: req.presetId, strength: req.presetStrength, userLoras: req.loras, characterStrength: charStrength });
+ prompt = r.prompt;
+ loras = r.loras;
+ notes.push(...r.notes);
+ const own = new Set(req.loras ?? []);
+ soulPlan = {
+ ...(r.look && { look: r.look.id }),
+ words: r.words.trim().replace(/[.\s]+$/, ""),
+ triggers: [...new Set(r.loras.filter((l) => !own.has(l) && l.trigger?.trim()).map((l) => l.trigger!.trim()))],
+ ...(r.grade && { grade: r.grade }),
+ ...(r.overlay && { overlay: r.overlay }),
+ };
+ // characterStrength is Fuobe's setting, not the provider's.
+ if ("characterStrength" in extra) {
+ const rest = { ...extra };
+ delete rest.characterStrength;
+ params = { ...params, extra: Object.keys(rest).length ? rest : undefined };
+ }
+ } else if (req.loras?.length) loras = [...req.loras, ...loras];
// A LoRA at strength 0 changes nothing: leave it out, so preset strength 0 is the preset's prompt alone (and its file isn't needed).
const kept = loras.filter((l) => (l.strength ?? 1) !== 0);
// Its trigger word goes with it: an open motion's template starts with its LoRA's trigger ("e13c7r1c electricity
@@ -265,6 +299,8 @@ export function planGeneration(
// makes the one file the picker showed, not both.
const matteOutputs = model.options.matteOutputs;
if (op === "bg-remove-video" && !params.matteOutput && matteOutputs && matteOutputs.length > 1) params = { ...params, matteOutput: matteOutputs[0] };
+ // Soul's prompt always carries the look's words: it's the user's own words a new picture needs.
+ if (soulPlan && op === "t2i" && !soulPlan.words) throw new Error("Write a prompt first");
if (!prompt && !promptOptional(model, op) && !markedTarget(model, op, req, params)) {
throw new Error(op === "remove-object" ? "Say what to remove, e.g. “the coffee cup in her hand”" : "Write a prompt first");
}
@@ -274,11 +310,27 @@ export function planGeneration(
const presets = model.options.presets;
if (presets?.required && !params.extra?.[presets.param]) throw new Error(`Pick a ${presets.label.toLowerCase()} first`);
+ // Soul's exact sizes on the user's GPU (the cloud routes send them through FieldMap.size); an edit keeps the picture's shape.
+ if (soul && model.engine === "open" && op === "t2i") {
+ const { width, height } = soulSize(params.aspectRatio, params.resolution);
+ params = { ...params, extra: { ...params.extra, width, height } };
+ }
+
const requested = Math.max(1, Math.min(8, params.numOutputs ?? 1));
const maxPerJob = Math.max(1, model.options.maxOutputs ?? 1);
const perJobOutputs = Math.min(requested, maxPerJob);
const jobs = Math.ceil(requested / perJobOutputs);
- return { model, op, prompt, params: { ...params, numOutputs: perJobOutputs }, loras, jobs, perJobOutputs };
+ return {
+ model,
+ op,
+ prompt,
+ params: { ...params, numOutputs: perJobOutputs },
+ loras,
+ jobs,
+ perJobOutputs,
+ ...(notes.length && { notes }),
+ ...(soulPlan && { soul: soulPlan }),
+ };
}
/**
@@ -501,6 +553,11 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:
let per = usd;
const clip = op && CLIP_LENGTH_OPS.has(op) && params.sourceDuration && params.sourceDuration > 0 ? params.sourceDuration * (op === "interpolate" ? Math.max(1, params.slowdown ?? 1) : 1) : undefined;
if (p.unit === "image") per = usd * n;
+ // Per megapixel of every image made: Soul's sizes are known (about 1 or 2 MP); other models are taken as 1 MP.
+ if (p.unit === "megapixel") {
+ const mp = soulKind(model) ? soulMegapixels(params.aspectRatio ?? model.defaults?.aspectRatio, params.resolution ?? model.defaults?.resolution) : 1;
+ per = usd * (p.roundUp ? Math.ceil(mp - 1e-9) : mp) * n;
+ }
if (p.unit === "second") per = usd * (clip ?? params.duration ?? model.defaults?.duration ?? 5) * (p.inputSeconds ? 2 : 1);
if (p.unit === "minute") per = (usd * (params.duration ?? 60)) / 60;
// Settings that change the price (60 fps, a Pro tier, a cheaper model).
diff --git a/src/lib/catalog/soul.ts b/src/lib/catalog/soul.ts
index 76cb41b2..0746cdbc 100644
--- a/src/lib/catalog/soul.ts
+++ b/src/lib/catalog/soul.ts
@@ -261,12 +261,28 @@ export function soulRecipe(
/**
* The prompt after some LoRAs were left out (a cloud API's slots, a civitai file without a key): the left-out
- * LoRAs' triggers come off the front, since they mean nothing to the model without the LoRA.
+ * LoRAs' triggers come off the front, since they mean nothing to the model without the LoRA. `triggers` is the
+ * front as the recipe wrote it (Plan.soul.triggers), in order.
*/
-export function promptWithLoras(prompt: string, asked: Pick<LoraRef, "trigger">[], kept: Pick<LoraRef, "trigger">[]): string {
- const before = triggersOf(asked);
- const after = triggersOf(kept);
- if (!before || before === after || !prompt.startsWith(`${before}, `)) return prompt;
+export function promptWithLoras(prompt: string, triggers: string[], kept: Pick<LoraRef, "trigger">[]): string {
+ const before = triggers.join(", ");
+ if (!before || !prompt.startsWith(`${before}, `)) return prompt;
+ const keep = new Set(kept.map((l) => l.trigger?.trim()).filter(Boolean));
+ const after = triggers.filter((t) => keep.has(t)).join(", ");
+ if (after === before) return prompt;
const rest = prompt.slice(before.length + 2);
return after ? `${after}, ${rest}` : rest;
}
+
+/**
+ * What happens to a Soul result after generation, read from its request (the grade preset and the overlay the
+ * browser applies; meta.grade / meta.overlay tell API clients). Undefined for other models.
+ */
+export function soulPostSteps(modelId: string, presetId: string | null | undefined): { look?: string; grade?: string; overlay?: SoulOverlay } | undefined {
+ const kind = soulKind(modelId);
+ if (!kind) return undefined;
+ if (kind === "cinema") return { grade: SOUL_CINEMA.grades[0] };
+ const look = soulLook(presetId ?? DEFAULT_LOOK);
+ if (!look) return undefined;
+ return { look: look.id, ...(look.grade && { grade: look.grade }), ...(look.overlay && { overlay: look.overlay }) };
+}
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index de4e3b47..bf36fc0c 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -424,7 +424,17 @@ export interface FieldMap {
* Width and height fields (Replicate's Z-Image LoRA model): the aspect ratio's shape with the area of a
* `base`×`base` square (1024 when unset), in multiples of `multiple`, neither side above `max`.
*/
- size?: { width: string; height: string; multiple: number; max?: number; base?: number };
+ size?: {
+ width?: string;
+ height?: string;
+ /** One object field that takes {width, height} (fal's image_size) instead of two fields. */
+ key?: string;
+ multiple: number;
+ max?: number;
+ base?: number;
+ /** Exact sizes per resolution tier and aspect ratio (Fuobe Soul's table); the computed size where it has none. */
+ table?: Record<string, Record<string, [number, number]>>;
+ };
/**
* Limits the API checks on numeric fields Fuobe fills (round 4: target fps, slow motion, frame interval,
* overlay position and scale, Ken Burns length…): a value is rounded when the field takes whole numbers
@@ -491,6 +501,11 @@ export interface ModelOptions {
draft?: boolean;
/** A style/template list fetched from the provider (Soul styles, Genjutsu looks, Marketing Studio templates). */
presets?: { source: string; param: string; label: string; required?: boolean };
+ /**
+ * Takes a Fuobe Soul look (src/lib/catalog/soul.ts) as GenerationRequest.presetId, with presetStrength scaling
+ * its LoRAs; `label` names the picker.
+ */
+ looks?: { label: string };
/** Premade voices the model offers (shown in the voice picker). */
voices?: { id: string; name: string; hint?: string }[];
/** Takes a reference recording to clone a voice from. */
@@ -561,6 +576,8 @@ export interface Pricing {
factors?: { param: string; values: Record<string, number> }[];
/** The price per unit when the run carries LoRAs and goes to the route's LoRA endpoint (fal's /lora variants cost more). */
withLoras?: number;
+ /** Per-megapixel prices billed on whole megapixels (fal's Qwen-Image 2512). */
+ roundUp?: true;
}
export interface ModelDef {
@@ -578,6 +595,12 @@ export interface ModelDef {
pricing?: Pricing;
/** Trained identities this model accepts by id (Higgsfield Soul ID). */
identity?: { provider: "higgsfield"; version: "v1" | "v2" | "cinema" };
+ /**
+ * A Fuobe Original that runs on both engines: its routes cover ComfyUI and the hosted open weights on fal /
+ * Replicate. `engine` is the one it shows first; a request picks one with GenerationRequest.engine, and
+ * onEngine() (src/lib/catalog/engines.ts) gives the model as it runs there (that engine's routes only).
+ */
+ engines?: Engine[];
/** Hidden from pickers (used only internally by presets). */
hidden?: boolean;
/**
@@ -759,6 +782,11 @@ export interface GenerationRequest {
mix?: { presetId: string; strength: number };
/** LoRAs added by @element mentions (trained identities, server-side), or a recipe's LoRAs sent by the evaluation harness. */
loras?: LoraRef[];
+ /**
+ * The engine a model that runs on both (a Fuobe Original, ModelDef.engines) runs on: the composer's switch.
+ * Unset: the install's engine mode, else the first one connected (your GPU before the cloud).
+ */
+ engine?: Engine;
/** Chained jobs: where the previous job's image goes among `inputs.images` (one dependency). */
chainFrom?: "first" | "last";
/** Chained jobs with several dependencies: where each one's first output goes, in dependsOn order. */
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index 6f57ae0f..a01fd04e 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -3,6 +3,7 @@ import type Anthropic from "@anthropic-ai/sdk";
import { nanoid } from "nanoid";
import { z } from "zod";
import { getModel, modelsFor } from "@/lib/catalog";
+import { dualEngine, runsOn } from "@/lib/catalog/engines";
import { OPERATION_LABELS, type ChainSlot, type GenerationRequest, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";
import { type PlannedJob, totalCost } from "@/lib/assist";
import { STORYBOARD_MODELS } from "@/lib/catalog/storyboard";
@@ -39,10 +40,26 @@ function summarize(m: ModelDef) {
id: m.id,
name: m.name,
vendor: m.vendor,
- engine: m.engine === "open" ? (local ? "open source (Ollama, on this machine)" : "open source (ComfyUI)") : local ? "Claude (or Ollama when no key is set)" : "paid cloud API",
+ engine: dualEngine(m)
+ ? "Fuobe Original: open source on your GPU (ComfyUI) or hosted open weights in the cloud (pass engine to pick one)"
+ : m.engine === "open"
+ ? local
+ ? "open source (Ollama, on this machine)"
+ : "open source (ComfyUI)"
+ : local
+ ? "Claude (or Ollama when no key is set)"
+ : "paid cloud API",
about: m.tagline,
does: [...new Set(m.routes.map((r) => r.op))].map((op) => `${op} (${OPERATION_LABELS[op]})`),
- price: m.engine === "open" ? (local ? "free (your machine)" : "free (your GPU)") : m.pricing ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.note ? ` — ${m.pricing.note}` : ""}` : "unknown",
+ price: dualEngine(m)
+ ? `free on your GPU; in the cloud ${m.pricing ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.withLoras ? ` ($${m.pricing.withLoras} with LoRAs)` : ""}` : "priced per run"}`
+ : m.engine === "open"
+ ? local
+ ? "free (your machine)"
+ : "free (your GPU)"
+ : m.pricing
+ ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.note ? ` — ${m.pricing.note}` : ""}`
+ : "unknown",
connected: configured,
...(o.aspectRatios && { aspectRatios: o.aspectRatios }),
...(o.resolutions && { resolutions: o.resolutions }),
@@ -56,6 +73,7 @@ function summarize(m: ModelDef) {
...(o.voiceClone && { voiceClone: true }),
...(o.languages?.length && { languages: o.languages.length > 12 ? `${o.languages.slice(0, 12).join(", ")}…` : o.languages.join(", ") }),
...(o.presets && { needs: o.presets.required ? `a ${o.presets.label} (pick in the studio)` : undefined }),
+ ...(o.looks && { looks: "139 Soul looks: pass a look id as presetId (v1-general, v2-y2k-studio…), presetStrength 0–1 scales its LoRAs" }),
};
}
@@ -85,7 +103,7 @@ const searchModels = defineTool({
if (scored.some((x) => x.s)) list = scored.filter((x) => x.s).sort((a, b) => b.s - a.s).map((x) => x.m);
}
// The engine the user picked first, then the rest.
- list = [...list].sort((a, b) => Number(b.engine === ctx.engine) - Number(a.engine === ctx.engine));
+ list = [...list].sort((a, b) => Number(runsOn(b, ctx.engine)) - Number(runsOn(a, ctx.engine)));
const shown = list.slice(0, 20);
return {
content: JSON.stringify({ engineMode: mode, preferredEngine: ctx.engine, total: list.length, models: shown.map(summarize) }),
@@ -250,6 +268,8 @@ const Job = z.object({
"Index (0-based) of an earlier job in this same call whose result this job uses: it starts by itself when that job finishes. An image becomes the start frame or the image to edit, a video the input video, audio the soundtrack or the recording to re-voice (the voice to clone, for tts), text the prompt.",
),
negative_prompt: z.string().optional(),
+ look: z.string().optional().describe("Fuobe Soul / Soul HD: the look's id from search_models (v1-general, v1-y2k, v2-y2k-studio…). Leave it out for Soul's default look."),
+ engine: z.enum(["open", "cloud"]).optional().describe("Fuobe Originals run on both engines: open = the user's GPU (free), cloud = hosted open weights (paid). Leave it out to follow the user's engine."),
});
type JobInput = z.infer<typeof Job>;
@@ -282,6 +302,8 @@ function toRequest(j: JobInput): GenerationRequest {
return {
feature: "assist",
modelId: j.model_id,
+ ...(j.look && { presetId: j.look }),
+ ...(j.engine && { engine: j.engine }),
op: j.op as Operation | undefined,
prompt: j.prompt,
negativePrompt: j.negative_prompt,
diff --git a/src/server/enhance.ts b/src/server/enhance.ts
index 43d08d63..21614ecb 100644
--- a/src/server/enhance.ts
+++ b/src/server/enhance.ts
@@ -113,6 +113,23 @@ export function heuristicEnhance(prompt: string, kind: MediaKind, op: Operation)
return `${p}. Highly detailed, natural skin and material texture, cinematic lighting, thoughtful composition, shot on a full-frame camera with a 50mm lens, shallow depth of field.`;
}
+/** Fuobe Soul's enhancer (research §4.2): the user's words grown into one scene; the look adds the style itself. */
+const SOUL_SYSTEM =
+ "You expand a short image prompt into one vivid scene of 60 to 120 words for a photographic image model. Keep every word and idea the user wrote. " +
+ "Add only what a photographer would decide: subject, wardrobe, pose, place, light, lens and film stock. Don't name an art style, filter or colour grade, and don't add text, signs or watermarks. " +
+ "Answer with the prompt only: plain sentences, no quotes, no lists, no preamble.";
+
+/**
+ * Soul's words, expanded when an LLM is available (Claude or Ollama); otherwise the user's own words, since the
+ * look already says how the picture should look (the generic offline rewrite would fight it).
+ */
+export async function enhanceSoulWords(words: string): Promise<string> {
+ const w = words.trim();
+ if (!w || w.split(/\s+/).length >= 60) return words;
+ const out = (await llmText(SOUL_SYSTEM, w))?.trim().replace(/^["“]|["”]$/g, "").replace(/[.\s]+$/, "");
+ return out && out.length > w.length ? out : words;
+}
+
export async function enhancePrompt(prompt: string, kind: MediaKind, op: Operation): Promise<string> {
return (await llmText(SYSTEM, instruction(prompt, kind, op))) ?? heuristicEnhance(prompt, kind, op);
}
diff --git a/src/server/generations.ts b/src/server/generations.ts
index d5dce108..ad1180d5 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -13,6 +13,8 @@ import { chainedWaitMessage, keyframeChain } from "@/lib/catalog/keyframes";
import { estimateCost, inferOperation, planGeneration, routeLoras, routesFor } from "@/lib/catalog/plan";
import { framedLength, keepMatte } from "@/lib/catalog/payload";
import { fitLoras, lorasFit } from "@/lib/catalog/loras";
+import { dualEngine, onEngine, pickEngine } from "@/lib/catalog/engines";
+import { promptWithLoras, soulPostSteps } from "@/lib/catalog/soul";
import {
LAST_FRAME_CHAIN,
OPERATION_OUTPUT,
@@ -31,11 +33,11 @@ import { db } from "./db";
import { listElements } from "./elements";
import { pollTrainings } from "./training";
import { createExtendChain, createKeyframeFilm, createShotFilm } from "./chains";
-import { enhancePrompt } from "./enhance";
+import { enhancePrompt, enhanceSoulWords } from "./enhance";
import { setResolver, watchGenerations, type LiveEvent } from "./live";
import { provider } from "./providers";
import { comfyLoraFiles, probeComfy } from "./providers/comfyui";
-import { ensureLorasOnComfy, prepareCloudLoras } from "./loras";
+import { ensureLorasOnComfy, prepareCloudLoras, withoutUnreachableCivitai } from "./loras";
import { llmBackends, llmMissing, llmUsesClaude, probeOllama } from "./providers/llm";
import type { PollContext, PollResult, RemoteOutput } from "./providers/types";
import { mediaFacts } from "./media-facts";
@@ -424,10 +426,13 @@ function prepare(original: GenerationRequest) {
// @element mentions become reference images / LoRAs; the stored request keeps the mentions for "Reuse".
// A style signature's sentences (palette, look) join the prompt here; the stored request keeps the user's words.
const worded = withSignatureWords(original);
- const model = getModel(worded.modelId);
- const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, listElements()).request, model).request, model) : worded;
- let plan = planGeneration(req, getModel, getPreset);
const mode = engineMode();
+ const found = getModel(worded.modelId);
+ // A Fuobe Original runs on the engine asked for (the composer's switch), else the engine mode, else the first one connected.
+ const model = found && dualEngine(found) ? onEngine(found, pickEngine(found, worded.engine, mode, (e) => onEngine(found, e).routes.some(routeReady))) : found;
+ const lookup = (id: string) => (model && id === model.id ? model : getModel(id));
+ const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, listElements()).request, model).request, model) : worded;
+ let plan = planGeneration(req, lookup, getPreset);
if (mode !== "both" && plan.model.engine !== mode) {
throw new Error(
mode === "open"
@@ -442,11 +447,15 @@ function prepare(original: GenerationRequest) {
const seconds = MADE_LENGTH_OPS.has(plan.op) ? plan.params.duration : undefined;
const { route, demo } = chooseRoute(routesFor(plan.model, plan.op), req.inputs?.images?.length ?? 0, plan.loras, seconds);
// What the cloud run can carry: a LoRA whose licence doesn't allow hosting stays on the GPU, and an API
- // takes at most so many (the plan's notes say which were left out). Open runs carry them all.
+ // takes at most so many (the plan's notes say which were left out). Open runs carry them all. Without a
+ // civitai key a civitai LoRA the run can't get is left out (and said), rather than failing at the download.
const asked = plan.loras;
- const fitted = fitLoras(asked, route);
- plan = { ...plan, loras: fitted.loras };
- const notes = [...fitted.notes];
+ const reachable = demo ? { loras: asked, notes: [] } : withoutUnreachableCivitai(asked, route.provider === "comfyui" ? "comfyui" : route.provider === "replicate" ? "replicate" : "fal");
+ const fitted = fitLoras(reachable.loras, route);
+ // A Soul look's triggers lead the prompt: a LoRA left out takes its trigger with it.
+ const prompt = plan.soul ? promptWithLoras(plan.prompt, plan.soul.triggers, fitted.loras) : plan.prompt;
+ plan = { ...plan, prompt, loras: fitted.loras };
+ const notes = [...(plan.notes ?? []), ...reachable.notes, ...fitted.notes];
// A frame-count API that can't make the length asked (Replicate's Wan 2.2 fast: 81–121 frames) says what it makes.
const made = demo ? undefined : framedLength(route.map?.numFrames, seconds, plan.params.fps);
if (made !== undefined && route.map?.numFrames) {
@@ -464,7 +473,8 @@ function prepare(original: GenerationRequest) {
// A text step that runs on Ollama is free; only Claude costs money.
const free = demo || (route.provider === "llm" && !llmUsesClaude(route));
const withLoras = fitted.loras.length > 0 && !!route.loraEndpoint;
- return { req, plan, route, demo, providerId, notes, asked, cost: free ? 0 : estimateCost(plan.model, plan.params, 1, plan.op, withLoras) };
+ const unreachable = asked.filter((l) => !reachable.loras.includes(l));
+ return { req, plan, route, demo, providerId, notes, asked, unreachable, cost: free ? 0 : estimateCost(plan.model, plan.params, 1, plan.op, withLoras) };
}
/** Operations whose clip length is the duration picked (made, or added by extend), not an input video's. */
@@ -473,8 +483,9 @@ const MADE_LENGTH_OPS = new Set<Operation>(["t2v", "i2v", "flf2v", "ref2v", "ext
/** What a request would run as — model, operation, job count and cost — without starting it. */
export function previewGeneration(req: GenerationRequest) {
- const { plan, route, demo, providerId, cost, notes, asked } = prepare(req);
- const loras = routeLoras(route, asked);
+ const { plan, route, demo, providerId, cost, notes, asked, unreachable } = prepare(req);
+ const fitted = routeLoras(route, asked.filter((l) => !unreachable.includes(l)));
+ const loras = { ...fitted, dropped: [...unreachable.map((l) => ({ file: l.file, reason: "it downloads from civitai, which needs your civitai key (Settings → LoRAs)" })), ...fitted.dropped] };
return {
model: plan.model,
op: plan.op,
@@ -483,6 +494,8 @@ export function previewGeneration(req: GenerationRequest) {
demo,
providerId,
costUsd: cost === null ? null : cost * plan.jobs,
+ // The engine it runs on (a Fuobe Original picks one per request).
+ engine: plan.model.engine,
// What the route runs (the evaluation harness records it): the provider endpoint, the final prompt and the LoRAs it loads.
route: { provider: route.provider, endpoint: loras.applied.length && route.provider !== "comfyui" && route.loraEndpoint ? route.loraEndpoint : route.endpoint },
prompt: plan.prompt,
@@ -554,7 +567,8 @@ export function createGenerations(original: GenerationRequest, opts: CreateOptio
message: waits ? (original.frame ? "Waits for the previous frame" : "Waits for the earlier steps") : demo ? "Demo mode — no provider connected" : "Submitting",
// A step whose prompt comes from an earlier step shows its own words (not the placeholder) until then.
prompt: waits && req.chain?.some((s) => s.slot === "prompt") ? original.prompt?.replaceAll("{text}", "…").trim() || null : plan.prompt,
- request_json: JSON.stringify(original),
+ // An Original remembers the engine it ran on, so a retry or a chained step runs there too.
+ request_json: JSON.stringify(dualEngine(plan.model) ? { ...original, engine: plan.model.engine } : original),
provider_input_json: null,
external_id: null,
external_meta_json: null,
@@ -803,7 +817,13 @@ async function submit(
let prompt = plan.prompt;
if (req.params?.enhancePrompt && prompt) {
update(id, { message: "Enhancing prompt" });
- prompt = await enhancePrompt(prompt, plan.model.kind, plan.op).catch(() => prompt);
+ const words = plan.soul?.words;
+ const at = words ? prompt.indexOf(words) : -1;
+ if (words && at >= 0) {
+ // Soul: only the user's words are expanded (60–120 words of subject, wardrobe, place, light); the look stays as it is.
+ const longer = await enhanceSoulWords(words).catch(() => words);
+ prompt = prompt.slice(0, at) + longer + prompt.slice(at + words.length);
+ } else prompt = await enhancePrompt(prompt, plan.model.kind, plan.op).catch(() => prompt);
update(id, { prompt });
}
const input: GenInput = {
@@ -1067,6 +1087,9 @@ async function pollOne(r: Row): Promise<void> {
console.warn(`[fuobe] could not save output for ${r.id}: ${(e as Error).message}`);
}
}
+ // Fuobe Soul: what follows in the browser (the look's grade, an overlay), on each image; API clients read it as meta.
+ const post = soulPostSteps(r.model_id, r.preset_id);
+ if (post) for (const [i, o] of outputs.entries()) if (o.kind === "image") outputs[i] = { ...o, meta: { ...o.meta, ...post } };
update(r.id, {
status: "succeeded",
outputs_json: JSON.stringify(outputs),
diff --git a/src/server/loras.ts b/src/server/loras.ts
index 3f08d8bb..7d63c3d3 100644
--- a/src/server/loras.ts
+++ b/src/server/loras.ts
@@ -424,6 +424,29 @@ export function filesInLoraFolder(): { files: Set<string>; problem?: string } {
return { files };
}
+/**
+ * Before a run, without a civitai key: the civitai LoRAs it can't get, so the run goes ahead without them (the
+ * look's words still carry it) and says how to add them, instead of failing at the download. A LoRA is still
+ * reachable when ComfyUI's LoRA folder already has it (open engine) or a live mirror exists (cloud).
+ */
+export function withoutUnreachableCivitai(loras: LoraRef[], target: MirrorTarget): { loras: LoraRef[]; notes: string[] } {
+ const civitai = loras.filter((l) => !l.hostedUrl && needsToken(l.url) && !localOnly(l));
+ if (!civitai.length || civitaiKey()) return { loras, notes: [] };
+ const folder = target === "comfyui" && getSetting("comfyLorasDir") ? filesInLoraFolder().files : null;
+ const unreachable = civitai.filter((l) => {
+ if (target === "comfyui") return !!folder && !folder.has(l.file);
+ const cached = getCopy(l.file, target);
+ return !(cached?.hostedUrl && Date.now() - cached.createdAt < MIRROR_TTL_MS[target]);
+ });
+ if (!unreachable.length) return { loras, notes: [] };
+ const names = unreachable.map(loraName);
+ const list = names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
+ return {
+ loras: loras.filter((l) => !unreachable.includes(l)),
+ notes: [`${list} ${names.length > 1 ? "download" : "downloads"} from civitai, which needs your free API key (Settings → LoRAs), so this run leaves ${names.length > 1 ? "them" : "it"} out`],
+ };
+}
+
/** Test the civitai key (Settings → Save & test): civitai's /me answers 200 for a good key. */
export async function testCivitaiKey(): Promise<{ ok: boolean; detail: string }> {
const token = civitaiKey();
diff --git a/tests/catalog.test.ts b/tests/catalog.test.ts
index 0454b833..ce7c5ecf 100644
--- a/tests/catalog.test.ts
+++ b/tests/catalog.test.ts
@@ -3,6 +3,7 @@ import path from "node:path";
import { describe, expect, it } from "vitest";
import { PRESET_ICONS } from "@/components/preset-icons";
import { getModel, MODELS, PRESETS } from "@/lib/catalog";
+import { onEngine } from "@/lib/catalog/engines";
import type { Manifest } from "@/lib/comfy";
describe("catalog integrity", () => {
@@ -20,9 +21,15 @@ describe("catalog integrity", () => {
if (d.aspectRatio && m.options.aspectRatios) expect(m.options.aspectRatios, `${m.id} aspect`).toContain(d.aspectRatio);
if (d.resolution && m.options.resolutions) expect(m.options.resolutions, `${m.id} resolution`).toContain(d.resolution);
// ComfyUI, browser-only tools and Ollama-only text steps are the open engine; every API provider is cloud.
+ // A Fuobe Original runs on both: each engine it lists has routes, and every route is on one of them.
+ const engines = m.engines ?? [m.engine];
for (const r of m.routes) {
const open = r.provider === "comfyui" || r.provider === "local" || (r.provider === "llm" && r.endpoint === "ollama");
- expect(open ? "open" : "cloud", `${m.id} engine/provider`).toBe(m.engine);
+ expect(engines, `${m.id} engine/provider`).toContain(open ? "open" : "cloud");
+ }
+ if (m.engines) {
+ expect(m.engines, m.id).toContain(m.engine);
+ for (const e of m.engines) expect(onEngine(m, e).routes.length, `${m.id} on ${e}`).toBeGreaterThan(0);
}
}
});
diff --git a/tests/cloud-catalog.test.ts b/tests/cloud-catalog.test.ts
index 9944a6cb..4b99b8e8 100644
--- a/tests/cloud-catalog.test.ts
+++ b/tests/cloud-catalog.test.ts
@@ -27,7 +27,8 @@ function fieldsOf(map: FieldMap): string[] {
for (const [k, v] of Object.entries(map)) {
if (k === "fixed" || k === "defaults" || k === "seedRange" || k === "maskFormat" || k === "loras") continue;
if (k === "size") {
- out.push(map.size!.width, map.size!.height);
+ const z = map.size!;
+ out.push(...[z.key, z.width, z.height].filter((f): f is string => !!f));
continue;
}
if (typeof v === "string") out.push(v);
diff --git a/tests/soul-originals.test.ts b/tests/soul-originals.test.ts
index 1fce2908..ca405a02 100644
--- a/tests/soul-originals.test.ts
+++ b/tests/soul-originals.test.ts
@@ -11,6 +11,7 @@ import {
soulLook,
soulLookList,
soulMegapixels,
+ soulPostSteps,
soulRecipe,
soulSize,
SOUL_ASPECTS,
@@ -158,10 +159,22 @@ describe("Soul recipe (soul.ts)", () => {
it("takes a left-out LoRA's trigger off the front", () => {
const r = soulRecipe("soul", "x", { look: "v1-indie-sleaze" });
+ const triggers = ["hardflashy", "emoessence"];
const kept = r.loras.filter((l) => l.trigger !== "hardflashy");
- expect(promptWithLoras(r.prompt, r.loras, kept).startsWith("emoessence, x. ")).toBe(true);
- expect(promptWithLoras(r.prompt, r.loras, []).startsWith("x. ")).toBe(true);
- expect(promptWithLoras("plain", r.loras, [])).toBe("plain");
+ expect(promptWithLoras(r.prompt, triggers, kept).startsWith("emoessence, x. ")).toBe(true);
+ expect(promptWithLoras(r.prompt, triggers, []).startsWith("x. ")).toBe(true);
+ expect(promptWithLoras(r.prompt, triggers, r.loras)).toBe(r.prompt);
+ expect(promptWithLoras("plain", triggers, [])).toBe("plain");
+ // A trigger with commas of its own (Realistic Snapshot's) comes off whole.
+ const phone = soulRecipe("soul", "x", { look: "v1-iphone" });
+ expect(promptWithLoras(phone.prompt, ["amateur digital snapshot, candid, smartphone capture"], []).startsWith("x. ")).toBe(true);
+ });
+
+ it("says what happens after generation: the grade and the overlay", () => {
+ expect(soulPostSteps("fuobe-soul", "v1-digitalcam")).toEqual({ look: "v1-digitalcam", overlay: "date-stamp" });
+ expect(soulPostSteps("fuobe-soul", undefined)).toEqual({ look: "v1-general", grade: "natural" });
+ expect(soulPostSteps("fuobe-soul-cinema", null)).toEqual({ grade: "teal-orange" });
+ expect(soulPostSteps("nano-banana-pro", "v1-general")).toBeUndefined();
});
});
diff --git a/tests/soul-runs.test.ts b/tests/soul-runs.test.ts
new file mode 100644
index 00000000..d524b16e
--- /dev/null
+++ b/tests/soul-runs.test.ts
@@ -0,0 +1,159 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import type { ComfyWorkflow } from "@/lib/comfy";
+
+// Fuobe Soul as a run (build plan O2): one model on both engines, the look applied on the server, the cloud
+// payload from the research's FieldMaps, the ComfyUI graph with the look's LoRA chain, prices and post steps.
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-soul-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9"; // nothing listens here: open runs fall back to the demo
+
+const { setSetting } = await import("@/server/settings");
+const { createGenerations, previewGeneration } = await import("@/server/generations");
+const { prepareWorkflow } = await import("@/server/providers/comfyui");
+const { getModel, getPreset, modelsFor } = await import("@/lib/catalog");
+const { onEngine, pickEngine } = await import("@/lib/catalog/engines");
+const { estimateCost, planGeneration, routesFor } = await import("@/lib/catalog/plan");
+const { buildPayload } = await import("@/lib/catalog/payload");
+const { loraEntry } = await import("@/lib/catalog/loras");
+const { SOUL_TAILS } = await import("@/lib/catalog/soul-originals.generated");
+
+beforeAll(() => setSetting("demoMode", "auto"));
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+const soul = () => getModel("fuobe-soul")!;
+const plan = (engine: "open" | "cloud", req: Partial<Parameters<typeof planGeneration>[0]> = {}) => {
+ const m = onEngine(soul(), engine);
+ return planGeneration({ feature: "image", modelId: m.id, prompt: "a woman in a silver slip dress leaving a club at 2am", ...req }, (id) => (id === m.id ? m : getModel(id)), getPreset);
+};
+
+describe("Fuobe Soul on both engines", () => {
+ it("is one model with ComfyUI routes and hosted open-weight routes", () => {
+ const m = soul();
+ expect(m.engines).toEqual(["open", "cloud"]);
+ expect(onEngine(m, "open").routes.map((r) => r.provider)).toEqual(["comfyui"]);
+ expect(new Set(onEngine(m, "cloud").routes.map((r) => r.provider))).toEqual(new Set(["fal", "replicate"]));
+ expect(onEngine(m, "cloud")).toBe(onEngine(m, "cloud"));
+ // The pickers list it on both engines.
+ expect(modelsFor({ kind: "image", engine: "open" }).some((x) => x.id === "fuobe-soul")).toBe(true);
+ expect(modelsFor({ kind: "image", engine: "cloud" }).some((x) => x.id === "fuobe-soul")).toBe(true);
+ for (const id of ["fuobe-soul-hd", "fuobe-soul-cinema"]) expect(getModel(id)?.engines).toEqual(["open", "cloud"]);
+ });
+
+ it("picks the engine asked for, else the engine mode, else the first connected", () => {
+ const m = soul();
+ expect(pickEngine(m, "cloud", "both", () => false)).toBe("cloud");
+ expect(pickEngine(m, undefined, "cloud", () => false)).toBe("cloud");
+ expect(pickEngine(m, undefined, "both", (e) => e === "cloud")).toBe("cloud");
+ expect(pickEngine(m, undefined, "both", () => true)).toBe("open");
+ expect(() => pickEngine(m, "cloud", "open", () => true)).toThrow(/open source only/);
+ });
+
+ it("applies the look: triggers in front, the user's words, the look, the tail, its LoRAs", () => {
+ const p = plan("open", { presetId: "v1-indie-sleaze" });
+ expect(p.prompt.startsWith("hardflashy, emoessence, a woman in a silver slip dress leaving a club at 2am. ")).toBe(true);
+ expect(p.prompt.endsWith(SOUL_TAILS.flash)).toBe(true);
+ expect(p.loras.map((l) => l.file)).toEqual(["hardflash", "emo"].map((k) => loraEntry(k)!.file));
+ expect(p.soul).toMatchObject({ look: "v1-indie-sleaze", triggers: ["hardflashy", "emoessence"], words: "a woman in a silver slip dress leaving a club at 2am" });
+ // Soul's exact size on the user's GPU.
+ expect(p.params.extra).toMatchObject({ width: 896, height: 1152 });
+ expect(plan("open", { params: { aspectRatio: "16:9", resolution: "1080p" } }).params.extra).toMatchObject({ width: 1920, height: 1088 });
+ });
+
+ it("asks for words, and refuses a look id that doesn't exist", () => {
+ expect(() => plan("open", { prompt: "" })).toThrow(/Write a prompt/);
+ expect(() => plan("open", { presetId: "v9-nope" })).toThrow(/Unknown Soul look/);
+ });
+
+ it("builds fal's payload from the research: image_size from Soul's table, 8 steps, no prompt expansion, loras [{path, scale}]", () => {
+ const p = plan("cloud", { presetId: "v1-sunset-beach", params: { aspectRatio: "9:16", resolution: "720p", numOutputs: 4 } });
+ const route = routesFor(p.model, "t2i").find((r) => r.provider === "fal")!;
+ expect(route.loraEndpoint).toBe("fal-ai/z-image/turbo/lora");
+ const body = buildPayload(route.map!, { ...p.params, prompt: p.prompt, loras: p.loras.map((l) => ({ ...l, hostedUrl: l.hostedUrl ?? `https://fal.media/${l.file}` })) });
+ expect(body).toMatchObject({ image_size: { width: 768, height: 1344 }, num_inference_steps: 8, enable_prompt_expansion: false, output_format: "png", num_images: 4 });
+ expect(body.loras).toEqual(p.loras.map((l) => ({ path: l.hostedUrl ?? `https://fal.media/${l.file}`, scale: l.strength })));
+ expect(body).not.toHaveProperty("width");
+ expect(body).not.toHaveProperty("extra");
+ });
+
+ it("builds Replicate's payload: width / height within its 1440 limit, LoRAs as two arrays", () => {
+ const p = plan("cloud", { presetId: "v1-general", params: { aspectRatio: "16:9", resolution: "1080p" } });
+ const route = routesFor(p.model, "t2i").find((r) => r.provider === "replicate")!;
+ const body = buildPayload(route.map!, { ...p.params, prompt: p.prompt, loras: p.loras });
+ expect(body).toMatchObject({ width: 1440, height: 816, num_inference_steps: 8, output_format: "png" });
+ expect(body.lora_weights).toEqual(p.loras.map((l) => l.url));
+ expect(body.lora_scales).toEqual(p.loras.map((l) => l.strength));
+ });
+
+ it("chains the look's LoRAs after Z-Image Turbo's loader on ComfyUI, at Soul's size", async () => {
+ const p = plan("open", { presetId: "v1-y2k", params: { aspectRatio: "3:4", resolution: "720p" } });
+ const { workflow } = await prepareWorkflow(
+ "z-image-turbo-t2i",
+ { ...p.params, prompt: p.prompt, loras: p.loras, seed: 7 },
+ { generationId: "g", op: "t2i", upload: async (_d, _t, name) => `up_${name}`, media: () => undefined, serverRam: async () => undefined },
+ );
+ const wf = workflow as ComfyWorkflow;
+ const chain = Object.values(wf).filter((n) => n.class_type === "LoraLoaderModelOnly").map((n) => [n.inputs.lora_name, n.inputs.strength_model]);
+ expect(chain).toEqual(p.loras.map((l) => [l.file, l.strength]));
+ const latent = Object.values(wf).find((n) => n.class_type === "EmptySD3LatentImage")!;
+ expect([latent.inputs.width, latent.inputs.height]).toEqual([896, 1152]);
+ const sampler = Object.values(wf).find((n) => n.class_type === "KSampler")!;
+ expect(sampler.inputs).toMatchObject({ steps: 8, cfg: 1, sampler_name: "res_multistep", scheduler: "simple" });
+ });
+
+ it("prices per megapixel of every image: free on the GPU, the /lora price with LoRAs, whole megapixels on Soul HD", () => {
+ const cloud = onEngine(soul(), "cloud");
+ const p = plan("cloud", { params: { aspectRatio: "1:1", resolution: "720p", numOutputs: 4 } });
+ expect(estimateCost(cloud, p.params, p.jobs, p.op, true)).toBeCloseTo(0.0085 * 1.048576 * 4, 3);
+ expect(estimateCost(onEngine(soul(), "open"), p.params, p.jobs, p.op)).toBe(0);
+ const hd = onEngine(getModel("fuobe-soul-hd")!, "cloud");
+ expect(estimateCost(hd, { aspectRatio: "16:9", resolution: "1080p", numOutputs: 1 }, 1, "t2i")).toBeCloseTo(0.02 * 3, 3);
+ });
+
+ it("gives Soul Cinema its film look and Soul HD the look's words without Z-Image LoRAs", () => {
+ const c = planGeneration({ feature: "image", modelId: "fuobe-soul-cinema", prompt: "a detective in the rain" }, getModel, getPreset);
+ expect(c.loras.map((l) => l.file)).toEqual(["filmstill", "moviewide"].map((k) => loraEntry(k)!.file));
+ expect(c.soul?.grade).toBe("teal-orange");
+ const hd = planGeneration({ feature: "image", modelId: "fuobe-soul-hd", prompt: "a poster that says OPEN LATE", presetId: "v1-y2k-posters" }, getModel, getPreset);
+ expect(hd.loras).toEqual([]);
+ expect(hd.notes?.join(" ")).toMatch(/words only/);
+ });
+});
+
+describe("Fuobe Soul through the server", () => {
+ it("previews on the engine asked for, with its engine and route", () => {
+ const open = previewGeneration({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "open" });
+ expect(open).toMatchObject({ engine: "open", demo: true, costUsd: 0, route: { provider: "comfyui", endpoint: "z-image-turbo-t2i" } });
+ const cloud = previewGeneration({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "cloud" });
+ expect(cloud).toMatchObject({ engine: "cloud", demo: true });
+ expect(cloud.route.provider).toBe("fal");
+ });
+
+ it("leaves civitai LoRAs out without a civitai key (and says so) on the cloud, and keeps their triggers off", () => {
+ setSetting("falKey", "fal_test_key_123456");
+ const p = previewGeneration({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "cloud", presetId: "v1-indie-sleaze" });
+ // Hard Flash is on civitai, Rebel Essence Emo on Hugging Face.
+ expect(p.loras.applied.map((l) => l.file)).toEqual([loraEntry("emo")!.file]);
+ expect(p.loras.dropped).toEqual([{ file: loraEntry("hardflash")!.file, reason: expect.stringMatching(/civitai key/) }]);
+ expect(p.notes?.join(" ")).toMatch(/Hard Flash downloads from civitai, which needs your free API key/);
+ expect(p.prompt.startsWith("emoessence, a fox. ")).toBe(true);
+ // A Hugging Face LoRA needs no key.
+ const g = previewGeneration({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "cloud", presetId: "v1-general" });
+ expect(g.loras.applied.length).toBe(2);
+ expect(g.route.endpoint).toBe("fal-ai/z-image/turbo/lora");
+ setSetting("falKey", "");
+ });
+
+ it("remembers the engine on the row, and the engine mode still holds", () => {
+ const [g] = createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "cloud" });
+ expect(g.engine).toBe("cloud");
+ expect(g.request.engine).toBe("cloud");
+ setSetting("engineMode", "open");
+ expect(() => createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a fox", engine: "cloud" })).toThrow(/open source only/);
+ const [o] = createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a fox" });
+ expect(o.engine).toBe("open");
+ setSetting("engineMode", "both");
+ });
+});