Skip to content

Graph Lifecycle

Zane Helton edited this page Feb 22, 2024 · 13 revisions

Execution Diagram

  • Green: Represents an OpenAI API call.
%%{
  init: {
    'theme': 'base',
    'themeVariables': {
      'primaryColor': '#4F5D75', // Dark Slate Gray
      'primaryTextColor': '#F0F0F0', // Off White
      'primaryBorderColor': '#333C57', // Darker Slate Gray
      'lineColor': '#1F2833', // Dark Blue Gray
      'secondaryColor': '#EDF5E1', // Light Greenish
      'tertiaryColor': '#45A29E', // Soft Teal
      'fontSize': '16px',
      'textColor': '#333333', // Dark Text
      'edgeLabelBackground':'#F0F0F0', // Off White
      'tertiaryTextColor': '#F0F0F0' // Off White
    }
  }
}%%

graph TD
    style A fill:#2c4c3b,stroke:#333,stroke-width:2px
    A["Create workflow graph with GraphBuilder"] -->|Pass workflow| B("GraphProcessor")
    B -- Run --> C{"GraphValidator"}
    C -->|Retry up to 2 times| A
    C -->|Validation Passes| D["root_node.process()"]
    D --> E["output_nodes.execute()"]
    E --> J["Execute node"]
    J -->|Node Execution Fails| K["Retry up to 3 times"]
    K -->|Retries Exhausted| G["graph_processor.add_personality()"]
    J -->|Node Execution Succeeds| G["graph_processor.add_personality()"]
    G --> F{has_stale_text?}
    style L fill:#2c4c3b,stroke:#333,stroke-width:2px
    F -->|Yes| L["Update graph and continue execution"]
    L --> H
    F -->|No| H{More Output Nodes?}
    H -->|Yes| E
    H -->|No| I["Workflow is finished"]
Loading

Execution Overview

This flow ensures a dynamic, robust, and intelligent handling of requests, with the flexibility to adapt and respond effectively in real-time with minimal LLM requests.

  1. Initialization:

    • The journey of each request begins with the construction of a workflow graph by the GraphBuilder.
  2. Validation:

    • Before execution, the GraphProcessor validates the graph with the help of GraphValidator. If validation fails, the graph is reconstructed.
  3. Execution:

    • The validated graph enters the execution phase, starting with the root node and proceeding through output nodes (output_nodes.execute()). Nodes are retried up to three times upon failure.
  4. Dynamic Update:

    • During execution, the system checks for any need to enhance the graph based on AI-generated insights (graph_processor.add_personality()). If has_stale_text is true, the graph is updated in an attempt to add personality and connect data from separate nodes.
    • node_uuid is set on nodes that wish to be re-synthesized. Conventionally, it will rephrase whatever is in node.data['text'].
  5. Completion:

    • The workflow continues processing nodes until there are no more output nodes, at which point the process gracefully concludes.
    • When GraphProcessor.active_branches reaches 0, the workflow is officially completed.

Clone this wiki locally