mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 15:03:21 +00:00
docs, standard-tests: property tags, support tool decorator (#28234)
This commit is contained in:
@@ -13,7 +13,7 @@ from langchain_tests.base import BaseStandardTests
|
||||
class ToolsTests(BaseStandardTests):
|
||||
@property
|
||||
@abstractmethod
|
||||
def tool_constructor(self) -> Union[Type[BaseTool], Callable]: ...
|
||||
def tool_constructor(self) -> Union[Type[BaseTool], Callable, BaseTool]: ...
|
||||
|
||||
@property
|
||||
def tool_constructor_params(self) -> dict:
|
||||
@@ -31,6 +31,14 @@ class ToolsTests(BaseStandardTests):
|
||||
|
||||
@pytest.fixture
|
||||
def tool(self) -> BaseTool:
|
||||
if isinstance(self.tool_constructor, BaseTool):
|
||||
if self.tool_constructor_params != {}:
|
||||
msg = (
|
||||
"If tool_constructor is an instance of BaseTool, "
|
||||
"tool_constructor_params must be empty"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
return self.tool_constructor
|
||||
return self.tool_constructor(**self.tool_constructor_params)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user