0
0
LangChainframework~10 mins

Installing and setting up LangChain - Interactive Practice

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

Complete the code to install LangChain using pip.

LangChain
pip install [1]
Drag options to blanks, or click blank then click option'
Alangchain
Bnumpy
Crequests
Dflask
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to install unrelated packages like numpy or flask.
Forgetting to use pip before the package name.
2fill in blank
medium

Complete 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'
AChain
BChains
CLangChain
DLLMChain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Chain' which does not exist in this context.
Trying to import 'LangChain' which is not a class.
3fill in blank
hard

Fix 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'
AOpenAi
BOpenAI
CopenAI
Dopenai
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect capitalization causes import errors.
Trying to import a non-existent class name.
4fill in blank
hard

Fill 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'
AOpenAI
Bllm
COpenAI()
Dprompt
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class name instead of the instance.
Using the prompt variable in place of the llm parameter.
5fill in blank
hard

Fill 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'
Ainvoke
B{"input": "Hello"}
C"text"
Dexecute
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.