diff --git a/examples/agent_executor/base.ipynb b/examples/agent_executor/base.ipynb index 99def6da0..31aad70a5 100644 --- a/examples/agent_executor/base.ipynb +++ b/examples/agent_executor/base.ipynb @@ -78,7 +78,7 @@ "source": [ "## Create the LangChain agent\n", "\n", - "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/docs/modules/agents/)" + "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/v0.2/docs/concepts/#agents)" ] }, { @@ -156,7 +156,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/agent_executor/force-calling-a-tool-first.ipynb b/examples/agent_executor/force-calling-a-tool-first.ipynb index 8034cf8ce..e2d464dcf 100644 --- a/examples/agent_executor/force-calling-a-tool-first.ipynb +++ b/examples/agent_executor/force-calling-a-tool-first.ipynb @@ -83,7 +83,7 @@ "source": [ "## Create the LangChain agent\n", "\n", - "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/docs/modules/agents/)" + "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/v0.2/docs/concepts/#agents)" ] }, { @@ -161,7 +161,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/agent_executor/human-in-the-loop.ipynb b/examples/agent_executor/human-in-the-loop.ipynb index 6916fe32c..f53930192 100644 --- a/examples/agent_executor/human-in-the-loop.ipynb +++ b/examples/agent_executor/human-in-the-loop.ipynb @@ -83,7 +83,7 @@ "source": [ "## Create the LangChain agent\n", "\n", - "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/docs/modules/agents/)" + "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/v0.2/docs/concepts/#agents)" ] }, { @@ -161,7 +161,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/agent_executor/managing-agent-steps.ipynb b/examples/agent_executor/managing-agent-steps.ipynb index 1f463df94..24b10d9c1 100644 --- a/examples/agent_executor/managing-agent-steps.ipynb +++ b/examples/agent_executor/managing-agent-steps.ipynb @@ -83,7 +83,7 @@ "source": [ "## Create the LangChain agent\n", "\n", - "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/docs/modules/agents/)" + "First, we will create the LangChain agent. For more information on LangChain agents, see [this documentation](https://python.langchain.com/v0.2/docs/concepts/#agents)" ] }, { @@ -161,7 +161,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/async.ipynb b/examples/async.ipynb index 6dea1383e..848c48cf6 100644 --- a/examples/async.ipynb +++ b/examples/async.ipynb @@ -586,7 +586,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/chat_agent_executor_with_function_calling/anthropic.ipynb b/examples/chat_agent_executor_with_function_calling/anthropic.ipynb index ec7e1c0e9..3c7f975b7 100644 --- a/examples/chat_agent_executor_with_function_calling/anthropic.ipynb +++ b/examples/chat_agent_executor_with_function_calling/anthropic.ipynb @@ -82,7 +82,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n", + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n", "\n", "**MODIFICATION**\n", "\n", @@ -183,7 +183,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -305,7 +305,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/base.ipynb b/examples/chat_agent_executor_with_function_calling/base.ipynb index b45c62232..f9384f68f 100644 --- a/examples/chat_agent_executor_with_function_calling/base.ipynb +++ b/examples/chat_agent_executor_with_function_calling/base.ipynb @@ -81,7 +81,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -211,7 +211,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -380,7 +380,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/dynamically-returning-directly.ipynb b/examples/chat_agent_executor_with_function_calling/dynamically-returning-directly.ipynb index ebe8c6cfb..8ac2e500b 100644 --- a/examples/chat_agent_executor_with_function_calling/dynamically-returning-directly.ipynb +++ b/examples/chat_agent_executor_with_function_calling/dynamically-returning-directly.ipynb @@ -17,7 +17,7 @@ "
\n", "

Note

\n", "

\n", - " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, interrupt_before=[\"agent\" | \"tools\"], interrupt_after=[\"agent\" | \"tools\"], checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", + " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, interrupt_before=[\"agent\" | \"tools\"], interrupt_after=[\"agent\" | \"tools\"], checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", "

\n", "
" ] @@ -93,7 +93,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n", + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n", "\n", "**MODIFICATION**\n", "\n", @@ -248,7 +248,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -475,7 +475,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/force-calling-a-tool-first.ipynb b/examples/chat_agent_executor_with_function_calling/force-calling-a-tool-first.ipynb index 5ba9e1901..b2ae9ba1a 100644 --- a/examples/chat_agent_executor_with_function_calling/force-calling-a-tool-first.ipynb +++ b/examples/chat_agent_executor_with_function_calling/force-calling-a-tool-first.ipynb @@ -90,7 +90,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -226,7 +226,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -458,7 +458,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { @@ -707,7 +707,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/chat_agent_executor_with_function_calling/human-in-the-loop.ipynb b/examples/chat_agent_executor_with_function_calling/human-in-the-loop.ipynb index 11aa66b8c..9ab467887 100644 --- a/examples/chat_agent_executor_with_function_calling/human-in-the-loop.ipynb +++ b/examples/chat_agent_executor_with_function_calling/human-in-the-loop.ipynb @@ -102,7 +102,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -232,7 +232,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -426,7 +426,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/managing-agent-steps.ipynb b/examples/chat_agent_executor_with_function_calling/managing-agent-steps.ipynb index fd99f9245..35f494b95 100644 --- a/examples/chat_agent_executor_with_function_calling/managing-agent-steps.ipynb +++ b/examples/chat_agent_executor_with_function_calling/managing-agent-steps.ipynb @@ -85,7 +85,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -215,7 +215,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -421,7 +421,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/prebuilt-tool-node.ipynb b/examples/chat_agent_executor_with_function_calling/prebuilt-tool-node.ipynb index 9bd9b1df8..da0e8b3c9 100644 --- a/examples/chat_agent_executor_with_function_calling/prebuilt-tool-node.ipynb +++ b/examples/chat_agent_executor_with_function_calling/prebuilt-tool-node.ipynb @@ -82,7 +82,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n", + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n", "\n", "**MODIFICATION**\n", "\n", @@ -192,7 +192,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -314,7 +314,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/chat_agent_executor_with_function_calling/respond-in-format.ipynb b/examples/chat_agent_executor_with_function_calling/respond-in-format.ipynb index c641fd6db..3e1f82577 100644 --- a/examples/chat_agent_executor_with_function_calling/respond-in-format.ipynb +++ b/examples/chat_agent_executor_with_function_calling/respond-in-format.ipynb @@ -64,7 +64,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -227,7 +227,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -372,7 +372,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -562,7 +562,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/code_assistant/langgraph_code_assistant.ipynb b/examples/code_assistant/langgraph_code_assistant.ipynb index 8f63d7863..c435cd3ce 100644 --- a/examples/code_assistant/langgraph_code_assistant.ipynb +++ b/examples/code_assistant/langgraph_code_assistant.ipynb @@ -18,7 +18,7 @@ "\n", "[AlphaCodium](https://github.com/Codium-ai/AlphaCodium) iteravely tests and improves an answer on public and AI-generated tests for a particular question. \n", "\n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph):\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/):\n", "\n", "1. We start with a set of documentation specified by a user\n", "2. We use a long context LLM to ingest it and perform RAG to answer a question based upon it\n", @@ -45,7 +45,7 @@ "source": [ "## Docs\n", "\n", - "Load [LangChain Expression Language](https://python.langchain.com/docs/expression_language/) (LCEL) docs as an example." + "Load [LangChain Expression Language](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) (LCEL) docs as an example." ] }, { @@ -59,7 +59,7 @@ "from langchain_community.document_loaders.recursive_url_loader import RecursiveUrlLoader\n", "\n", "# LCEL docs\n", - "url = \"https://python.langchain.com/docs/expression_language/\"\n", + "url = \"https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel\"\n", "loader = RecursiveUrlLoader(\n", " url=url, max_depth=20, extractor=lambda x: Soup(x, \"html.parser\").text\n", ")\n", diff --git a/examples/code_assistant/langgraph_code_assistant_mistral.ipynb b/examples/code_assistant/langgraph_code_assistant_mistral.ipynb index 0d6d7b586..0533444b9 100644 --- a/examples/code_assistant/langgraph_code_assistant_mistral.ipynb +++ b/examples/code_assistant/langgraph_code_assistant_mistral.ipynb @@ -18,7 +18,7 @@ "\n", "[AlphaCodium](https://github.com/Codium-ai/AlphaCodium) iteravely tests and improves an answer on public and AI-generated tests for a particular question. \n", "\n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph):\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/):\n", "\n", "1. We show how to route user questions to different types of documentation\n", "2. We we will show how to perform inline unit tests to confirm imports and code execution work\n", diff --git a/examples/dynamically-returning-directly.ipynb b/examples/dynamically-returning-directly.ipynb index c7b81c1ab..38b9e3b0e 100644 --- a/examples/dynamically-returning-directly.ipynb +++ b/examples/dynamically-returning-directly.ipynb @@ -605,7 +605,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/extraction/retries.ipynb b/examples/extraction/retries.ipynb index 9612c99a7..47de6529d 100644 --- a/examples/extraction/retries.ipynb +++ b/examples/extraction/retries.ipynb @@ -424,7 +424,7 @@ "from langchain_core.prompts import ChatPromptTemplate\n", "\n", "# Or you can use ChatGroq, ChatOpenAI, ChatGoogleGemini, ChatCohere, etc.\n", - "# See https://python.langchain.com/v0.1/docs/integrations/chat/ for more info on tool calling\n", + "# See https://python.langchain.com/v0.2/docs/integrations/chat/ for more info on tool calling\n", "llm = ChatAnthropic(model=\"claude-3-haiku-20240307\")\n", "bound_llm = bind_validator_with_retries(llm, tools=tools)\n", "prompt = ChatPromptTemplate.from_messages(\n", diff --git a/examples/force-calling-a-tool-first.ipynb b/examples/force-calling-a-tool-first.ipynb index 7f4cd6086..1c1947e1b 100644 --- a/examples/force-calling-a-tool-first.ipynb +++ b/examples/force-calling-a-tool-first.ipynb @@ -81,7 +81,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { diff --git a/examples/human-in-the-loop.ipynb b/examples/human-in-the-loop.ipynb index efe1f5cf1..1042d714f 100644 --- a/examples/human-in-the-loop.ipynb +++ b/examples/human-in-the-loop.ipynb @@ -18,7 +18,7 @@ "
\n", "

Note

\n", "

\n", - " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using either `interrupt_before` or `interrupt_after` in the create_react_agent(model, tools=tool, interrupt_before=[\"tools\" | \"agent\"], interrupt_after=[\"tools\" | \"agent\"]) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", + " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using either `interrupt_before` or `interrupt_after` in the create_react_agent(model, tools=tool, interrupt_before=[\"tools\" | \"agent\"], interrupt_after=[\"tools\" | \"agent\"]) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", "

\n", "
" ] @@ -668,7 +668,7 @@ ] }, { - "name": "stdin", + "name": "stdout", "output_type": "stream", "text": [ " can you specify sf in CA?\n" @@ -699,7 +699,7 @@ ] }, { - "name": "stdin", + "name": "stdout", "output_type": "stream", "text": [ " y\n" @@ -972,7 +972,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/introduction.ipynb b/examples/introduction.ipynb index 68fe172e5..5cdde3480 100644 --- a/examples/introduction.ipynb +++ b/examples/introduction.ipynb @@ -398,7 +398,7 @@ "\n", "Before we start, make sure you have the necessary packages installed and API keys set up:\n", "\n", - "First, install the requirements to use the [Tavily Search Engine](https://python.langchain.com/docs/integrations/tools/tavily_search/), and set your [TAVILY_API_KEY](https://tavily.com/)." + "First, install the requirements to use the [Tavily Search Engine](https://python.langchain.com/v0.2/docs/integrations/tools/tavily_search/), and set your [TAVILY_API_KEY](https://tavily.com/)." ] }, { @@ -1443,7 +1443,7 @@ "=================================\u001b[1m Tool Message \u001b[0m=================================\n", "Name: tavily_search_results_json\n", "\n", - "[{\"url\": \"https://github.com/langchain-ai/langgraph\", \"content\": \"LangGraph is a Python package that extends LangChain Expression Language with the ability to coordinate multiple chains across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam and can be used for agent-like behaviors, such as chatbots, with LLMs.\"}, {\"url\": \"https://python.langchain.com/docs/langgraph/\", \"content\": \"LangGraph is a library for building stateful, multi-actor applications with LLMs, built on top of (and intended to be used with) LangChain . It extends the LangChain Expression Language with the ability to coordinate multiple chains (or actors) across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam .\"}]\n", + "[{\"url\": \"https://github.com/langchain-ai/langgraph\", \"content\": \"LangGraph is a Python package that extends LangChain Expression Language with the ability to coordinate multiple chains across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam and can be used for agent-like behaviors, such as chatbots, with LLMs.\"}, {\"url\": \"https://langchain-ai.github.io/langgraph//\", \"content\": \"LangGraph is a library for building stateful, multi-actor applications with LLMs, built on top of (and intended to be used with) LangChain . It extends the LangChain Expression Language with the ability to coordinate multiple chains (or actors) across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam .\"}]\n", "==================================\u001b[1m Ai Message \u001b[0m==================================\n", "\n", "Based on the search results, LangGraph seems to be a Python library that extends the LangChain library to enable more complex, multi-step interactions with large language models (LLMs). Some key points:\n", diff --git a/examples/learning.ipynb b/examples/learning.ipynb index 1f00937a3..0b4c27db1 100644 --- a/examples/learning.ipynb +++ b/examples/learning.ipynb @@ -101,7 +101,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use a built-in search tool via Tavily.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -192,7 +192,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/llm-compiler/LLMCompiler.ipynb b/examples/llm-compiler/LLMCompiler.ipynb index 2530cca78..23a75ab57 100644 --- a/examples/llm-compiler/LLMCompiler.ipynb +++ b/examples/llm-compiler/LLMCompiler.ipynb @@ -68,7 +68,7 @@ "\n", "We'll first define the tools for the agent to use in our demo. We'll give it the class search engine + calculator combo.\n", "\n", - "If you don't want to sign up for tavily, you can replace it with the free [DuckDuckGo](https://python.langchain.com/docs/integrations/tools/ddg)." + "If you don't want to sign up for tavily, you can replace it with the free [DuckDuckGo](https://python.langchain.com/v0.2/docs/integrations/tools/ddg/)." ] }, { diff --git a/examples/managing-agent-steps.ipynb b/examples/managing-agent-steps.ipynb index 48e733708..97c2abd05 100644 --- a/examples/managing-agent-steps.ipynb +++ b/examples/managing-agent-steps.ipynb @@ -129,7 +129,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -231,7 +231,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -394,7 +394,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { @@ -677,7 +677,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/pass-run-time-values-to-tools.ipynb b/examples/pass-run-time-values-to-tools.ipynb index feda568af..ebeae58ef 100644 --- a/examples/pass-run-time-values-to-tools.ipynb +++ b/examples/pass-run-time-values-to-tools.ipynb @@ -90,7 +90,7 @@ "source": [ "## Set up the tools\n", "\n", - "Here, we will make a function that dynamically creates 3 [custom-tools](https://python.langchain.com/docs/modules/agents/tools/custom_tools).\n", + "Here, we will make a function that dynamically creates 3 [custom-tools](https://python.langchain.com/v0.2/docs/how_to/custom_tools).\n", "\n", "This function will bind to the tools the correct `user_id`, allowing the LLM to only fill in the other relevant values. Importantly,\n", "the LLM will be **unaware** that a user ID even exists!" @@ -206,7 +206,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -391,7 +391,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/persistence.ipynb b/examples/persistence.ipynb index 7ead6c69c..32d7b2e5d 100644 --- a/examples/persistence.ipynb +++ b/examples/persistence.ipynb @@ -33,7 +33,7 @@ "
\n", "

Note

\n", "

\n", - " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", + " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", "

\n", "
" ] @@ -147,7 +147,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -202,7 +202,7 @@ "For the design below, it must satisfy two criteria:\n", "\n", "1. It should work with **messages** (since our state contains a list of chat messages)\n", - "2. It should work with [**tool calling**](https://python.langchain.com/v0.1/docs/modules/model_io/chat/function_calling/).\n", + "2. It should work with [**tool calling**](https://python.langchain.com/v0.2/docs/concepts/#functiontool-calling).\n", "\n", "
\n", "

Note

\n", @@ -255,7 +255,7 @@ "## Define the graph \n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/plan-and-execute/plan-and-execute.ipynb b/examples/plan-and-execute/plan-and-execute.ipynb index 1612fd730..5f044c5eb 100644 --- a/examples/plan-and-execute/plan-and-execute.ipynb +++ b/examples/plan-and-execute/plan-and-execute.ipynb @@ -105,7 +105,7 @@ "source": [ "## Define Tools\n", "\n", - "We will first define the tools we want to use. For this simple example, we will use a built-in search tool via Tavily. However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that." + "We will first define the tools we want to use. For this simple example, we will use a built-in search tool via Tavily. However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that." ] }, { diff --git a/examples/rag/langgraph_agentic_rag.ipynb b/examples/rag/langgraph_agentic_rag.ipynb index 0eefd0744..01049aa82 100644 --- a/examples/rag/langgraph_agentic_rag.ipynb +++ b/examples/rag/langgraph_agentic_rag.ipynb @@ -7,11 +7,11 @@ "source": [ "# LangGraph Retrieval Agent\n", "\n", - "[Retrieval Agents](https://python.langchain.com/docs/use_cases/question_answering/conversational_retrieval_agents) are useful when we want to make decisions about whether to retrieve from an index.\n", + "[Retrieval Agents](https://python.langchain.com/v0.2/docs/tutorials/qa_chat_history/#agents) are useful when we want to make decisions about whether to retrieve from an index.\n", "\n", "To implement a retrieval agent, we simple need to give an LLM access to a retriever tool.\n", "\n", - "We can incorporate this into [LangGraph](https://python.langchain.com/docs/langgraph)." + "We can incorporate this into [LangGraph](https://langchain-ai.github.io/langgraph/)." ] }, { diff --git a/examples/rag/langgraph_crag.ipynb b/examples/rag/langgraph_crag.ipynb index 70940d173..fbe536e6d 100644 --- a/examples/rag/langgraph_crag.ipynb +++ b/examples/rag/langgraph_crag.ipynb @@ -23,11 +23,11 @@ "* If all documents fall below the relevance threshold or if the grader is unsure, then the framework seeks an additional datasource\n", "* It will use web search to supplement retrieval\n", " \n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph):\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/):\n", "\n", "* Let's skip the knowledge refinement phase as a first pass. This can be added back as a node, if desired. \n", "* If *any* documents are irrelevant, let's opt to supplement retrieval with web search. \n", - "* We'll use [Tavily Search](https://python.langchain.com/docs/integrations/tools/tavily_search) for web search.\n", + "* We'll use [Tavily Search](https://python.langchain.com/v0.2/docs/integrations/tools/tavily_search/) for web search.\n", "* Let's use query re-writing to optimize the query for web search.\n", "\n", "![Screenshot 2024-04-01 at 9.28.30 AM.png](attachment:683fae34-980f-43f0-a9c2-9894bebd9157.png)" diff --git a/examples/rag/langgraph_crag_local.ipynb b/examples/rag/langgraph_crag_local.ipynb index 70ed86f7d..a898f93f9 100644 --- a/examples/rag/langgraph_crag_local.ipynb +++ b/examples/rag/langgraph_crag_local.ipynb @@ -23,11 +23,11 @@ "* If all documents fall below the relevance threshold or if the grader is unsure, then the framework seeks an additional datasource\n", "* It will use web search to supplement retrieval\n", " \n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph):\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/):\n", "\n", "* Let's skip the knowledge refinement phase as a first pass. This can be added back as a node, if desired. \n", "* If *any* documents are irrelevant, let's opt to supplement retrieval with web search. \n", - "* We'll use [Tavily Search](https://python.langchain.com/docs/integrations/tools/tavily_search) for web search.\n", + "* We'll use [Tavily Search](https://python.langchain.com/v0.2/docs/integrations/tools/tavily_search/) for web search.\n", "* Let's use query re-writing to optimize the query for web search.\n", "\n", "![Screenshot 2024-04-01 at 12.36.05 PM.png](attachment:d3ff129f-c0ff-4951-993c-efafc7f29dce.png)\n", diff --git a/examples/rag/langgraph_self_rag.ipynb b/examples/rag/langgraph_self_rag.ipynb index d27eb3478..3f309a237 100644 --- a/examples/rag/langgraph_self_rag.ipynb +++ b/examples/rag/langgraph_self_rag.ipynb @@ -40,7 +40,7 @@ "* `y (generation)` is a useful response to `x (question)`.\n", "* Output: `{5, 4, 3, 2, 1}`\n", "\n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph).\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/).\n", "\n", "![Screenshot 2024-04-01 at 12.41.50 PM.png](attachment:15cba0ab-a549-4909-8373-fb761e384eff.png)" ] diff --git a/examples/rag/langgraph_self_rag_local.ipynb b/examples/rag/langgraph_self_rag_local.ipynb index dce12a9cf..df160e9aa 100644 --- a/examples/rag/langgraph_self_rag_local.ipynb +++ b/examples/rag/langgraph_self_rag_local.ipynb @@ -40,7 +40,7 @@ "* `y (generation)` is a useful response to `x (question)`.\n", "* Output: `{5, 4, 3, 2, 1}`\n", "\n", - "We will implement some of these ideas from scratch using [LangGraph](https://python.langchain.com/docs/langgraph).\n", + "We will implement some of these ideas from scratch using [LangGraph](https://langchain-ai.github.io/langgraph/).\n", "\n", "![Screenshot 2024-04-01 at 12.42.59 PM.png](attachment:5fca0a3e-d13d-4bfa-95ea-58203640cc7a.png)" ] diff --git a/examples/respond-in-format.ipynb b/examples/respond-in-format.ipynb index 6d71adeed..a77a30791 100644 --- a/examples/respond-in-format.ipynb +++ b/examples/respond-in-format.ipynb @@ -131,7 +131,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -282,7 +282,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -417,7 +417,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { @@ -500,7 +500,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/examples/rewoo/rewoo.ipynb b/examples/rewoo/rewoo.ipynb index 818882380..ee9228fe1 100644 --- a/examples/rewoo/rewoo.ipynb +++ b/examples/rewoo/rewoo.ipynb @@ -36,7 +36,7 @@ "\n", "## 0. Prerequisites\n", "\n", - "For this example, we will provide the agent with a Tavily search engine tool. You can get an API key [here](https://app.tavily.com/sign-in) or replace with a free tool option (e.g., [duck duck go search](https://python.langchain.com/docs/integrations/tools/ddg)).\n", + "For this example, we will provide the agent with a Tavily search engine tool. You can get an API key [here](https://app.tavily.com/sign-in) or replace with a free tool option (e.g., [duck duck go search](https://python.langchain.com/v0.2/docs/integrations/tools/ddg/)).\n", "\n", "To see the full langsmith trace, you can s" ] diff --git a/examples/state-model.ipynb b/examples/state-model.ipynb index 31b818821..5a1bca9fe 100644 --- a/examples/state-model.ipynb +++ b/examples/state-model.ipynb @@ -92,7 +92,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -231,7 +231,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", @@ -400,7 +400,7 @@ "## Use it!\n", "\n", "We can now use it!\n", - "This now exposes the [same interface](https://python.langchain.com/docs/expression_language/) as all other LangChain runnables." + "This now exposes the [same interface](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel) as all other LangChain runnables." ] }, { diff --git a/examples/streaming-tokens.ipynb b/examples/streaming-tokens.ipynb index d91594246..28e786648 100644 --- a/examples/streaming-tokens.ipynb +++ b/examples/streaming-tokens.ipynb @@ -14,7 +14,7 @@ "
\n", "

Note

\n", "

\n", - " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", + " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", "

\n", "
\n", "\n", @@ -144,7 +144,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "It is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -244,7 +244,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/time-travel.ipynb b/examples/time-travel.ipynb index 244f48681..598623a9e 100644 --- a/examples/time-travel.ipynb +++ b/examples/time-travel.ipynb @@ -25,7 +25,7 @@ "
\n", "

Note:

\n", "

\n", - " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", + " In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n", "

\n", "
" ] @@ -139,7 +139,7 @@ "\n", "We will first define the tools we want to use.\n", "For this simple example, we will use create a placeholder search engine.\n", - "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/docs/modules/agents/tools/custom_tools) on how to do that.\n" + "However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that.\n" ] }, { @@ -239,7 +239,7 @@ "## Define the nodes\n", "\n", "We now need to define a few different nodes in our graph.\n", - "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/docs/expression_language/).\n", + "In `langgraph`, a node can be either a function or a [runnable](https://python.langchain.com/v0.2/docs/concepts/#langchain-expression-language-lcel).\n", "There are two main nodes we need for this:\n", "\n", "1. The agent: responsible for deciding what (if any) actions to take.\n", diff --git a/examples/tutorials/sql-agent.ipynb b/examples/tutorials/sql-agent.ipynb index 3c1555616..b3946b9d0 100644 --- a/examples/tutorials/sql-agent.ipynb +++ b/examples/tutorials/sql-agent.ipynb @@ -43,11 +43,11 @@ "execution_count": 1, "id": "6c05a600f1afb5b6", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-06-12T21:24:00.532147Z", "start_time": "2024-06-12T21:24:00.526043Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -78,11 +78,11 @@ "execution_count": 2, "id": "64b0bf1b14c2e902", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-06-12T21:24:09.918436Z", "start_time": "2024-06-12T21:24:09.608563Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -125,11 +125,11 @@ "execution_count": 3, "id": "a60191bd3489f278", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-06-12T21:24:14.663745Z", "start_time": "2024-06-12T21:24:13.527958Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -142,11 +142,11 @@ "execution_count": 4, "id": "1f1e1f4f86ed54", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-06-12T21:24:15.891582Z", "start_time": "2024-06-12T21:24:15.289782Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -192,11 +192,11 @@ "execution_count": 5, "id": "deae8460e4cf72b1", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-06-12T21:24:17.557848Z", "start_time": "2024-06-12T21:24:17.508550Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -214,6 +214,7 @@ " [RunnableLambda(handle_tool_error)], exception_key=\"error\"\n", " )\n", "\n", + "\n", "def handle_tool_error(state) -> dict:\n", " error = state.get(\"error\")\n", " tool_calls = state[\"messages\"][-1].tool_calls\n", @@ -341,6 +342,7 @@ " return \"Error: Query failed. Please rewrite your query and try again.\"\n", " return result\n", "\n", + "\n", "print(db_query_tool.invoke(\"SELECT * FROM Artist LIMIT 10;\"))" ] }, @@ -393,8 +395,12 @@ "\n", "You will call the appropriate tool to execute the query after running this check.\"\"\"\n", "\n", - "query_check_prompt = ChatPromptTemplate.from_messages([(\"system\", query_check_system),(\"placeholder\", \"{messages}\")])\n", - "query_check = query_check_prompt | ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools([db_query_tool], tool_choice=\"required\")\n", + "query_check_prompt = ChatPromptTemplate.from_messages(\n", + " [(\"system\", query_check_system), (\"placeholder\", \"{messages}\")]\n", + ")\n", + "query_check = query_check_prompt | ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools(\n", + " [db_query_tool], tool_choice=\"required\"\n", + ")\n", "\n", "query_check.invoke({\"messages\": [(\"user\", \"SELET * FROM Artist LIMIT 10;\")]})" ] @@ -440,9 +446,11 @@ "class State(TypedDict):\n", " messages: Annotated[list[AnyMessage], add_messages]\n", "\n", + "\n", "# Define a new graph\n", "workflow = StateGraph(State)\n", "\n", + "\n", "# Add a node for the first tool call\n", "def first_tool_call(state: State) -> dict[str, list[AIMessage]]:\n", " return {\n", @@ -452,8 +460,7 @@ " tool_calls=[\n", " {\n", " \"name\": \"sql_db_list_tables\",\n", - " \"args\": {\n", - " },\n", + " \"args\": {},\n", " \"id\": \"tool_abcd123\",\n", " }\n", " ],\n", @@ -461,31 +468,41 @@ " ]\n", " }\n", "\n", + "\n", "def model_check_query(state: State) -> dict[str, list[AIMessage]]:\n", " \"\"\"\n", " Use this tool to double-check if your query is correct before executing it.\n", " \"\"\"\n", - " return {\n", - " \"messages\": [\n", - " query_check.invoke({\"messages\": [state[\"messages\"][-1]]})\n", - " ]\n", - " }\n", + " return {\"messages\": [query_check.invoke({\"messages\": [state[\"messages\"][-1]]})]}\n", + "\n", "\n", "workflow.add_node(\"first_tool_call\", first_tool_call)\n", "\n", "# Add nodes for the first two tools\n", - "workflow.add_node(\"list_tables_tool\", create_tool_node_with_fallback([list_tables_tool]))\n", + "workflow.add_node(\n", + " \"list_tables_tool\", create_tool_node_with_fallback([list_tables_tool])\n", + ")\n", "workflow.add_node(\"get_schema_tool\", create_tool_node_with_fallback([get_schema_tool]))\n", "\n", "# Add a node for a model to choose the relevant tables based on the question and available tables\n", - "model_get_schema = ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools([get_schema_tool])\n", - "workflow.add_node(\"model_get_schema\", lambda state: {\"messages\": [model_get_schema.invoke(state[\"messages\"])],})\n", + "model_get_schema = ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools(\n", + " [get_schema_tool]\n", + ")\n", + "workflow.add_node(\n", + " \"model_get_schema\",\n", + " lambda state: {\n", + " \"messages\": [model_get_schema.invoke(state[\"messages\"])],\n", + " },\n", + ")\n", + "\n", "\n", "# Describe a tool to represent the end state\n", "class SubmitFinalAnswer(BaseModel):\n", " \"\"\"Submit the final answer to the user based on the query results.\"\"\"\n", + "\n", " final_answer: str = Field(..., description=\"The final answer to the user\")\n", "\n", + "\n", "# Add a node for a model to generate a query based on the question and schema\n", "query_gen_system = \"\"\"You are a SQL expert with a strong attention to detail.\n", "\n", @@ -509,11 +526,17 @@ "If you have enough information to answer the input question, simply invoke the appropriate tool to submit the final answer to the user.\n", "\n", "DO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\"\"\"\n", - "query_gen_prompt = ChatPromptTemplate.from_messages([(\"system\", query_gen_system),(\"placeholder\", \"{messages}\")])\n", - "query_gen = query_gen_prompt | ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools([SubmitFinalAnswer])\n", + "query_gen_prompt = ChatPromptTemplate.from_messages(\n", + " [(\"system\", query_gen_system), (\"placeholder\", \"{messages}\")]\n", + ")\n", + "query_gen = query_gen_prompt | ChatOpenAI(model=\"gpt-4o\", temperature=0).bind_tools(\n", + " [SubmitFinalAnswer]\n", + ")\n", + "\n", + "\n", "def query_gen_node(state: State):\n", " message = query_gen.invoke(state)\n", - " \n", + "\n", " # Sometimes, the LLM will hallucinate and call the wrong tool. We need to catch this and return an error message.\n", " tool_messages = []\n", " if message.tool_calls:\n", @@ -529,6 +552,7 @@ " tool_messages = []\n", " return {\"messages\": [message] + tool_messages}\n", "\n", + "\n", "workflow.add_node(\"query_gen\", query_gen_node)\n", "\n", "# Add a node for the model to check the query before executing it\n", @@ -537,6 +561,7 @@ "# Add node for executing the query\n", "workflow.add_node(\"execute_query\", create_tool_node_with_fallback([db_query_tool]))\n", "\n", + "\n", "# Define a conditional edge to decide whether to continue or end the workflow\n", "def should_continue(state: State) -> Literal[END, \"correct_query\", \"query_gen\"]:\n", " messages = state[\"messages\"]\n", @@ -549,6 +574,7 @@ " else:\n", " return \"correct_query\"\n", "\n", + "\n", "# Specify the edges between the nodes\n", "workflow.set_entry_point(\"first_tool_call\")\n", "workflow.add_edge(\"first_tool_call\", \"list_tables_tool\")\n", @@ -649,7 +675,9 @@ } ], "source": [ - "for event in app.stream({\"messages\": [(\"user\", \"Which sales agent made the most in sales in 2009?\")]}):\n", + "for event in app.stream(\n", + " {\"messages\": [(\"user\", \"Which sales agent made the most in sales in 2009?\")]}\n", + "):\n", " print(event)" ] } diff --git a/examples/usaco/usaco.ipynb b/examples/usaco/usaco.ipynb index aa9b55d70..f647abc3c 100644 --- a/examples/usaco/usaco.ipynb +++ b/examples/usaco/usaco.ipynb @@ -321,7 +321,7 @@ "source": [ "#### Node 1: Solver\n", "\n", - "Create a `solver` node that prompts an LLM \"agent\" to use a [writePython tool](https://python.langchain.com/docs/integrations/chat/anthropic/#beta-tool-calling) to generate the submitted code." + "Create a `solver` node that prompts an LLM \"agent\" to use a [writePython tool](https://python.langchain.com/v0.2/docs/integrations/chat/anthropic/#integration-details) to generate the submitted code." ] }, {