diff --git a/langgraph/prebuilt/chat_agent_executor.py b/langgraph/prebuilt/chat_agent_executor.py index 6bb30245c..fc68bcb85 100644 --- a/langgraph/prebuilt/chat_agent_executor.py +++ b/langgraph/prebuilt/chat_agent_executor.py @@ -274,7 +274,7 @@ def create_react_agent( ... ]) >>> def modify_messages(messages: list): ... # You can do more complex modifications here - ... return prompt.invoke(messages=messages) + ... return prompt.invoke({"messages": messages}) >>> >>> app = create_react_agent(model, tools, messages_modifier=modify_messages) >>> inputs = {"messages": [("user", "What's your name? And what's the weather in SF?")]} diff --git a/langgraph/prebuilt/tool_executor.py b/langgraph/prebuilt/tool_executor.py index 1c44700ee..cf3140e72 100644 --- a/langgraph/prebuilt/tool_executor.py +++ b/langgraph/prebuilt/tool_executor.py @@ -55,6 +55,7 @@ class ToolExecutor(RunnableCallable): Examples: + ```pycon >>> from langchain_core.tools import tool >>> from langgraph.prebuilt.tool_executor import ToolExecutor, ToolInvocation ... @@ -71,14 +72,17 @@ class ToolExecutor(RunnableCallable): >>> invocation = ToolInvocation(tool="search", tool_input="What is the capital of France?") >>> result = executor.invoke(invocation) >>> print(result) - Output: "Searching for: What is the capital of France?" + "Searching for: What is the capital of France?" + ``` + ```pycon >>> invocation = ToolInvocation( ... tool="nonexistent", tool_input="What is the capital of France?" ... ) >>> result = executor.invoke(invocation) >>> print(result) - Output: "nonexistent is not a valid tool, try one of [search]." + "nonexistent is not a valid tool, try one of [search]." + ``` """ def __init__( diff --git a/langgraph/prebuilt/tool_node.py b/langgraph/prebuilt/tool_node.py index 8b51897f8..b747b5091 100644 --- a/langgraph/prebuilt/tool_node.py +++ b/langgraph/prebuilt/tool_node.py @@ -139,8 +139,8 @@ def tools_condition( >>> graph_builder.add_node("chatbot", llm.bind_tools(tools)) >>> graph_builder.add_edge("tools", "chatbot") >>> graph_builder.add_conditional_edges( - >>> "chatbot", tools_condition - >>> ) + ... "chatbot", tools_condition + ... ) >>> graph_builder.set_entry_point("chatbot") >>> graph = graph_builder.compile() >>> graph.invoke([("user", "What's 329993 divided by 13662?")])