Skip to content

Class swarmauri_core.conversations.IConversation.IConversation

swarmauri_core.conversations.IConversation.IConversation

Bases: ABC

Interface for managing conversations, defining abstract methods for adding messages, retrieving the latest message, getting all messages, and clearing history.

history property

history

Provides read-only access to the conversation history.

add_message abstractmethod

add_message(message)

Adds a message to the conversation history.

Source code in swarmauri_core/conversations/IConversation.py
19
20
21
22
23
24
@abstractmethod
def add_message(self, message: IMessage):
    """
    Adds a message to the conversation history.
    """
    pass

add_messages abstractmethod

add_messages(messages)

Adds multiple messages to the conversation history.

Source code in swarmauri_core/conversations/IConversation.py
26
27
28
29
30
31
@abstractmethod
def add_messages(self, messages: List[IMessage]):
    """
    Adds multiple messages to the conversation history.
    """
    pass

get_last abstractmethod

get_last()

Retrieves the latest message from the conversation history.

Source code in swarmauri_core/conversations/IConversation.py
33
34
35
36
37
38
@abstractmethod
def get_last(self) -> Optional[IMessage]:
    """
    Retrieves the latest message from the conversation history.
    """
    pass

clear_history abstractmethod

clear_history()

Clears the conversation history.

Source code in swarmauri_core/conversations/IConversation.py
40
41
42
43
44
45
@abstractmethod
def clear_history(self) -> None:
    """
    Clears the conversation history.
    """
    pass