Advanced Workflows
The workflows app elevates the Root System beyond simple single-step prompt-to-image mechanics. It provides a robust Directed Acyclic Graph (DAG) orchestration engine capable of chaining disparate AI modules into complex, multi-step pipelines.
The Workflow Engine
A "Workflow" is a structured series of Tasks (Nodes) connected by logic (Edges).
For example, a high-end "AI Fashion Photoshoot" workflow might look like this:
- Node A (Text2Image): Generate a background scene based on a text prompt.
- Node B (Image2Image - Segmentation): Extract the user's clothing from their uploaded photo.
- Node C (Image2Image - Inpainting): composite the extracted clothing onto a mannequin placed in the generated background.
Dynamic DAG Orchestration
The engine processes these nodes recursively. It waits for Node A to complete, extracts the output (the MinIO URL), feeds it as an input payload to Node C, and fires the next Celery worker.
Cost Management in Workflows
Pipelines are inherently expensive and risky.
Upfront Cost Deduction
The workflow engine calculates the sum total of all distinct node costs before execution. It deducts the credits upfront to guarantee the user can afford the entire pipeline.
Partial Refunds
If any node in the chain fails (e.g., Node B triggers a NSFW filter), the system halts the DAG and intelligently calculates a partial refund, ensuring the user only pays for the successful intermediate steps.
Seeding Standard Workflows
Defining complex DAGs manually in the admin panel is tedious.
The management command python manage.py seed_workflows uses predefined Python dictionaries within the management command itself to automatically construct these complex graphs in the database.
Code-as-Configuration
This allows developers to define new pipelines purely via Python dictionaries without writing complex state-machine logic.