Skip to main content

FlowDisplay Module

The FlowDisplay class provides visual display of agent workflows, showing agents in the center with their tools on the sides.

Import

from praisonaiagents import FlowDisplay

Quick Example

from praisonaiagents import Agent, FlowDisplay

# Create flow display
flow = FlowDisplay()

# Start tracking
flow.start()

# Run your agents
agent = Agent(name="Researcher", tools=[web_search])
agent.start("Research AI trends")

# Stop and display the flow
flow.stop()

Constructor

FlowDisplay()

Creates a new FlowDisplay instance. No parameters required.

Methods

start()

Start tracking the workflow. Registers callbacks to capture agent interactions and tool calls.
flow = FlowDisplay()
flow.start()

stop()

Stop tracking and display the flow chart.
flow.stop()

display()

Manually display the current flow chart without stopping tracking.
flow.display()

Attributes

AttributeTypeDescription
agentslistList of agents in execution order
agent_toolsdictMapping of agent names to their tools
trackingboolWhether tracking is active

Visual Output

The flow display shows:
┌─────────────────────────────────────────────────────────┐
│                    Agent Workflow                        │
├─────────────────────────────────────────────────────────┤
│                                                          │
│  [web_search]  ──►  Researcher  ──►  [file_write]       │
│                          │                               │
│                          ▼                               │
│  [calculator]  ──►    Analyst    ──►  [chart_gen]       │
│                          │                               │
│                          ▼                               │
│                       Writer                             │
│                                                          │
└─────────────────────────────────────────────────────────┘

Example with Multiple Agents

from praisonaiagents import Agent, PraisonAIAgents, FlowDisplay

# Create agents
researcher = Agent(
    name="Researcher",
    tools=[web_search, wikipedia]
)
analyst = Agent(
    name="Analyst",
    tools=[calculator, data_analysis]
)
writer = Agent(
    name="Writer",
    tools=[file_write]
)

# Create flow display
flow = FlowDisplay()
flow.start()

# Run workflow
agents = PraisonAIAgents(
    agents=[researcher, analyst, writer],
    tasks=[research_task, analysis_task, writing_task]
)
agents.start()

# Display the flow
flow.stop()

Thread Safety

The FlowDisplay class is thread-safe and uses locks to protect shared state when multiple agents run concurrently.