IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Designing Agentic Systems with LangChain

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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({
    "____": ____,
    "____": ____["____"][____].____
})
Modifica ed esegui il codice