Node (base)
nae.node.Node ¶
Node(name: Optional[str] = None, llm: Optional[Any] = None, node_prompt: str = '', cache_ttl: Optional[int] = None, retry: bool = False)
Bases: ABC
Abstract base class for all nodes in the agent framework.
This class defines the basic interface that all node types must implement, providing core functionality for language model integration and prompt management.
Initialize a new Node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Unique identifier for the node. OPTIONAL — when omitted, the
node's name is inferred from the assignment target at the call
site ( |
None
|
llm
|
Optional[Any]
|
Language model instance to be used by this node |
None
|
node_prompt
|
str
|
System prompt/instructions for the language model |
''
|
cache_ttl
|
Optional[int]
|
Seconds to cache this node's result (LangGraph CachePolicy). |
None
|
retry
|
bool
|
When True, retry this node on exception (LangGraph RetryPolicy). |
False
|
__call__
abstractmethod
¶
Execute the node's primary function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments |
()
|
**kwargs
|
Any
|
Keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Node execution result |
Raises:
| Type | Description |
|---|---|
ValueError
|
If LLM is not set |
__gt__ ¶
Wire this node forward to one child, or fan out to several.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Node | list | Branch
|
A single node (sequential edge), a list of nodes, or a
|
required |
Returns:
| Type | Description |
|---|---|
Node | Branch
|
The single child (chain building), or the |
Node | Branch
|
|
__lt__ ¶
Fan-in join: wire a list of branch tails INTO this node.
This is the reflected half of [tails] > self. Python evaluates
x > [a, b] > self as a chained comparison (x > [a,b]) and ([a,b] > self);
the second term is list.__gt__(self), which returns NotImplemented,
so Python falls back to self.__lt__([a, b]) — landing here. It points
every tail's child at self and marks self a join, mirroring
Branch.__gt__. Only [..] > node is supported (not [..] > [..]).
map ¶
Run this node once per item of state[field] in parallel (map-reduce).
Use as a > worker.map("items") > collector: the worker fans out via
LangGraph Send over the items, then all replies join into the
collector (which runs once, after).
A mapped worker's scalar write key becomes a LIST channel — one entry per
item (a 1-element list for a single item; arrival order, not input order)
— and state= is not required: the channel and its accumulate reducer
are inferred at build time.
v1 limitation: workers return their REPLY only, not the source item (the
Send payload is the worker's input, never a state update).