GenAI Launchpad

Examples

Decision

Route a support ticket to a team with DecisionNode and TypeSafe's Jev


This example routes a support ticket to the team that should handle it and saves Jev's confidence with the decision. It ships as DecisionWorkflow in app/launchpad/workflows/examples/decision/ and is registered as WorkflowRegistry.DECISION.

What it demonstrates

  • A DecisionNode that asks one typed question
  • Enum options described with UseEnumMemberDocstrings
  • Reading the per-field confidence from result.response.provider_details
  • A validated output (team plus confidence from 0 to 1) that downstream nodes and routers can use

Files

FilePurpose
app/launchpad/workflows/examples/decision/schema.pyTicketEvent with a single message: str.
app/launchpad/workflows/examples/decision/nodes/decide_team_node.pyDecideTeamNode, the Team enum, and the TeamQuestion model.
app/launchpad/workflows/examples/decision/workflow.pyDecisionWorkflow registered as WorkflowRegistry.DECISION.
app/launchpad/workflows/examples/decision/request_examples/ticket.jsonSample ticket about a duplicate charge.

Workflow

from launchpad.core.schema import NodeConfig, WorkflowSchema
from launchpad.core.workflow import Workflow
from launchpad.workflows.examples.decision.nodes.decide_team_node import (
    DecideTeamNode,
)
from launchpad.workflows.examples.decision.schema import TicketEvent


class DecisionWorkflow(Workflow):
    workflow_schema = WorkflowSchema(
        description="Choose a support team with Jev and validate the decision.",
        event_schema=TicketEvent,
        start=DecideTeamNode,
        nodes=[NodeConfig(node=DecideTeamNode)],
    )

See the Decision Node page for the full DecideTeamNode.

Run it

  1. Set the API key

    Add your TypeSafe key to the root .env:

    TYPESAFE_API_KEY=your-api-key
  2. Run the playground

    uv run playground/decision.py

    The script loads app/launchpad/workflows/examples/decision/request_examples/ticket.json, runs WorkflowRegistry.DECISION.value(), and prints the final TaskContext.

Output

{
  "event": {
    "message": "I was charged twice. Please refund the duplicate."
  },
  "nodes": {
    "DecideTeamNode": {
      "team": "billing",
      "confidence": 1.0
    }
  },
  "metadata": {},
  "should_stop": false,
  "trace_id": null
}

Downstream nodes read the result with self.get_output(DecideTeamNode). A router can branch on output.team, or send decisions below a confidence threshold to review.