diff --git a/haystack/components/generators/utils.py b/haystack/components/generators/utils.py index f9f9f2b690..4b31f0d06b 100644 --- a/haystack/components/generators/utils.py +++ b/haystack/components/generators/utils.py @@ -2,10 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -from typing import Callable, Optional - from haystack.dataclasses import StreamingChunk -from haystack.utils import deserialize_callable, serialize_callable def print_streaming_chunk(chunk: StreamingChunk) -> None: @@ -15,29 +12,3 @@ def print_streaming_chunk(chunk: StreamingChunk) -> None: Prints the tokens of the first completion to stdout as soon as they are received """ print(chunk.content, flush=True, end="") - - -def serialize_callback_handler(streaming_callback: Callable[[StreamingChunk], None]) -> str: - """ - Serializes the streaming callback handler. - - :param streaming_callback: - The streaming callback handler function - :returns: - The full path of the streaming callback handler function - """ - return serialize_callable(streaming_callback) - - -def deserialize_callback_handler(callback_name: str) -> Optional[Callable[[StreamingChunk], None]]: - """ - Deserializes the streaming callback handler. - - :param callback_name: - The full path of the streaming callback handler function - :returns: - The streaming callback handler function - :raises DeserializationError: - If the streaming callback handler function cannot be found - """ - return deserialize_callable(callback_name) diff --git a/releasenotes/notes/rm-serialize-callback-handler-5c104eafc6673932.yaml b/releasenotes/notes/rm-serialize-callback-handler-5c104eafc6673932.yaml new file mode 100644 index 0000000000..d830c014b8 --- /dev/null +++ b/releasenotes/notes/rm-serialize-callback-handler-5c104eafc6673932.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + The `serialize_callback_handler` and `deserialize_callback_handler` utility functions have been removed. + Use `serialize_callable` and `deserialize_callable` instead. + + For more information on `serialize_callable` and `deserialize_callable`, see the API reference: + https://docs.haystack.deepset.ai/reference/utils-api#module-callable_serialization