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

deepset-ai / haystack / 14384570060

10 Apr 2025 03:37PM UTC coverage: 90.388% (+0.02%) from 90.373%
14384570060

Pull #9213

github

web-flow
Merge e953558d2 into 45aa9608b
Pull Request #9213: feat: Minimal chat generator protocol

10683 of 11819 relevant lines covered (90.39%)

0.9 hits per line

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

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

5
from typing import Any, Dict, List, Protocol, TypeVar
1✔
6

7
from haystack.dataclasses import ChatMessage
1✔
8

9
# Ellipsis are needed to define the Protocol but pylint complains. See https://github.com/pylint-dev/pylint/issues/9319.
10
# pylint: disable=unnecessary-ellipsis
11

12
T = TypeVar("T", bound="ChatGenerator")
1✔
13

14

15
class ChatGenerator(Protocol):
1✔
16
    """
17
    Protocol for Chat Generators.
18

19
    This protocol defines the minimal interface that Chat Generators must implement.
20
    Chat Generators are components that process a list of `ChatMessage` objects as input and generate
21
    responses using a Language Model. They return a dictionary.
22
    """
23

24
    def run(self, messages: List[ChatMessage]) -> Dict[str, Any]:
1✔
25
        """
26
        Generate messages using the underlying Language Model.
27

28
        Implementing classes may accept additional optional parameters in their run method.
29
        For example: `def run (self, messages: List[ChatMessage], param_a="default", param_b="another_default")`.
30

31
        :param messages:
32
            A list of ChatMessage instances representing the input messages.
33
        :returns:
34
            A dictionary.
35
        """
36
        ...
×
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