Introducing Daggr: Chain AI Apps Programmatically with Visual Inspection

Hugging Face has introduced Daggr, an open-source Python library designed to simplify the creation of AI workflows by connecting Gradio apps, machine learning models, and custom Python functions. Daggr allows developers to define complex pipelines in code while automatically generating a visual canvas for inspecting intermediate outputs and rerunning specific steps.

Code-First Workflow Orchestration

Daggr adopts a code-first approach to workflow design, contrasting with traditional node-based GUI editors. Developers define their pipelines in Python, and Daggr automatically generates a visual interface. This architecture ensures that workflows remain version-controllable via code while providing the benefits of visual inspection.

Key capabilities include:

  • Granular Inspection and Rerunning: Users can inspect the output of any single node, modify its inputs, and rerun that specific step without executing the entire pipeline.
  • Resilient Workflows: The library supports "backup nodes," allowing developers to replace one model or Space with another to ensure pipeline stability.
  • State Persistence: Daggr automatically saves workflow state, including input values, cached results, and canvas positions. It also supports "sheets" to manage multiple workspaces within a single application.
  • Gradio Integration: Built by the Gradio team, Daggr integrates natively with Gradio Spaces. Developers can reference any public or private Space by its name and API endpoint without needing custom adapters.

Supported Node Types

Daggr utilizes three primary node types to build pipelines:

GradioNode

GradioNode connects to a Gradio Space API endpoint or a locally served Gradio app. By setting run_locally=True, Daggr clones the Space, creates an isolated virtual environment, and launches the app locally. If local execution fails, the system automatically falls back to the remote API.

FnNode

FnNode allows the integration of custom Python functions into the workflow. This is used for data processing steps, such as image downscaling or text manipulation, that do not require a full ML model.

InferenceNode

InferenceNode enables direct calls to models hosted via Hugging Face Inference Providers.

Implementation Example: Image to 3D Asset Pipeline

To demonstrate the versatility of the different node types, Daggr can be used to build a multi-stage pipeline that converts a 2D image into a 3D asset. A typical implementation involves the following chain:

  1. Background Removal: A GradioNode (e.g., using the BiRefNet Space) removes the background from the input image.
  2. Image Downscaling: An FnNode runs a custom Python function to resize the image for efficiency.
  3. Style Enhancement: An InferenceNode (using a model like FLUX.2-klein-4B) transforms the image into a clean 3D asset render style.
  4. 3D Generation: A final GradioNode (using the TRELLIS.2 Space) generates the 3D GLB asset from the enhanced image.

Deployment and Requirements

Daggr requires Python 3.10 or higher and can be installed via pip or uv. Workflows can be shared using Gradio's tunneling for public URLs or hosted permanently on Hugging Face Spaces by adding daggr to the requirements.txt file. When using InferenceNode on Hugging Face Spaces, a fine-grained access token with the "Make calls to Inference Providers" permission is required.

Sources