/ haystack / tools / __init__.py
__init__.py
 1  # SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
 2  #
 3  # SPDX-License-Identifier: Apache-2.0
 4  
 5  # NOTE: we do not use LazyImporter here because it creates conflicts between the tool module and the tool decorator
 6  
 7  # ruff: noqa: I001 (ignore import order as we need to import Tool before ComponentTool and PipelineTool)
 8  
 9  from haystack.tools.from_function import create_tool_from_function, tool
10  from haystack.tools.tool import Tool, _check_duplicate_tool_names
11  from haystack.tools.toolset import Toolset
12  from haystack.tools.searchable_toolset import SearchableToolset
13  from haystack.tools.component_tool import ComponentTool
14  from haystack.tools.pipeline_tool import PipelineTool
15  from haystack.tools.serde_utils import deserialize_tools_or_toolset_inplace, serialize_tools_or_toolset
16  from haystack.tools.utils import flatten_tools_or_toolsets, warm_up_tools
17  
18  # Type alias for tools parameter - allows mixing Tools and Toolsets in a list
19  # Explicitly list all valid combinations due to list invariance:
20  # - list[Tool]: Most common pattern - list of Tool objects
21  # - list[Toolset]: Less common pattern - list of Toolset objects
22  # - list[Union[Tool, Toolset]]: Mixing Tools and Toolsets in one list
23  # - Toolset: Single Toolset (not in a list)
24  ToolsType = list[Tool] | list[Toolset] | list[Tool | Toolset] | Toolset
25  
26  __all__ = [
27      "_check_duplicate_tool_names",
28      "ComponentTool",
29      "create_tool_from_function",
30      "deserialize_tools_or_toolset_inplace",
31      "flatten_tools_or_toolsets",
32      "PipelineTool",
33      "serialize_tools_or_toolset",
34      "Tool",
35      "SearchableToolset",
36      "ToolsType",
37      "Toolset",
38      "tool",
39      "warm_up_tools",
40  ]