• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

deepset-ai / haystack / 14739918096

29 Apr 2025 07:41PM UTC coverage: 90.477% (-0.03%) from 90.508%
14739918096

Pull #9290

github

web-flow
Merge 713fc016f into f8eead3ad
Pull Request #9290: feat: enable streaming ToolCall/Result from Agent

10907 of 12055 relevant lines covered (90.48%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.0
haystack/components/generators/utils.py
1
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
2
#
3
# SPDX-License-Identifier: Apache-2.0
4

5
from openai.types.chat.chat_completion_chunk import ChoiceDeltaToolCall
1✔
6

7
from haystack.dataclasses import StreamingChunk
1✔
8

9

10
def print_streaming_chunk(chunk: StreamingChunk) -> None:
1✔
11
    """
12
    Default callback function for streaming responses.
13

14
    Prints the tokens of the first completion to stdout as soon as they are received.
15
    Also prints the tool calls in the meta data of the chunk.
16
    """
17
    if chunk.meta.get("tool_calls"):
×
18
        for tool_call in chunk.meta["tool_calls"]:
×
19
            if isinstance(tool_call, ChoiceDeltaToolCall) and tool_call.function:
×
20
                # pick the name of the function, otherwise the arguments
21
                output = tool_call.function.name or tool_call.function.arguments
×
22
                if output:
×
23
                    print(output, flush=True, end="")
×
24

25
    print(chunk.content, flush=True, end="")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc