-
Couldn't load subscription status.
- Fork 19.5k
chore: move ToolNode improvements back to langgraph
#33634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7eea83b
e65a813
869a928
a0e53de
642db4d
b1f3605
8edf880
d5eb7c4
322191d
19e6cb1
d24f0cd
a939c0b
347b3e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| from langgraph._internal._runnable import RunnableCallable | ||
| from langgraph.constants import END, START | ||
| from langgraph.graph.state import StateGraph | ||
| from langgraph.prebuilt.tool_node import ToolCallWithContext, ToolNode | ||
| from langgraph.runtime import Runtime # noqa: TC002 | ||
| from langgraph.types import Command, Send | ||
| from langgraph.typing import ContextT # noqa: TC002 | ||
|
|
@@ -37,7 +38,6 @@ | |
| ToolStrategy, | ||
| ) | ||
| from langchain.chat_models import init_chat_model | ||
| from langchain.tools.tool_node import ToolCallWithContext, _ToolNode | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Awaitable, Callable, Sequence | ||
|
|
@@ -48,7 +48,7 @@ | |
| from langgraph.store.base import BaseStore | ||
| from langgraph.types import Checkpointer | ||
|
|
||
| from langchain.tools.tool_node import ToolCallRequest, ToolCallWrapper | ||
| from langchain.agents.middleware.types import ToolCallRequest, ToolCallWrapper | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to import this from middleware.types or from langgraph.prebuilt.tool_node directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something in langchain since langchain users will be working with that import rather than with an import from langgraph.prebuilt.tool_node There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't really think it matters |
||
|
|
||
| STRUCTURED_OUTPUT_ERROR_TEMPLATE = "Error: {error}\n Please fix your mistakes." | ||
|
|
||
|
|
@@ -675,7 +675,7 @@ def check_weather(location: str) -> str: | |
| awrap_tool_call_wrapper = _chain_async_tool_call_wrappers(async_wrappers) | ||
|
|
||
| # Setup tools | ||
| tool_node: _ToolNode | None = None | ||
| tool_node: ToolNode | None = None | ||
| # Extract built-in provider tools (dict format) and regular tools (BaseTool/callables) | ||
| built_in_tools = [t for t in tools if isinstance(t, dict)] | ||
| regular_tools = [t for t in tools if not isinstance(t, dict)] | ||
|
|
@@ -685,7 +685,7 @@ def check_weather(location: str) -> str: | |
|
|
||
| # Only create ToolNode if we have client-side tools | ||
| tool_node = ( | ||
| _ToolNode( | ||
| ToolNode( | ||
| tools=available_tools, | ||
| wrap_tool_call=wrap_tool_call_wrapper, | ||
| awrap_tool_call=awrap_tool_call_wrapper, | ||
|
|
@@ -1491,7 +1491,7 @@ def model_to_model( | |
|
|
||
| def _make_tools_to_model_edge( | ||
| *, | ||
| tool_node: _ToolNode, | ||
| tool_node: ToolNode, | ||
| model_destination: str, | ||
| structured_output_tools: dict[str, OutputToolBinding], | ||
| end_destination: str, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is still there for backwards compat, but I think from middleware is good for now