Langgraph contd..
Lets interact with llms using langgraph and also our tools
-
For today our tools will be simple python functions Refer Here
-
In Langgraph tools are functions or external APIS that LLM can call as part of workflow or graph node.
- Tools extend the LLM capabilities beyond just generating,
- In a simplest form a tool is a function
- Best way to define a tool
from langchain.agents.tools import tool
@tool
def add_numbers(a: int, b: int) -> int:
"""Add two numbers and return the result"""
return a + b
-
@tool: decorator that registers the function as Langchain Tools
-
A tool is just a special object of python with:
- name
- description
- callable function
- In Langgraph, Each node represents a computation step and a common type of node is one that uses a tool
-
We can integrate tools inside Langgraph using
- An LLM that decides which tool to call
- A tool executer that executes the tool
- A langgraph node that wraps this logic
- using tools
- ToolNode
