0
0
LangChainframework~10 mins

Multi-agent graphs in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Graph class from LangChain.

LangChain
from langchain.graphs import [1]
Drag options to blanks, or click blank then click option'
AAgent
BChain
CNode
DGraph
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Agent instead of Graph
Using Chain which is unrelated here
Confusing Node with Graph
2fill in blank
medium

Complete the code to create a new Graph instance named 'my_graph'.

LangChain
my_graph = [1]()
Drag options to blanks, or click blank then click option'
ANode
BGraph
CChain
DAgent
Attempts:
3 left
💡 Hint
Common Mistakes
Creating an Agent instead of a Graph
Using Chain or Node which are not graph containers
3fill in blank
hard

Fix the error in adding an agent to the graph by completing the method call.

LangChain
my_graph.[1](agent)
Drag options to blanks, or click blank then click option'
Aadd_agent
Bappend
Cinsert
Dadd_node
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic list methods like append or insert
Using add_node which is not specific for agents
4fill in blank
hard

Fill both blanks to create an edge between two agents named 'agent1' and 'agent2'.

LangChain
my_graph.[1](agent1, agent2)
my_graph.[2](agent2, agent1)
Drag options to blanks, or click blank then click option'
Aadd_edge
Bconnect
Clink
Djoin
Attempts:
3 left
💡 Hint
Common Mistakes
Using connect or link which may not be valid methods
Using join which is unrelated
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps agent names to their status if active.

LangChain
status_map = {agent.[1]: agent.[2] for agent in my_graph.agents if agent.[3]
Drag options to blanks, or click blank then click option'
Aname
Bstatus
Cis_active
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using id instead of name for keys
Checking status instead of is_active for filtering
Mixing up keys and values