Spaces:
Paused

JatinAutonomousLabs commited on
Commit
5bc6924
·
verified ·
1 Parent(s): 2ed172a

Update graph.py

Browse files
Files changed (1) hide show
  1. graph.py +14 -1
graph.py CHANGED
@@ -10,6 +10,19 @@ from memory_manager import memory_manager
10
  from code_executor import execute_python_code
11
  from logging_config import setup_logging, get_logger
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # --- Setup Logging & Constants ---
14
  setup_logging()
15
  log = get_logger(__name__)
@@ -74,7 +87,7 @@ def run_triage_agent(state: AgentState):
74
 
75
  def run_planner_agent(state: AgentState):
76
  log.info("--- ✈️ Running Planner Agent ---")
77
- path = state.get('execution_path', []) + ["Planner Agent"]
78
  prompt = f"Analyze the user's request. Provide a high-level plan and estimate the number of LLM calls for one loop. User Request: \"{state['userInput']}\". Respond in JSON with keys: 'plan' (list of strings), 'estimated_llm_calls_per_loop' (integer)."
79
 
80
  response = llm.invoke(prompt)
 
10
  from code_executor import execute_python_code
11
  from logging_config import setup_logging, get_logger
12
 
13
+ def ensure_list(state, key):
14
+ """Return a list from state[key], default [] if missing/None/not-list."""
15
+ v = state.get(key) if state else None
16
+ if v is None:
17
+ return []
18
+ if isinstance(v, list):
19
+ return v
20
+ # if it's a tuple, convert to list
21
+ if isinstance(v, tuple):
22
+ return list(v)
23
+ # fallback: wrap single scalar value
24
+ return [v]
25
+
26
  # --- Setup Logging & Constants ---
27
  setup_logging()
28
  log = get_logger(__name__)
 
87
 
88
  def run_planner_agent(state: AgentState):
89
  log.info("--- ✈️ Running Planner Agent ---")
90
+ path = ensure_list(state, 'execution_path') + ["Planner Agent"]
91
  prompt = f"Analyze the user's request. Provide a high-level plan and estimate the number of LLM calls for one loop. User Request: \"{state['userInput']}\". Respond in JSON with keys: 'plan' (list of strings), 'estimated_llm_calls_per_loop' (integer)."
92
 
93
  response = llm.invoke(prompt)