Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to install LangChain using pip.
LangChain
pip install [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to install unrelated packages like numpy or flask.
Forgetting to use pip before the package name.
✗ Incorrect
To install LangChain, you use the command pip install langchain.
2fill in blank
mediumComplete the code to import the main LangChain class for chains.
LangChain
from langchain.chains import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Chain' which does not exist in this context.
Trying to import 'LangChain' which is not a class.
✗ Incorrect
The main class to create chains in LangChain is LLMChain.
3fill in blank
hardFix the error in the code to create a LangChain LLM instance.
LangChain
from langchain.llms import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect capitalization causes import errors.
Trying to import a non-existent class name.
✗ Incorrect
The correct class name is OpenAI with capital O and AI.
4fill in blank
hardFill both blanks to create an LLMChain with an OpenAI LLM and a prompt.
LangChain
llm = [1]() chain = LLMChain(llm=[2], prompt=prompt)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class name instead of the instance.
Using the prompt variable in place of the llm parameter.
✗ Incorrect
You create an OpenAI instance with OpenAI() and pass it as llm to the chain.
5fill in blank
hardFill all three blanks to run the chain and print the output.
LangChain
output = chain.[1]([2]) print(output[[3]])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute' instead of 'invoke' causes errors.
Passing a string instead of a dictionary as input.
Trying to print the whole output object instead of its text.
✗ Incorrect
You run the chain with invoke, passing a dictionary input, then print the text key of the output.