Skip to content

Commit

Permalink
rm serialize callback handler (#8172)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Aug 8, 2024
1 parent 5851701 commit a4eb88e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
29 changes: 0 additions & 29 deletions haystack/components/generators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a4eb88e

Please sign in to comment.