0
0
Prompt Engineering / GenAIml~10 mins

LangChain installation and setup in Prompt Engineering / GenAI - Interactive Code 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.

Prompt Engineering / GenAI
pip install [1]
Drag options to blanks, or click blank then click option'
Ascikit-learn
Bnumpy
Ctensorflow
Dlangchain
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to install unrelated packages like numpy or tensorflow.
Misspelling the package name.
2fill in blank
medium

Complete the code to import the main LangChain class for building chains.

Prompt Engineering / GenAI
from langchain.chains import [1]
Drag options to blanks, or click blank then click option'
ALLMChain
BChain
CTextChain
DModelChain
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class name that does not exist like Chain or TextChain.
Confusing the class name with other LangChain components.
3fill in blank
hard

Fix the error in the code to create a LangChain LLMChain with an OpenAI model.

Prompt Engineering / GenAI
from langchain.llms import OpenAI
llm = OpenAI(model_name=[1])
chain = LLMChain(llm=llm, prompt=prompt)
Drag options to blanks, or click blank then click option'
A'text-davinci-003'
B'gpt-3.5-turbo'
C'openai-gpt'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the model name string.
Using an invalid or unsupported model name.
4fill in blank
hard

Fill both blanks to create a prompt template and initialize an LLMChain with it.

Prompt Engineering / GenAI
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 ChainPrompt.
Importing one name but using another.
5fill in blank
hard

Fill all three blanks to run the chain and print the output.

Prompt Engineering / GenAI
input_data = [1](name="Alice")
result = chain.[2](input_data)
print(result[[3]])
Drag options to blanks, or click blank then click option'
Adict
Binvoke
C'text'
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Passing input as a list or other type instead of dict.
Using wrong method names like execute instead of invoke.
Accessing result with wrong keys.