dina1 commited on
Commit
e933edd
·
verified ·
1 Parent(s): 8f5040e

Update agents/graph_builder_langgraph.py

Browse files
Files changed (1) hide show
  1. agents/graph_builder_langgraph.py +14 -3
agents/graph_builder_langgraph.py CHANGED
@@ -32,11 +32,22 @@ async def node_extract(state: State, config=None, runtime=None) -> State:
32
  return {"requirements": reqs}
33
 
34
  async def node_generate(state: State, config=None, runtime=None) -> State:
35
- # Safely read reference HTML from runtime or env
 
 
 
36
  reference_html = None
37
- if runtime and getattr(runtime.graph, "config", None):
38
- reference_html = runtime.graph.config.get("reference_html")
39
 
 
 
 
 
 
 
 
 
 
 
40
  if not reference_html and os.path.exists("templates/demo_qms_design.html"):
41
  with open("templates/demo_qms_design.html", "r", encoding="utf-8") as f:
42
  reference_html = f.read()
 
32
  return {"requirements": reqs}
33
 
34
  async def node_generate(state: State, config=None, runtime=None) -> State:
35
+ """
36
+ Generate recruitment-style UI HTML using requirements and reference template.
37
+ Works with both old and new LangGraph runtime objects.
38
+ """
39
  reference_html = None
 
 
40
 
41
+ # ✅ Handle all known runtime configurations
42
+ if runtime:
43
+ # Newer LangGraph (>=0.2)
44
+ if hasattr(runtime, "graph") and getattr(runtime.graph, "config", None):
45
+ reference_html = runtime.graph.config.get("reference_html")
46
+ # Older LangGraph (<0.2)
47
+ elif hasattr(runtime, "config"):
48
+ reference_html = runtime.config.get("reference_html")
49
+
50
+ # Fallback to local file if none supplied
51
  if not reference_html and os.path.exists("templates/demo_qms_design.html"):
52
  with open("templates/demo_qms_design.html", "r", encoding="utf-8") as f:
53
  reference_html = f.read()