0
0
LangChainframework~10 mins

Debugging failed chains 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 correct LangChain class for creating a chain.

LangChain
from langchain.chains import [1]

chain = [1]()
Drag options to blanks, or click blank then click option'
ALLMChain
BChainBase
CBaseChain
DChain
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent class like 'Chain' or 'ChainBase'.
Confusing base classes with usable chain classes.
2fill in blank
medium

Complete the code to initialize the OpenAI LLM with the correct parameter for temperature.

LangChain
from langchain.llms import OpenAI

llm = OpenAI(temperature=[1])
Drag options to blanks, or click blank then click option'
A'0.7'
B'high'
C0.7
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Passing temperature as a string instead of a float.
Using invalid values like 'high' or boolean True.
3fill in blank
hard

Fix the error in the chain call by completing the method name correctly.

LangChain
response = chain.[1](input_variables={'question': 'What is AI?'})
Drag options to blanks, or click blank then click option'
Astart
Bexecute
Ccall
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'execute' or 'start'.
Confusing the chain's method with other APIs.
4fill in blank
hard

Fill both blanks to create a prompt template and use it in the chain.

LangChain
from langchain.prompts import [1]

prompt = [2](template="Hello, {{name}}!")
chain = LLMChain(llm=llm, prompt=prompt)
Drag options to blanks, or click blank then click option'
APromptTemplate
BPrompt
CTemplatePrompt
DChainPrompt
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like 'Prompt' or 'TemplatePrompt'.
Forgetting to import the prompt template class.
5fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters and transforms chain outputs.

LangChain
filtered_outputs = {k:v for k, v in outputs.items() if v {BLANK_2}} 0 and k != {{BLANK_2}}
Drag options to blanks, or click blank then click option'
A:
B>
C'error'
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in dictionary comprehension.
Using wrong comparison operators or forgetting quotes around string keys.