Aan de slagGa gratis aan de slag

Conversation setup

Now that you have a custom tool to help you calculate the length of a roof, you can set your agent's outputs to respond to your entered query. By slightly modifying your print statements, you can directly compare your query and your agent's response to ensure accuracy. Your tools and query have already been set up and your model is ready to use.

Deze oefening maakt deel uit van de cursus

Designing Agentic Systems with LangChain

Cursus bekijken

Oefeninstructies

  • Initialize the create_react_agent function creating an object called app, passing in the required arguments.
  • Invoke the agent app, passing in your query, before storing and printing the agent's response.
  • Define the "user_input" as query and the "agent_output" as the last item extracted from "messages" in response before both are printed.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

tools = [hypotenuse_length]
query = "What is the value of the hypotenuse for a triangle with sides 3 and 5?"

# Create the ReAct agent
app = ____(____, ____)

# Invoke the agent with a query and store the messages
response = ____.____({"messages": [("human", ____)]})

# Define and print the input and output messages
print({
    "____": ____,
    "____": ____["____"][____].____
})
Code bewerken en uitvoeren