Skip to content

Messages schemas

MediaMessage

Bases: Message

A single media message.

Source code in light_agents/schemas/messages_schemas.py
83
84
85
86
class MediaMessage(Message):
    """A single media message."""

    media_url: str

Message

Bases: MessageBase

A single message.

Attributes

content: the content of the message to be passed to the LLM
timestamp: the timestamp of message creation
Source code in light_agents/schemas/messages_schemas.py
48
49
50
51
52
53
54
55
56
57
58
59
60
class Message(MessageBase):
    """A single message.

    Attributes
    ----------
        content: the content of the message to be passed to the LLM
        timestamp: the timestamp of message creation

    """

    model_config = model_config
    content: str
    timestamp: Optional[datetime] = datetime.now(timezone.utc)

MessageBase

Bases: BaseModel

A single message.

Source code in light_agents/schemas/messages_schemas.py
38
39
40
41
42
43
44
45
class MessageBase(BaseModel):
    """A single message."""

    model_config = model_config
    role: MessageRole
    type: MessageType
    external_fields: dict[str, Any] = {}
    """Fields to be returned for the thread outside LLM."""

external_fields: dict[str, Any] = {} class-attribute instance-attribute

Fields to be returned for the thread outside LLM.

MessageRole

Bases: str, Enum

Possible roles for a single message.

Source code in light_agents/schemas/messages_schemas.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class MessageRole(str, Enum):
    """Possible roles for a single message."""

    USER = "user"
    SYSTEM = "system"
    AI = "ai"
    TOOL_USE = "tool_use"

    @staticmethod
    def get_roles_mapping() -> dict[str, str]:
        """Get the role mapping."""
        return {
            MessageRole.USER.value: "user",
            MessageRole.SYSTEM.value: "system",
            MessageRole.AI.value: "ai",
        }

get_roles_mapping() staticmethod

Get the role mapping.

Source code in light_agents/schemas/messages_schemas.py
18
19
20
21
22
23
24
25
@staticmethod
def get_roles_mapping() -> dict[str, str]:
    """Get the role mapping."""
    return {
        MessageRole.USER.value: "user",
        MessageRole.SYSTEM.value: "system",
        MessageRole.AI.value: "ai",
    }

MessageType

Bases: str, Enum

Possible types for a single message.

Source code in light_agents/schemas/messages_schemas.py
28
29
30
31
32
33
34
35
class MessageType(str, Enum):
    """Possible types for a single message."""

    TEXT = "text"
    IMAGE = "image"
    VIDEO = "video"
    AUDIO = "audio"
    FILE = "file"

ToolUseMessage

Bases: MessageBase

Message for a LLM function calling.

Attributes

run_id: the run id of the tool
name: the name of the tool
input_params_dict: the input parameters of the tool
tool_outputs: the output of the tool
is_error: flag to indicate if the tool execution was an error
Source code in light_agents/schemas/messages_schemas.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class ToolUseMessage(MessageBase):
    """Message for a LLM function calling.

    Attributes
    ----------
        run_id: the run id of the tool
        name: the name of the tool
        input_params_dict: the input parameters of the tool
        tool_outputs: the output of the tool
        is_error: flag to indicate if the tool execution was an error

    """

    run_id: str
    name: str
    input_params_dict: Union[str, dict[str, Any]]
    tool_outputs: Optional[Any] = None
    is_error: Optional[bool] = False