Skip to content

events

Class info

Classes

Name Children Inherits
ChatMessage
llmling_agent.messaging.messages
Common message format for all UI types.
    ConnectionEventData
    llmling_agent.messaging.events
    Event from connection activity.
      EmailEventData
      llmling_agent.messaging.events
      Email event with specific content structure.
        EventData
        llmling_agent.messaging.events
        Base class for event data.
        EventSourceConfig
        llmling_agent.models.events
        Base configuration for event sources.
        FileEventData
        llmling_agent.messaging.events
        File system event.
          FunctionResultEventData
          llmling_agent.messaging.events
          Event from a function execution result.
            Talk
            llmling_agent.talk.talk
            Manages message flow between agents/groups.
              TimeEventData
              llmling_agent.messaging.events
              Time-based event.
                UIEventData
                llmling_agent.messaging.events
                Event triggered through UI interaction.
                  WebhookEventData
                  llmling_agent.messaging.events
                  Webhook payload with formatting.

                    🛈 DocStrings

                    Event sources for LLMling agent.

                    ConnectionEventData

                    Bases: EventData

                    Event from connection activity.

                    Source code in src/llmling_agent/messaging/events.py
                     96
                     97
                     98
                     99
                    100
                    101
                    102
                    103
                    104
                    105
                    106
                    107
                    108
                    109
                    110
                    111
                    112
                    113
                    114
                    115
                    116
                    class ConnectionEventData[TTransmittedData](EventData):
                        """Event from connection activity."""
                    
                        connection_name: str
                        """Name of the connection which fired an event."""
                    
                        connection: Talk[TTransmittedData]
                        """The connection which fired the event."""
                    
                        event_type: ConnectionEventType
                        """Type of event that occurred."""
                    
                        message: ChatMessage[TTransmittedData] | None = None
                        """The message at the stage of the event."""
                    
                        def to_prompt(self) -> str:
                            """Convert event to agent prompt."""
                            base = f"Connection '{self.connection_name}' event: {self.event_type}"
                            if self.message:
                                return f"{base}\nMessage content: {self.message.content}"
                            return base
                    

                    connection instance-attribute

                    connection: Talk[TTransmittedData]
                    

                    The connection which fired the event.

                    connection_name instance-attribute

                    connection_name: str
                    

                    Name of the connection which fired an event.

                    event_type instance-attribute

                    event_type: ConnectionEventType
                    

                    Type of event that occurred.

                    message class-attribute instance-attribute

                    message: ChatMessage[TTransmittedData] | None = None
                    

                    The message at the stage of the event.

                    to_prompt

                    to_prompt() -> str
                    

                    Convert event to agent prompt.

                    Source code in src/llmling_agent/messaging/events.py
                    111
                    112
                    113
                    114
                    115
                    116
                    def to_prompt(self) -> str:
                        """Convert event to agent prompt."""
                        base = f"Connection '{self.connection_name}' event: {self.event_type}"
                        if self.message:
                            return f"{base}\nMessage content: {self.message.content}"
                        return base
                    

                    EmailEventData

                    Bases: EventData

                    Email event with specific content structure.

                    Source code in src/llmling_agent/messaging/events.py
                    139
                    140
                    141
                    142
                    143
                    144
                    145
                    146
                    147
                    148
                    class EmailEventData(EventData):
                        """Email event with specific content structure."""
                    
                        subject: str
                        sender: str
                        body: str
                    
                        def to_prompt(self) -> str:
                            """Core email message."""
                            return f"Email from {self.sender} with subject: {self.subject}\n\n{self.body}"
                    

                    to_prompt

                    to_prompt() -> str
                    

                    Core email message.

                    Source code in src/llmling_agent/messaging/events.py
                    146
                    147
                    148
                    def to_prompt(self) -> str:
                        """Core email message."""
                        return f"Email from {self.sender} with subject: {self.subject}\n\n{self.body}"
                    

                    EventData

                    Bases: BaseModel

                    Base class for event data.

                    Source code in src/llmling_agent/messaging/events.py
                    23
                    24
                    25
                    26
                    27
                    28
                    29
                    30
                    31
                    32
                    33
                    34
                    35
                    36
                    37
                    38
                    39
                    40
                    41
                    42
                    43
                    44
                    45
                    46
                    47
                    48
                    49
                    50
                    51
                    52
                    53
                    54
                    55
                    56
                    57
                    58
                    59
                    60
                    class EventData(BaseModel):
                        """Base class for event data."""
                    
                        source: str
                        timestamp: datetime = Field(default_factory=datetime.now)
                        metadata: dict[str, Any] = Field(default_factory=dict)
                    
                        model_config = ConfigDict(
                            frozen=True,
                            use_attribute_docstrings=True,
                            extra="forbid",
                            arbitrary_types_allowed=True,
                        )
                    
                        @classmethod
                        def create(cls, source: str, **kwargs: Any) -> Self:
                            """Create event with current timestamp."""
                            return cls(source=source, timestamp=datetime.now(), **kwargs)
                    
                        @abstractmethod
                        def to_prompt(self) -> str:
                            """Convert event to agent prompt."""
                    
                        async def format(self, config: EventSourceConfig) -> str:
                            """Wraps core message with configurable template."""
                            from jinja2 import Environment
                    
                            env = Environment(trim_blocks=True, lstrip_blocks=True)
                            template = env.from_string(config.template)
                    
                            return template.render(
                                source=self.source,
                                content=self.to_prompt(),  # Use the core message
                                metadata=self.metadata,
                                timestamp=self.timestamp,
                                include_metadata=config.include_metadata,
                                include_timestamp=config.include_timestamp,
                            )
                    

                    create classmethod

                    create(source: str, **kwargs: Any) -> Self
                    

                    Create event with current timestamp.

                    Source code in src/llmling_agent/messaging/events.py
                    37
                    38
                    39
                    40
                    @classmethod
                    def create(cls, source: str, **kwargs: Any) -> Self:
                        """Create event with current timestamp."""
                        return cls(source=source, timestamp=datetime.now(), **kwargs)
                    

                    format async

                    format(config: EventSourceConfig) -> str
                    

                    Wraps core message with configurable template.

                    Source code in src/llmling_agent/messaging/events.py
                    46
                    47
                    48
                    49
                    50
                    51
                    52
                    53
                    54
                    55
                    56
                    57
                    58
                    59
                    60
                    async def format(self, config: EventSourceConfig) -> str:
                        """Wraps core message with configurable template."""
                        from jinja2 import Environment
                    
                        env = Environment(trim_blocks=True, lstrip_blocks=True)
                        template = env.from_string(config.template)
                    
                        return template.render(
                            source=self.source,
                            content=self.to_prompt(),  # Use the core message
                            metadata=self.metadata,
                            timestamp=self.timestamp,
                            include_metadata=config.include_metadata,
                            include_timestamp=config.include_timestamp,
                        )
                    

                    to_prompt abstractmethod

                    to_prompt() -> str
                    

                    Convert event to agent prompt.

                    Source code in src/llmling_agent/messaging/events.py
                    42
                    43
                    44
                    @abstractmethod
                    def to_prompt(self) -> str:
                        """Convert event to agent prompt."""
                    

                    FileEventData

                    Bases: EventData

                    File system event.

                    Source code in src/llmling_agent/messaging/events.py
                    119
                    120
                    121
                    122
                    123
                    124
                    125
                    126
                    class FileEventData(EventData):
                        """File system event."""
                    
                        path: str
                        type: ChangeType
                    
                        def to_prompt(self) -> str:
                            return f"File {self.type}: {self.path}"
                    

                    FunctionResultEventData

                    Bases: EventData

                    Event from a function execution result.

                    Source code in src/llmling_agent/messaging/events.py
                    129
                    130
                    131
                    132
                    133
                    134
                    135
                    136
                    class FunctionResultEventData(EventData):
                        """Event from a function execution result."""
                    
                        result: Any
                    
                        def to_prompt(self) -> str:
                            """Convert result to prompt format."""
                            return str(self.result)
                    

                    to_prompt

                    to_prompt() -> str
                    

                    Convert result to prompt format.

                    Source code in src/llmling_agent/messaging/events.py
                    134
                    135
                    136
                    def to_prompt(self) -> str:
                        """Convert result to prompt format."""
                        return str(self.result)
                    

                    TimeEventData

                    Bases: EventData

                    Time-based event.

                    Source code in src/llmling_agent/messaging/events.py
                    151
                    152
                    153
                    154
                    155
                    156
                    157
                    158
                    159
                    160
                    161
                    162
                    class TimeEventData(EventData):
                        """Time-based event."""
                    
                        schedule: str
                        """Cron expression that triggered this event."""
                    
                        prompt: str
                        """Cron expression that triggered this event."""
                    
                        def to_prompt(self) -> str:
                            """Format scheduled event."""
                            return f"Scheduled task triggered by {self.schedule}: {self.prompt}"
                    

                    prompt instance-attribute

                    prompt: str
                    

                    Cron expression that triggered this event.

                    schedule instance-attribute

                    schedule: str
                    

                    Cron expression that triggered this event.

                    to_prompt

                    to_prompt() -> str
                    

                    Format scheduled event.

                    Source code in src/llmling_agent/messaging/events.py
                    160
                    161
                    162
                    def to_prompt(self) -> str:
                        """Format scheduled event."""
                        return f"Scheduled task triggered by {self.schedule}: {self.prompt}"
                    

                    UIEventData

                    Bases: EventData

                    Event triggered through UI interaction.

                    Source code in src/llmling_agent/messaging/events.py
                    63
                    64
                    65
                    66
                    67
                    68
                    69
                    70
                    71
                    72
                    73
                    74
                    75
                    76
                    77
                    78
                    79
                    80
                    81
                    82
                    83
                    84
                    85
                    86
                    87
                    88
                    89
                    90
                    91
                    92
                    93
                    class UIEventData(EventData):
                        """Event triggered through UI interaction."""
                    
                        type: Literal["command", "message", "agent_command", "agent_message"]
                        """Type of UI interaction that triggered this event."""
                    
                        content: str
                        """The actual content (command string, voice command, etc.)."""
                    
                        args: list[str] = Field(default_factory=list)
                        """Additional arguments for the interaction."""
                    
                        kwargs: dict[str, Any] = Field(default_factory=dict)
                        """Additional options/parameters."""
                    
                        agent_name: str | None = None
                        """Target agent for @agent messages/commands."""
                    
                        def to_prompt(self) -> str:
                            """Convert event to agent prompt."""
                            match self.type:
                                case "command":
                                    args_str = " ".join(self.args)
                                    kwargs_str = " ".join(f"--{k}={v}" for k, v in self.kwargs.items())
                                    return f"UI Command: /{self.content} {args_str} {kwargs_str}"
                                case "shortcut" | "gesture":
                                    return f"UI Action: {self.content}"
                                case "voice":
                                    return f"Voice Command: {self.content}"
                                case _:
                                    raise ValueError(self.type)
                    

                    agent_name class-attribute instance-attribute

                    agent_name: str | None = None
                    

                    Target agent for @agent messages/commands.

                    args class-attribute instance-attribute

                    args: list[str] = Field(default_factory=list)
                    

                    Additional arguments for the interaction.

                    content instance-attribute

                    content: str
                    

                    The actual content (command string, voice command, etc.).

                    kwargs class-attribute instance-attribute

                    kwargs: dict[str, Any] = Field(default_factory=dict)
                    

                    Additional options/parameters.

                    type instance-attribute

                    type: Literal['command', 'message', 'agent_command', 'agent_message']
                    

                    Type of UI interaction that triggered this event.

                    to_prompt

                    to_prompt() -> str
                    

                    Convert event to agent prompt.

                    Source code in src/llmling_agent/messaging/events.py
                    81
                    82
                    83
                    84
                    85
                    86
                    87
                    88
                    89
                    90
                    91
                    92
                    93
                    def to_prompt(self) -> str:
                        """Convert event to agent prompt."""
                        match self.type:
                            case "command":
                                args_str = " ".join(self.args)
                                kwargs_str = " ".join(f"--{k}={v}" for k, v in self.kwargs.items())
                                return f"UI Command: /{self.content} {args_str} {kwargs_str}"
                            case "shortcut" | "gesture":
                                return f"UI Action: {self.content}"
                            case "voice":
                                return f"Voice Command: {self.content}"
                            case _:
                                raise ValueError(self.type)
                    

                    WebhookEventData

                    Bases: EventData

                    Webhook payload with formatting.

                    Source code in src/llmling_agent/messaging/events.py
                    165
                    166
                    167
                    168
                    169
                    170
                    171
                    172
                    class WebhookEventData(EventData):
                        """Webhook payload with formatting."""
                    
                        payload: dict[str, Any]
                    
                        def to_prompt(self) -> str:
                            """Format webhook payload."""
                            return f"Webhook received:\n{json.dumps(self.payload, indent=2)}"
                    

                    to_prompt

                    to_prompt() -> str
                    

                    Format webhook payload.

                    Source code in src/llmling_agent/messaging/events.py
                    170
                    171
                    172
                    def to_prompt(self) -> str:
                        """Format webhook payload."""
                        return f"Webhook received:\n{json.dumps(self.payload, indent=2)}"