Skip to content

State

graphorchestrator.core.state

State dataclass

Represents the state of a process or workflow, maintaining a list of messages.

Attributes:

Name Type Description
messages List[Any]

A list to store messages related to the state.

Source code in graphorchestrator\core\state.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@dataclass
class State:
    """
    Represents the state of a process or workflow, maintaining a list of messages.

    Attributes:
        messages (List[Any]): A list to store messages related to the state.
    """

    messages: List[Any] = field(default_factory=list)

    def __repr__(self) -> str:
        """
        Provides a string representation of the State object.

        Returns:
            str: A string representation of the State, including its messages.
        """
        return f"State({self.messages})"

    def __eq__(self, other: Any) -> bool:
        """
        Checks if the current State object is equal to another object.

        Args:
            other (Any): The object to compare with.

        Returns:
            bool: True if the objects are equal, False otherwise.
        """
        if not isinstance(other, State):
            return NotImplemented
        return self.messages == other.messages

__eq__(other)

Checks if the current State object is equal to another object.

Parameters:

Name Type Description Default
other Any

The object to compare with.

required

Returns:

Name Type Description
bool bool

True if the objects are equal, False otherwise.

Source code in graphorchestrator\core\state.py
25
26
27
28
29
30
31
32
33
34
35
36
37
def __eq__(self, other: Any) -> bool:
    """
    Checks if the current State object is equal to another object.

    Args:
        other (Any): The object to compare with.

    Returns:
        bool: True if the objects are equal, False otherwise.
    """
    if not isinstance(other, State):
        return NotImplemented
    return self.messages == other.messages

__repr__()

Provides a string representation of the State object.

Returns:

Name Type Description
str str

A string representation of the State, including its messages.

Source code in graphorchestrator\core\state.py
16
17
18
19
20
21
22
23
def __repr__(self) -> str:
    """
    Provides a string representation of the State object.

    Returns:
        str: A string representation of the State, including its messages.
    """
    return f"State({self.messages})"