Spaces:
Sleeping
Sleeping
File size: 787 Bytes
9dfc370 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from langgraph.graph import StateGraph, END
from agents import hunter_agent, skeptic_agent, calibrator_agent
from state import TraderState
graph = StateGraph(TraderState)
graph.add_node("hunter", hunter_agent)
graph.add_node("skeptic", skeptic_agent)
graph.add_node("calibrator", calibrator_agent)
# hunter -> skeptic -> calibrator
graph.add_edge("hunter", "skeptic")
graph.add_edge("skeptic", "calibrator")
# Conditional edge from calibrator: If stop is True that means it end and go to END; else it will loop back to hunter
def should_continue(state: TraderState) -> str:
return END if state.get('stop', False) else "hunter"
graph.add_conditional_edges("calibrator", should_continue)
graph.set_entry_point("hunter")
compiled_graph = graph.compile() |