0
0
Prompt Engineering / GenAIml~10 mins

Why LangChain simplifies LLM applications in Prompt Engineering / GenAI - Test Your Understanding

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

Complete the code to import the main LangChain class for building LLM apps.

Prompt Engineering / GenAI
from langchain.chains import [1]
Drag options to blanks, or click blank then click option'
AChain
BLLMChain
CModel
DLangChain
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a class that does not exist in LangChain.
Confusing LangChain with the model class.
2fill in blank
medium

Complete the code to create a prompt template in LangChain.

Prompt Engineering / GenAI
from langchain.prompts import [1]
prompt = [1](template="Hello, {name}!")
Drag options to blanks, or click blank then click option'
APromptBuilder
BPrompt
CTemplatePrompt
DPromptTemplate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class that does not exist in LangChain prompts module.
Confusing with generic 'Prompt'.
3fill in blank
hard

Fix the error in this LangChain code to run the chain with input variables.

Prompt Engineering / GenAI
result = chain.run([1])
Drag options to blanks, or click blank then click option'
A{'name': 'Alice'}
B"name='Alice'"
Cname='Alice'
D['name', 'Alice']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a dictionary.
Passing a tuple or list instead of dict.
4fill in blank
hard

Fill both blanks to create an LLMChain with OpenAI model and prompt template.

Prompt Engineering / GenAI
from langchain.llms import [1]
from langchain.prompts import [2]
from langchain.chains import LLMChain
chain = LLMChain(llm=[1](), prompt=[2](template="Hello, {name}!"))
Drag options to blanks, or click blank then click option'
AOpenAI
BChatOpenAI
CPromptTemplate
DPrompt
Attempts:
3 left
💡 Hint
Common Mistakes
Using ChatOpenAI instead of OpenAI for this example.
Using a wrong prompt class.
5fill in blank
hard

Fill all three blanks to build and run a LangChain app that greets a user.

Prompt Engineering / GenAI
from langchain.llms import [1]
from langchain.prompts import [2]
from langchain.chains import LLMChain
chain = LLMChain(llm=[1](), prompt=[2](template="Hello, {name}!"))
output = chain.run([3])
print(output)
Drag options to blanks, or click blank then click option'
AOpenAI
BPromptTemplate
C{'name': 'Bob'}
DChatOpenAI
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up LLM classes.
Passing inputs as string instead of dict.
Using wrong prompt class.