Vincular varias herramientas
¡Acabas de crear varias herramientas! Ahora podrás añadirlas a tu chatbot vinculándolas primero al LLM. Las herramientas wikipedia_tool, palindrome_checker y historical_events ya se han añadido a tu entorno junto con llm. También crearás un nodo de herramientas para tu chatbot que liste todas las herramientas disponibles.
Este ejercicio forma parte del curso
Diseño de sistemas agénticos con LangChain
Instrucciones del ejercicio
- Desde
langgraph.prebuilt, importa el módulo necesario para definir un nodo de herramientas. - Completa la lista de herramientas añadiendo los nombres de herramienta adecuados presentes en tu entorno.
- Pasa la lista de
toolsa la claseToolNode()y asígnala atool_node. - Vincula las
toolsalllmusando.bind_tools().
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Import modules required for defining tool nodes
from ____.____ import ____
# List of tools
tools = [____, ____, ____]
# Pass the tools to the ToolNode()
____ = ____(____)
# Bind tools to the LLM
model_with_tools = ____.____(____)