0
0
LangChainframework~10 mins

OpenAI functions agent 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 OpenAI functions agent from LangChain.

LangChain
from langchain_community.agents import [1]
Drag options to blanks, or click blank then click option'
AAgentExecutor
BOpenAIChatAgent
COpenAIFunctionsAgent
DTool
Attempts:
3 left
💡 Hint
Common Mistakes
Importing OpenAIChatAgent instead of OpenAIFunctionsAgent
Using AgentExecutor which is a different class
Importing Tool which is unrelated here
2fill in blank
medium

Complete the code to create an OpenAI chat model with temperature 0.

LangChain
from langchain_openai import ChatOpenAI
chat = ChatOpenAI(temperature=[1])
Drag options to blanks, or click blank then click option'
A0
B1.0
C0.5
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using temperature 1.0 which is very random
Using negative temperature which is invalid
Using 0.5 which is moderate randomness
3fill in blank
hard

Fix the error in the code to create an OpenAI functions agent with the chat model and tools.

LangChain
agent = OpenAIFunctionsAgent.from_llm_and_tools([1], tools)
Drag options to blanks, or click blank then click option'
Allm
Bmodel
Copenai
Dchat
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 'llm' which is undefined here
Passing 'model' or 'openai' which are not defined variables
4fill in blank
hard

Fill both blanks to create a list of tools and initialize the agent executor.

LangChain
tools = [[1]]
agent_executor = AgentExecutor(agent=agent, tools=[2])
Drag options to blanks, or click blank then click option'
Atool
Btools
Cagent
Dexecutor
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tools' inside the list instead of 'tool'
Passing 'agent' instead of 'tools' to AgentExecutor
5fill in blank
hard

Fill all three blanks to run the agent executor with input and print the output.

LangChain
input_text = [1]
output = agent_executor.run([2])
print([3])
Drag options to blanks, or click blank then click option'
A"What is the weather today?"
Binput_text
Coutput
D"Hello world"
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name instead of a string literal for input_text
Printing input_text instead of output
Passing output instead of input_text to run()