綁定多個工具
你剛剛建立了多個工具!現在你可以先把它們綁定到 LLM,再將它們加入你的聊天機器人。wikipedia_tool、palindrome_checker 和 historical_events 這些工具都已和 llm 一起加入你的環境。你也會建立一個工具節點,加入到聊天機器人中,列出所有可用的工具。
本練習屬於課程
Designing Agentic Systems with LangChain
練習說明
- 從
langgraph.prebuilt匯入用於定義工具節點所需的模組。 - 在你的環境中,將適當的工具名稱加入工具清單以完成清單。
- 將
tools清單傳入ToolNode()類別,並指定給tool_node。 - 使用
.bind_tools()將tools綁定到llm。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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 = ____.____(____)