Skip to content

Commit 11925b6

Browse files
anakin87Amnah199
authored andcommitted
fix: fix print_streaming_chunk + add tests (#9579)
* fix: fix print_streaming_chunk + add tests * rel note
1 parent fedce76 commit 11925b6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

haystack/components/generators/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def print_streaming_chunk(chunk: StreamingChunk) -> None:
4444
if chunk.index and tool_call.index > chunk.index:
4545
print("\n\n", flush=True, end="")
4646

47-
print("[TOOL CALL]\nTool: {tool_call.tool_name} \nArguments: ", flush=True, end="")
47+
print(f"[TOOL CALL]\nTool: {tool_call.tool_name} \nArguments: ", flush=True, end="")
4848

4949
# print the tool arguments
5050
if tool_call.arguments:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
fixes:
3+
- Fixed a bug in the `print_streaming_chunk` utility function that prevented tool call name from being printed.

test/components/generators/test_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
from openai.types.chat import chat_completion_chunk
6+
from unittest.mock import patch, call
67

7-
from haystack.components.generators.utils import _convert_streaming_chunks_to_chat_message
8-
from haystack.dataclasses import ComponentInfo, StreamingChunk, ToolCallDelta
8+
from haystack.components.generators.utils import _convert_streaming_chunks_to_chat_message, print_streaming_chunk
9+
from haystack.dataclasses import ComponentInfo, StreamingChunk, ToolCall, ToolCallDelta, ToolCallResult
910

1011

1112
def test_convert_streaming_chunks_to_chat_message_tool_calls_in_any_chunk():

0 commit comments

Comments
 (0)