langchain/libs
Neil Vachharajani eec35672a4
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>
2024-10-29 13:59:56 +00:00
..
cli multiple: update docs urls to latest 2 (#26837) 2024-09-30 17:37:07 -07:00
community community: Fix closed session in Infinity (#26933) 2024-10-27 11:37:21 -04:00
core core[patch]: Improve type checking for the tool decorator (#27460) 2024-10-29 13:59:56 +00:00
experimental experimental: migrate to external repo (#26879) 2024-09-25 19:02:19 -07:00
langchain all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00
partners partners/huggingface: release 0.1.1 (#27691) 2024-10-28 13:39:38 -07:00
standard-tests standard-tests: test that only one chunk sets input_tokens (#27177) 2024-10-08 11:35:32 -07:00
text-splitters all: test 3.13 ci (#27197) 2024-10-25 12:56:58 -07:00