Node Basics
A node in GraphAI is created by decorating an async function with the@node
decorator:
- Accept at least an
input
dictionary - Return a dictionary containing the processed results
Creating Different Types of Nodes
GraphAI supports several types of nodes for different purposes:Standard Nodes
Standard nodes process data and pass it to the next node:Start Nodes
Start nodes mark the entry point to your graph:End Nodes
End nodes mark the exit points from your graph:Streaming Nodes
Nodes that need to stream data (like LLM outputs) can use thestream
parameter:
callback
parameter that can be used to stream data.
Node Return Values
Nodes must return a dictionary containing their output:Accessing State
Nodes can access the graph’s state by adding astate
parameter:
Router Nodes
Routers are special nodes that determine the next node to execute:"choice"
key containing the name of the next node to execute.