args_schema type hint on subclassing (#3323)

per https://github.com/hwchase17/langchain/issues/3297

Co-authored-by: Daniel Chalef <daniel.chalef@private.org>
This commit is contained in:
Daniel Chalef 2023-04-21 16:51:13 -06:00 committed by GitHub
parent 05a8aa5447
commit 61e09229c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,6 +191,8 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from typing import Type\n",
"\n",
"class CustomSearchTool(BaseTool):\n", "class CustomSearchTool(BaseTool):\n",
" name = \"Search\"\n", " name = \"Search\"\n",
" description = \"useful for when you need to answer questions about current events\"\n", " description = \"useful for when you need to answer questions about current events\"\n",
@ -206,7 +208,7 @@
"class CustomCalculatorTool(BaseTool):\n", "class CustomCalculatorTool(BaseTool):\n",
" name = \"Calculator\"\n", " name = \"Calculator\"\n",
" description = \"useful for when you need to answer questions about math\"\n", " description = \"useful for when you need to answer questions about math\"\n",
" args_schema=CalculatorInput\n", " args_schema: Type[BaseModel] = CalculatorInput\n",
"\n", "\n",
" def _run(self, query: str) -> str:\n", " def _run(self, query: str) -> str:\n",
" \"\"\"Use the tool.\"\"\"\n", " \"\"\"Use the tool.\"\"\"\n",