Skip to main content

馃憪 Build and execute the graph

Now that we have defined the nodes and edges of the graph, let's put the graph together and execute it to ensure that our agent is working as expected.

Fill in any <CODE_BLOCK_N> placeholders and run the cells under the Step 10: Build the graph and Step 11: Execute the graph sections in the notebook to build and execute the graph.

The answers for code blocks in this section are as follows:

CODE_BLOCK_17

Answer
graph.add_node("agent", agent)

CODE_BLOCK_18

Answer
graph.add_node("tools", tool_node)

CODE_BLOCK_19

Answer
graph.add_edge(START, "agent")

CODE_BLOCK_20

Answer
graph.add_edge("tools", "agent")

CODE_BLOCK_21

Answer
graph.add_conditional_edges(
"agent",
route_tools,
{"tools": "tools", END: END},
)