MCPcopy Create free account
hub / github.com/LangGraph-GUI/LangGraph-GUI-backend / run_workflow_as_server

Function run_workflow_as_server

src/WorkFlow.py:264–299  ·  view source on GitHub ↗
(llm)

Source from the content-addressed store, hash-verified

262
263
264def run_workflow_as_server(llm):
265 # Load subgraph data
266 with open("workflow.json", 'r') as file:
267 graphs = json.load(file)
268
269 # Process each subgraph
270 for graph in graphs:
271 subgraph_name = graph.get("name")
272 node_map = parse_nodes_from_json(graph)
273
274 # Register the tool functions dynamically if has tool node, must before build graph
275 for tool_node in find_nodes_by_type(node_map, "TOOL"):
276 tool_code = f"{tool_node.description}"
277 exec(tool_code, globals())
278
279
280 subgraph = build_subgraph(node_map, llm)
281 subgraph_registry[subgraph_name] = subgraph
282
283
284 # Main Graph
285 main_graph = StateGraph(MainGraphState)
286 main_graph.add_node("subgraph", invoke_root)
287 main_graph.set_entry_point("subgraph")
288 main_graph = main_graph.compile()
289
290
291 # ==========================
292 # Run
293 # ==========================
294 for state in main_graph.stream(
295 {
296 "input": None,
297 }
298 ):
299 logger(state)

Callers 1

mainFunction · 0.90

Calls 4

loggerFunction · 0.90
parse_nodes_from_jsonFunction · 0.85
find_nodes_by_typeFunction · 0.85
build_subgraphFunction · 0.85

Tested by

no test coverage detected