0
0
LangChainframework~10 mins

ReAct agent implementation 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 base class for ReAct agents from LangChain.

LangChain
from langchain.agents import [1]
Drag options to blanks, or click blank then click option'
AAgentExecutor
BReActAgent
CTool
DLLMChain
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated classes like AgentExecutor or Tool instead of ReActAgent.
2fill in blank
medium

Complete the code to create a ReAct agent using the LLM and tools.

LangChain
agent = ReActAgent.from_llm_and_tools(llm, tools, [1]=True)
Drag options to blanks, or click blank then click option'
Averbose
Bsilent
Cdebug
Dinteractive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'silent' or 'debug' which are not valid parameters here.
3fill in blank
hard

Fix the error in the agent execution call to get the final output.

LangChain
result = agent.run([1])
Drag options to blanks, or click blank then click option'
Aquestion
Bquery
Cprompt
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable named 'input' or 'query' which may not be defined.
4fill in blank
hard

Fill both blanks to define tools and initialize the LLM for the ReAct agent.

LangChain
tools = [[1]]
llm = [2](temperature=0)
Drag options to blanks, or click blank then click option'
ATool(name='search', func=search_func, description='useful for web search')
BOpenAI
CChatOpenAI
DAgentExecutor
Attempts:
3 left
💡 Hint
Common Mistakes
Using AgentExecutor as a tool or using OpenAI instead of ChatOpenAI.
5fill in blank
hard

Fill all three blanks to create and run a ReAct agent with tools and print the output.

LangChain
agent = ReActAgent.from_llm_and_tools([1], [2], verbose=True)
output = agent.run([3])
print(output)
Drag options to blanks, or click blank then click option'
Allm
Btools
Cquestion
Dinput_text
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up variable names or passing undefined variables.