Spaces:
Sleeping
Sleeping
| 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() |