-
Notifications
You must be signed in to change notification settings - Fork 1
Graph Lifecycle
Zane Helton edited this page Feb 22, 2024
·
13 revisions
- 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"]
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.
-
Initialization:
- The journey of each request begins with the construction of a workflow graph by the
GraphBuilder.
- The journey of each request begins with the construction of a workflow graph by the
-
Validation:
- Before execution, the
GraphProcessorvalidates the graph with the help ofGraphValidator. If validation fails, the graph is reconstructed.
- Before execution, the
-
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.
- The validated graph enters the execution phase, starting with the root node and proceeding through output nodes (
-
Dynamic Update:
- During execution, the system checks for any need to enhance the graph based on AI-generated insights (
graph_processor.add_personality()). Ifhas_stale_textis true, the graph is updated in an attempt to add personality and connect data from separate nodes. -
node_uuidis set on nodes that wish to be re-synthesized. Conventionally, it will rephrase whatever is innode.data['text'].
- During execution, the system checks for any need to enhance the graph based on AI-generated insights (
-
Completion:
- The workflow continues processing nodes until there are no more output nodes, at which point the process gracefully concludes.
- When
GraphProcessor.active_branchesreaches 0, the workflow is officially completed.