For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
BlogLog InRequest Demo
HomeProductDevelopersSelf-HostingChangelog
HomeProductDevelopersSelf-HostingChangelog
  • Getting Started
    • Overview
  • Workflows SDK
    • Introduction
    • Installation
    • Core Concepts
    • Defining Control Flow
    • Configuration
    • Custom Docker Images
      • Displayable Nodes
        • Agent Node
        • Inline Prompt Node
        • Inline Subworkflow Node
        • Prompt Deployment Node
        • Search Node
        • Subworkflow Deployment Node
        • API Node
        • Code Execution Node
        • Templating Node
        • Guardrail Node
        • Map Node
        • Conditional Node
        • Merge Node
        • Error Node
        • Final Output Node
      • Datasets
      • CLI
  • Client SDK
    • Introduction
    • Authentication
    • API Versioning
LogoLogo
BlogLog InRequest Demo
Workflows SDKAPI ReferenceDisplayable Nodes

Conditional Node

Basic Example
1from vellum.workflows import BaseWorkflow
2from vellum.workflows.nodes import BaseNode
3from vellum.workflows.state import BaseState
4
5
6class SourceNode(BaseNode):
7 pass
8
9class MiddleNode(BaseNode):
10 class Ports(BaseNode.Ports):
11 top = Port.on_if(SourceNode.Execution.count.less_than(1))
12 bottom = Port.on_else()
13
14class TargetNode(BaseNode):
15 pass
16
17class MyWorkflow(BaseWorkflow):
18 graph = SourceNode >> {
19 # here we use Ports to execute the SourceNode one more time
20 # before proceeding to the TargetNode
21 MiddleNode.Ports.top >> SourceNode,
22 MiddleNode.Ports.bottom >> TargetNode,
23 }
24
25 class Outputs(BaseWorkflow.Outputs):
26 result = TargetNode.Outputs
Was this page helpful?
Previous

Merge Node

Next
Built with

vellum.workflows.nodes.ConditionalNode

Used to conditionally determine which port to invoke next. This node exists to be backwards compatible with Vellum’s Conditional Node, and for most cases, you should extend BaseNode.Ports directly.

Read more on ports here.