Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the LangChain client needed for deployment.
LangChain
from langsmith import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Chain' instead of 'Client' will cause import errors.
✗ Incorrect
The Client class is used to interact with LangChain services during deployment.
2fill in blank
mediumComplete the code to initialize the LangChain client with an API key.
LangChain
client = Client(api_key=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes causes NameError.
✗ Incorrect
The API key must be a string, so it needs quotes around it.
3fill in blank
hardFix the error in the deployment function by completing the missing method call.
LangChain
def deploy_chain(chain): result = chain.[1]() return result
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute' or 'start' causes AttributeError.
✗ Incorrect
The run() method executes the chain and returns the output.
4fill in blank
hardFill both blanks to create a dictionary that maps chain names to their status.
LangChain
status_map = {chain.[1]: chain.[2] for chain in chains} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' or 'result' leads to incorrect mappings.
✗ Incorrect
The name attribute identifies the chain, and status shows its deployment state.
5fill in blank
hardFill all three blanks to filter chains that are ready and collect their names.
LangChain
ready_chains = [chain.[1] for chain in chains if chain.[2] == [3]]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'running' instead of 'ready' filters wrong chains.
✗ Incorrect
This list comprehension collects the name of chains whose status is 'ready'.