Process Orchestration

Process Orchestration

Process orchestration is a key feature in Peeps AI, enabling developers to design workflows that align with their project requirements. By offering Sequential, Hierarchical, and Custom Workflows, Peeps AI empowers users to manage task execution with precision and flexibility, ensuring that processes are efficient, scalable, and adaptable to complex scenarios.

This section provides an in-depth look at each workflow type, their use cases, and best practices for implementation.


Understanding Process Orchestration

Process orchestration in Peeps AI determines how tasks are executed, agents collaborate, and outputs are managed. It governs the flow of work across AI agents and ensures that workflows adapt dynamically to changes in inputs, conditions, and dependencies.

Key benefits of process orchestration include:

  • Flexibility: Choose or design workflows that fit your specific needs.

  • Scalability: Handle workflows of varying complexity, from simple task sequences to multi-agent hierarchies.

  • Control: Integrate autonomous decision-making with structured execution paths.


Workflow Types

1. Sequential Workflows

In a sequential workflow, tasks are executed one after the other in a predefined order. This straightforward approach is ideal for workflows where each task depends on the output of the previous one.

Use Cases:

  • Linear data processing pipelines (e.g., collect → clean → analyze → report).

  • Step-by-step workflows with no parallel dependencies.

Example:

from peepsai.flow.flow import Flow, start, listen

class SequentialWorkflow(Flow):
    @start()
    def step_one(self):
        return {"input_data": "Raw Data"}

    @listen(step_one)
    def step_two(self, inputs):
        return {"processed_data": f"Processed {inputs['input_data']}"}

    @listen(step_two)
    def step_three(self, inputs):
        print(f"Final Output: {inputs['processed_data']}")

Advantages:

  • Easy to design and debug.

  • Suitable for workflows with linear dependencies.

2. Hierarchical Workflows

Hierarchical workflows introduce a layer of coordination by assigning a "manager" agent to oversee task delegation and validation. This approach is ideal for complex processes requiring oversight or multi-level decision-making.

How It Works:

  • The manager agent evaluates the workflow requirements and delegates tasks to specialized agents.

  • Results are validated before progressing to the next stage.

Use Cases:

  • Research and development teams with task-specific agents.

  • Crisis response workflows with escalation protocols.

Example:

from peepsai.flow.flow import Flow, start, listen
from peepsai import Agent, Task, Peeps

class HierarchicalWorkflow(Flow):
    @start()
    def assign_manager(self):
        return Peeps(
            agents=[Agent(role="Manager", goal="Oversee workflow execution")],
            process=Process.hierarchical
        ).kickoff()

    @listen(assign_manager)
    def delegate_tasks(self, manager):
        # Manager delegates tasks to agents
        tasks = [
            Task(description="Research data", agent="Researcher"),
            Task(description="Validate findings", agent="Validator")
        ]
        return Peeps(agents=["Researcher", "Validator"], tasks=tasks).kickoff()

Advantages:

  • Allows for complex decision-making.

  • Ensures task quality through validation and coordination.

  • Suitable for workflows involving multiple levels of responsibility.

3. Custom Workflows

Custom workflows provide complete flexibility, enabling developers to design processes tailored to their unique requirements. These workflows can include branching logic, parallel execution, and dynamic adaptation based on real-time data.

How It Works:

  • Developers define custom conditions, branching rules, and execution paths.

  • Tasks and agents are dynamically assigned based on workflow needs.

Use Cases:

  • AI-driven decision systems with multiple contingencies.

  • Workflows requiring real-time adjustments to changing inputs.

Example:

from peepsai.flow.flow import Flow, start, listen, router

class CustomWorkflow(Flow):
    @start()
    def initialize(self):
        return {"input": "Data Set A"}

    @listen(initialize)
    def process_data(self, inputs):
        # Process data and evaluate results
        confidence = 0.75  # Example output
        return {"confidence": confidence}

    @router(process_data)
    def decide_next_step(self, outputs):
        if outputs["confidence"] > 0.8:
            return "high_confidence_path"
        else:
            return "low_confidence_path"

    @listen("high_confidence_path")
    def finalize_high(self, outputs):
        print("High confidence path taken.")

    @listen("low_confidence_path")
    def escalate(self, outputs):
        print("Escalating for further validation.")

Advantages:

  • Fully adaptable to specific requirements.

  • Supports advanced logic and real-time decision-making.

  • Handles parallel and conditional task execution with ease.


Choosing the Right Workflow


Combining Workflow Types

Peeps AI allows developers to combine workflow types for hybrid scenarios. For example:

  • Use a Sequential Workflow for early-stage data collection.

  • Transition to a Hierarchical Workflow for validation and oversight.

  • Incorporate a Custom Workflow for real-time adjustments based on intermediate results.

This modular approach ensures maximum flexibility while maintaining clarity and control.

Last updated