alisamak commited on
Commit
8b7a5ff
·
verified ·
1 Parent(s): 1b356ff

Update LG_agent.py

Browse files
Files changed (1) hide show
  1. LG_agent.py +16 -17
LG_agent.py CHANGED
@@ -43,23 +43,22 @@ def build_graph(max_steps: int = 5):
43
 
44
  graph = builder.compile()
45
 
46
- def limited_invoke(input_state):
47
- steps = 0
48
- state = input_state
49
- while steps < max_steps:
50
- print(f"🔁 Step {steps + 1}")
51
- state = graph.invoke(state)
52
- latest_message = state["messages"][-1] if state["messages"] else None
53
-
54
- # Print tool usage if any
55
- for m in state["messages"]:
56
- if isinstance(m, ToolMessage):
57
- print(f"🔧 Tool Used: {m.tool_call_id} — {m.content}")
58
-
59
- if latest_message and isinstance(latest_message, AIMessage):
60
- break
61
- steps += 1
62
- return state
63
 
64
  return limited_invoke
65
 
 
43
 
44
  graph = builder.compile()
45
 
46
+ def limited_invoke(state):
47
+ steps = 0
48
+ while steps < max_steps:
49
+ print(f"🔁 Step {steps + 1}")
50
+ state = graph.invoke(state)
51
+ latest_message = state["messages"][-1] if state["messages"] else None
52
+
53
+ # Print tool usage if any
54
+ for m in state["messages"]:
55
+ if hasattr(m, "tool_call_id"):
56
+ print(f"🔧 Tool Used: {m.tool_call_id} — {m.content}")
57
+
58
+ if latest_message and isinstance(latest_message, AIMessage):
59
+ break
60
+ steps += 1
61
+ return state
 
62
 
63
  return limited_invoke
64