-
is possible add node or edge dynamic without restart app |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @weiminw, long time no see! Hope you're coding up a storm 🌪️ Yes, it is indeed possible to add a node or edge dynamically without restarting the app in LangChain. The Here's how you can add a node: # Assuming `graph` is an instance of the Graph class
new_node_data = ... # This should be an instance of BaseModel or RunnableType
new_node = graph.add_node(data=new_node_data) And here's how you can add an edge between two nodes: # Assuming `source_node` and `target_node` are Node instances within `graph`
new_edge = graph.add_edge(source=source_node, target=target_node) These operations are performed at runtime, and their effects are reflected immediately in the Sources
|
Beta Was this translation helpful? Give feedback.
Hey @weiminw, long time no see! Hope you're coding up a storm 🌪️
Yes, it is indeed possible to add a node or edge dynamically without restarting the app in LangChain. The
Graph
class in thegraph.py
file provides methodsadd_node
andadd_edge
that allow for the dynamic addition of nodes and edges to the graph instance. These methods modify the graph's state in memory, so any changes (like adding nodes or edges) take effect immediately without the need to restart the application.Here's how you can add a node:
And …