langchain
eec35672 - core[patch]: Improve type checking for the tool decorator (#27460)

Commit
1 year ago
core[patch]: Improve type checking for the tool decorator (#27460) **Description:** When annotating a function with the @tool decorator, the symbol should have type BaseTool. The previous type annotations did not convey that to type checkers. This patch creates 4 overloads for the tool function for the 4 different use cases. 1. @tool decorator with no arguments 2. @tool decorator with only keyword arguments 3. @tool decorator with a name argument (and possibly keyword arguments) 4. Invoking tool as function with a name and runnable positional arguments The main function is updated to match the overloads. The changes are 100% backwards compatible (all existing calls should continue to work, just with better type annotations). **Twitter handle:** @nvachhar --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Author
Parents
Loading