Integrando ferramentas personalizadas e consultas
Agora você tem uma ferramenta matemática personalizada para calcular o comprimento do telhado. Você pode integrá-la a um fluxo de trabalho agentic criando uma variável chamada query que recebe a pergunta do usuário em linguagem natural como uma string. Sua ferramenta já está carregada como hypotenuse_length, assim como o seu model.
Este exercício faz parte do curso
Projetando Sistemas Agentes com LangChain
Instruções do exercício
- Crie uma variável de lista chamada
toolse inclua nela a sua ferramenta,hypotenuse_length. - Crie uma variável chamada
queryque receba perguntas como strings em linguagem natural. - Use a função
create_react_agent()para criar o agente, passando omodeletools. - Invoque o agente
app, passando suaqueryrotulada como"human", antes de armazenar e imprimir aresponsedo agente.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Create a list variable and pass in your tool
____ = [____]
# Create a query using natural language
____ = "What is the hypotenuse length of a triangle with side lengths of 10 and 12?"
# Pass in the hypotenuse length tool and create the agent
app = ____(____, ____)
# Invoke the agent and print the response
response = ____.____({"messages": [("____", ____)]})
print(____['messages'][-1].content)