Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Last active February 10, 2026 23:53
Show Gist options
  • Select an option

  • Save quantra-go-algo/8e4230f4625e400b93e9a22efb5b138f to your computer and use it in GitHub Desktop.

Select an option

Save quantra-go-algo/8e4230f4625e400b93e9a22efb5b138f to your computer and use it in GitHub Desktop.
# Initialize a new StateGraph with our AgentState structure.
workflow = StateGraph(AgentState)
# Add the functions as nodes in the graph.
workflow.add_node("analysis", analysis_node)
workflow.add_node("portfolio_allocator", portfolio_agent_node)
workflow.add_node("executor", execution_node)
workflow.add_node("email_notifier", email_notification_node)
# Set the entry point of the graph, which is the first node to be called.
workflow.set_entry_point("analysis")
# Define the sequence of operations by connecting the nodes with edges.
workflow.add_edge("analysis", "portfolio_allocator")
workflow.add_edge("portfolio_allocator", "executor")
workflow.add_edge("executor", "email_notifier")
# The final node connects to END, which signifies the end of the graph's execution.
workflow.add_edge("email_notifier", END)
# Compile the graph into a runnable application.
app = workflow.compile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment