Examples
const subgraph = new SubgraphBuilder('my_subgraph')
.addParameter({ name: 'user_input', type: 'string' })
.addNode(intentNode)
.addNode(llmNode)
.addEdge(intentNode, llmNode)
.setStartNode(intentNode)
.setEndNode(llmNode)
.build();
Constructors
Methods
Constructors
constructor
new SubgraphBuilder(id: string): SubgraphBuilder
Creates a new subgraph builder with the specified ID.
Parameters
Unique identifier for the subgraph
Returns
SubgraphBuilder
Methods
addParameter
addParameter(config: object): this
Adds a parameter to the subgraph that can be passed from the parent graph.
Parameters
Returns
this
addParameters
addParameters(parameters: object): this
Adds multiple parameters to the subgraph at once.
Parameters
Array of parameter configurations
Returns
this
addNode
addNode(node: Node | AbstractNode): this
Adds a node to the subgraph.
Parameters
node
Node | AbstractNode
required
Node to add to the subgraph
Returns
this
addEdge
addEdge(fromNode: string | Node | AbstractNode, toNode: string | Node | AbstractNode, options?: object): this
Adds an edge connecting two nodes in the subgraph.
Parameters
fromNode
string | Node | AbstractNode
required
Source node or node ID
toNode
string | Node | AbstractNode
required
Destination node or node ID
Optional edge configuration
Returns
this
setStartNode
setStartNode(node: string | Node | AbstractNode): this
Sets the start node of the subgraph (subgraphs can only have one start node).
Parameters
node
string | Node | AbstractNode
required
Start node or node ID
Returns
this
setEndNode
setEndNode(node: string | Node | AbstractNode): this
Sets the end node of the subgraph (subgraphs can only have one end node).
Parameters
node
string | Node | AbstractNode
required
End node or node ID
Returns
this
build
Builds and returns the final subgraph configuration.
Returns
Subgraph