Integrar herramientas y consultas personalizadas
Ahora tienes una herramienta matemática personalizada para calcular la longitud del tejado. Puedes integrarlo en un flujo de trabajo agéntico creando una variable llamada query
que acepte la pregunta en lenguaje natural del usuario como una cadena. Tu herramienta ya está cargada como hypotenuse_length
, así como tu model
.
Este ejercicio forma parte del curso
Diseño de Sistemas Agenéticos con LangChain
Instrucciones del ejercicio
- Crea una variable de lista llamada
tools
e incluye tu herramienta,hypotenuse_length
, dentro de la lista. - Crea una variable llamada
query
que acepte preguntas como cadenas de lenguaje natural. - Utiliza la función
create_react_agent()
para crear el agente, pasando los datosmodel
ytools
. - Invoca al agente
app
, pasándole tuquery
etiquetado"human"
, antes de almacenar e imprimir elresponse
del agente.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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)