mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-06-26 22:00:13 +00:00
chore: remove deprecated deserialize tools inplace
function (#9379)
* rm deserialize_tools_inplace + clean up * release note
This commit is contained in:
parent
9f2c0679d4
commit
1541d93670
@ -6,7 +6,7 @@
|
||||
|
||||
# ruff: noqa: I001 (ignore import order as we need to import Tool before ComponentTool)
|
||||
from .from_function import create_tool_from_function, tool
|
||||
from .tool import Tool, _check_duplicate_tool_names, deserialize_tools_inplace
|
||||
from .tool import Tool, _check_duplicate_tool_names
|
||||
from .component_tool import ComponentTool
|
||||
from .serde_utils import deserialize_tools_or_toolset_inplace, serialize_tools_or_toolset
|
||||
from .toolset import Toolset
|
||||
@ -15,7 +15,6 @@ __all__ = [
|
||||
"_check_duplicate_tool_names",
|
||||
"ComponentTool",
|
||||
"create_tool_from_function",
|
||||
"deserialize_tools_inplace",
|
||||
"deserialize_tools_or_toolset_inplace",
|
||||
"serialize_tools_or_toolset",
|
||||
"Tool",
|
||||
|
@ -2,18 +2,16 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Union
|
||||
from typing import Any, Dict, List, Union
|
||||
|
||||
from haystack.core.errors import DeserializationError
|
||||
from haystack.core.serialization import import_class_by_name
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from haystack.tools.tool import Tool
|
||||
from haystack.tools.toolset import Toolset
|
||||
from haystack.tools.tool import Tool
|
||||
from haystack.tools.toolset import Toolset
|
||||
|
||||
|
||||
def serialize_tools_or_toolset(
|
||||
tools: Union["Toolset", List["Tool"], None],
|
||||
tools: Union[Toolset, List[Tool], None],
|
||||
) -> Union[Dict[str, Any], List[Dict[str, Any]], None]:
|
||||
"""
|
||||
Serialize a Toolset or a list of Tools to a dictionary or a list of tool dictionaries.
|
||||
@ -21,8 +19,6 @@ def serialize_tools_or_toolset(
|
||||
:param tools: A Toolset, a list of Tools, or None
|
||||
:returns: A dictionary, a list of tool dictionaries, or None if tools is None
|
||||
"""
|
||||
from haystack.tools.toolset import Toolset
|
||||
|
||||
if tools is None:
|
||||
return None
|
||||
if isinstance(tools, Toolset):
|
||||
@ -39,9 +35,6 @@ def deserialize_tools_or_toolset_inplace(data: Dict[str, Any], key: str = "tools
|
||||
:param key:
|
||||
The key in the dictionary where the list of Tools or Toolset is stored.
|
||||
"""
|
||||
from haystack.tools.tool import Tool
|
||||
from haystack.tools.toolset import Toolset
|
||||
|
||||
if key in data:
|
||||
serialized_tools = data[key]
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import warnings
|
||||
from dataclasses import asdict, dataclass
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
@ -11,7 +10,6 @@ from jsonschema.exceptions import SchemaError
|
||||
|
||||
from haystack.core.serialization import generate_qualified_class_name
|
||||
from haystack.tools.errors import ToolInvocationError
|
||||
from haystack.tools.serde_utils import deserialize_tools_or_toolset_inplace
|
||||
from haystack.utils import deserialize_callable, serialize_callable
|
||||
|
||||
|
||||
@ -175,22 +173,3 @@ def _check_duplicate_tool_names(tools: Optional[List[Tool]]) -> None:
|
||||
duplicate_tool_names = {name for name in tool_names if tool_names.count(name) > 1}
|
||||
if duplicate_tool_names:
|
||||
raise ValueError(f"Duplicate tool names found: {duplicate_tool_names}")
|
||||
|
||||
|
||||
def deserialize_tools_inplace(data: Dict[str, Any], key: str = "tools"):
|
||||
"""
|
||||
Deserialize a list of Tools or a Toolset in a dictionary inplace.
|
||||
|
||||
Deprecated in favor of `deserialize_tools_or_toolset_inplace`. It will be removed in Haystack 2.14.0.
|
||||
|
||||
:param data:
|
||||
The dictionary with the serialized data.
|
||||
:param key:
|
||||
The key in the dictionary where the list of Tools or Toolset is stored.
|
||||
"""
|
||||
warnings.warn(
|
||||
"`deserialize_tools_inplace` is deprecated and will be removed in Haystack 2.14.0. "
|
||||
"Use `deserialize_tools_or_toolset_inplace` instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
deserialize_tools_or_toolset_inplace(data, key)
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The deprecated `deserialize_tools_inplace` utility function has been removed.
|
||||
Use `deserialize_tools_or_toolset_inplace` instead, importing it as follows:
|
||||
`from haystack.tools import deserialize_tools_or_toolset_inplace`.
|
Loading…
x
Reference in New Issue
Block a user