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

deepset-ai / haystack / 13997715518

21 Mar 2025 05:35PM UTC coverage: 90.016% (+0.3%) from 89.69%
13997715518

Pull #9092

github

web-flow
Merge 6753ce930 into 1c1030efc
Pull Request #9092: docs: fixing docstrings

9827 of 10917 relevant lines covered (90.02%)

0.9 hits per line

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

0.0
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
×
6

7
from haystack.dataclasses import ChatMessage
×
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")
×
13

14

15
class ChatGenerator(Protocol):
×
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 to_dict(self) -> Dict[str, Any]:
×
25
        """
26
        Serialize this ChatGenerator to a dictionary.
27

28
        :returns:
29
            The serialized ChatGenerator as a dictionary.
30
        """
31
        ...
×
32

33
    @classmethod
×
34
    def from_dict(cls: type[T], data: Dict[str, Any]) -> T:
×
35
        """
36
        Deserialize this ChatGenerator from a dictionary.
37

38
        :param data: The dictionary representation of this ChatGenerator.
39
        :returns:
40
            An instance of the specific implementing class.
41
        """
42
        ...
×
43

44
    def run(self, messages: List[ChatMessage]) -> Dict[str, Any]:
×
45
        """
46
        Generate messages using the underlying Language Model.
47

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

51
        :param messages:
52
            A list of ChatMessage instances representing the input messages.
53
        :returns:
54
            A dictionary.
55
        """
56
        ...
×
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

© 2025 Coveralls, Inc