Checked other resources
Example Code
from langchain_core.runnables import RunnableLambda, RunnableWithFallbacks
from langgraph.prebuilt import ToolNode
def create_tool_node_with_fallback(tools: list) -> RunnableWithFallbacks[Any, dict]:
"""
Create a ToolNode with a fallback to handle errors and surface them to the agent.
"""
return ToolNode(tools).with_fallbacks(
[RunnableLambda(handle_tool_error)], exception_key="error"
)
Error Message and Stack Trace (if applicable)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[66], line 2
1 from langchain_core.runnables import RunnableLambda, RunnableWithFallbacks
----> 2 from langgraph.prebuilt import ToolNode
5 def create_tool_node_with_fallback(tools: list) -> RunnableWithFallbacks[Any, dict]:
6 """
7 Create a ToolNode with a fallback to handle errors and surface them to the agent.
8 """
ImportError: cannot import name 'ToolNode' from 'langgraph.prebuilt' (/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/langgraph/prebuilt/__init__.py)
Description
I am getting this error today, when I was able to execute it before
System Info
from langgraph.prebuilt import ToolNode
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[66], line 2 1 from langchain_core.runnables import RunnableLambda, RunnableWithFallbacks ----> 2 from langgraph.prebuilt import ToolNode 5 def create_tool_node_with_fallback(tools: list) -> RunnableWithFallbacks[Any, dict]: 6 """ 7 Create a ToolNode with a fallback to handle errors and surface them to the agent. 8 """ ImportError: cannot import name 'ToolNode' from 'langgraph.prebuilt' (/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/langgraph/prebuilt/__init__.py)Description
I am getting this error today, when I was able to execute it before
System Info
from langgraph.prebuilt import ToolNode