From 4da2faba418ca82ceefd4295c5bf4ceff62d8d33 Mon Sep 17 00:00:00 2001 From: Junlin Zhou Date: Tue, 14 Nov 2023 01:03:56 +0800 Subject: [PATCH] docs: align custom_tool document headers (#13252) On the [Defining Custom Tools](https://python.langchain.com/docs/modules/agents/tools/custom_tools) page, there's a 'Subclassing the BaseTool class' paragraph under the 'Completely New Tools - String Input and Output' header. Also there's another 'Subclassing the BaseTool' paragraph under no header, which I think may belong to the 'Custom Structured Tools' header. Another thing is, there's a 'Using the tool decorator' and a 'Using the decorator' paragraph, I think should belong to 'Completely New Tools - String Input and Output' and 'Custom Structured Tools' separately. This PR moves those paragraphs to corresponding headers. --- docs/docs/modules/agents/tools/custom_tools.ipynb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/docs/modules/agents/tools/custom_tools.ipynb b/docs/docs/modules/agents/tools/custom_tools.ipynb index 086c1627056..a7b4fb3e5c4 100644 --- a/docs/docs/modules/agents/tools/custom_tools.ipynb +++ b/docs/docs/modules/agents/tools/custom_tools.ipynb @@ -29,7 +29,8 @@ "outputs": [], "source": [ "# Import things that are needed generically\n", - "from langchain.chains import LLMMathChain\nfrom langchain.utilities import SerpAPIWrapper\n", + "from langchain.chains import LLMMathChain\n", + "from langchain.utilities import SerpAPIWrapper\n", "from langchain.agents import AgentType, initialize_agent\n", "from langchain.chat_models import ChatOpenAI\n", "from langchain.tools import BaseTool, StructuredTool, Tool, tool" @@ -230,7 +231,7 @@ "id": "6f12eaf0", "metadata": {}, "source": [ - "### Subclassing the BaseTool class\n", + "### Subclassing the BaseTool\n", "\n", "You can also directly subclass `BaseTool`. This is useful if you want more control over the instance variables or if you want to propagate callbacks to nested chains or other tools." ] @@ -367,7 +368,7 @@ "id": "824eaf74", "metadata": {}, "source": [ - "## Using the `tool` decorator\n", + "### Using the decorator\n", "\n", "To make it easier to define custom tools, a `@tool` decorator is provided. This decorator can be used to quickly create a `Tool` from a simple function. The decorator uses the function name as the tool name by default, but this can be overridden by passing a string as the first argument. Additionally, the decorator will use the function's docstring as the tool's description." ] @@ -531,7 +532,7 @@ "id": "fb0a38eb", "metadata": {}, "source": [ - "## Subclassing the BaseTool\n", + "### Subclassing the BaseTool\n", "\n", "The BaseTool automatically infers the schema from the `_run` method's signature." ] @@ -624,7 +625,7 @@ "id": "7d68b0ac", "metadata": {}, "source": [ - "## Using the decorator\n", + "### Using the decorator\n", "\n", "The `tool` decorator creates a structured tool automatically if the signature has multiple arguments." ] @@ -774,7 +775,8 @@ "from langchain.agents import initialize_agent, Tool\n", "from langchain.agents import AgentType\n", "from langchain.llms import OpenAI\n", - "from langchain.chains import LLMMathChain\nfrom langchain.utilities import SerpAPIWrapper\n", + "from langchain.chains import LLMMathChain\n", + "from langchain.utilities import SerpAPIWrapper\n", "\n", "search = SerpAPIWrapper()\n", "tools = [\n",