Get startedGet started for free

Generate a graph diagram

Now that you've demonstrated that the chatbot works to the school administration, you suggest generating a diagram explaining how the chatbot answers questions. You agree to create a LangGraph diagram that shows how the chatbot has been set up.

Image and display from IPython.display have been loaded for you.

This exercise is part of the course

Designing Agentic Systems with LangChain

View Course

Exercise instructions

  • Within a try block, call the .get_graph() method on graph, followed by .draw_mermaid_png() to display the diagram.
  • Create an except block called Exception and print the given string if an exception occurs.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Try generating and displaying the diagram of the graph
try:
    display(Image(graph.____().____()))

# Return an exception if the generation fails
____ Exception:
    ____("Diagram generation requires additional dependencies.")
Edit and Run Code