WiseAgentEvent

TODO

Source code in wiseagents/wise_agent_messaging.py
18
19
20
21
class WiseAgentEvent:
    """
    TODO
    """

WiseAgentMessage

Bases: YAMLObject

A message that can be sent between agents.

Source code in wiseagents/wise_agent_messaging.py
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
61
62
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
94
95
class WiseAgentMessage(YAMLObject):
    ''' A message that can be sent between agents. '''
    yaml_tag = u'!wiseagents.WiseAgentMessage'
    def __init__(self, message: str, sender: Optional[str] = None, message_type: Optional[WiseAgentMessageType] = None, 
                 chat_id: Optional[str] = None, tool_id : Optional[str] = None, context_name: Optional[str] = None,
                 route_response_to: Optional[str] = None):
        '''Initialize the message.

        Args:
            message (str): the message contents (a natural language string)
            sender Optional(str): the sender of the message (or None if the sender was not specified)
            message_type Optional(WiseAgentMessageType): the type of the message (or None if the type was not specified)
            chat_id Optional(str): the id of the message
            tool_id Optional(str): the id of the tool
            context_name Optional(str): the context name of the message
            route_response_to Optional(str): the id of the tool to route the response to
            ''' 
        self._message = message
        self._sender = sender
        self._message_type = message_type
        self._chat_id = chat_id
        self._tool_id = tool_id
        self._route_response_to = route_response_to
        if context_name is not None:
            self._context_name = context_name
        else:
            self._context_name = 'default'

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}(message={self.message}, sender={self.sender}, message_type={self.message_type}, id={self.chat_id})"

    @property
    def context_name(self) -> str:
        """Get the context name of the message."""
        return self._context_name

    @property
    def message(self) -> str:
        """Get the message contents (a natural language string)."""
        return self._message

    @property
    def sender(self) -> str:
        """Get the sender of the message (or None if the sender was not specified)."""
        return self._sender
    @sender.setter
    def sender(self, sender: str):
        '''Set the sender of the message.

        Args:
            sender (str): the sender of the message
        '''
        self._sender = sender

    @property
    def message_type(self) -> WiseAgentMessageType:
        """Get the type of the message (or None if the type was not specified)."""
        return self._message_type
    @property
    def chat_id(self) -> str:
        """Get the id of the message."""
        return self._chat_id

    @property
    def tool_id(self) -> str:
        """Get the id of the tool."""
        return self._tool_id

    @property
    def route_response_to(self) -> str:
        """Get the id of the tool."""
        return self._route_response_to

chat_id: str property

Get the id of the message.

context_name: str property

Get the context name of the message.

message: str property

Get the message contents (a natural language string).

message_type: WiseAgentMessageType property

Get the type of the message (or None if the type was not specified).

route_response_to: str property

Get the id of the tool.

sender: str property writable

Get the sender of the message (or None if the sender was not specified).

tool_id: str property

Get the id of the tool.

__init__(message, sender=None, message_type=None, chat_id=None, tool_id=None, context_name=None, route_response_to=None)

Initialize the message.

Parameters:
  • message (str) –

    the message contents (a natural language string)

  • sender (Optional(str, default: None ) –

    the sender of the message (or None if the sender was not specified)

  • message_type (Optional(WiseAgentMessageType, default: None ) –

    the type of the message (or None if the type was not specified)

  • chat_id (Optional(str, default: None ) –

    the id of the message

  • tool_id (Optional(str, default: None ) –

    the id of the tool

  • context_name (Optional(str, default: None ) –

    the context name of the message

  • route_response_to (Optional(str, default: None ) –

    the id of the tool to route the response to

Source code in wiseagents/wise_agent_messaging.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def __init__(self, message: str, sender: Optional[str] = None, message_type: Optional[WiseAgentMessageType] = None, 
             chat_id: Optional[str] = None, tool_id : Optional[str] = None, context_name: Optional[str] = None,
             route_response_to: Optional[str] = None):
    '''Initialize the message.

    Args:
        message (str): the message contents (a natural language string)
        sender Optional(str): the sender of the message (or None if the sender was not specified)
        message_type Optional(WiseAgentMessageType): the type of the message (or None if the type was not specified)
        chat_id Optional(str): the id of the message
        tool_id Optional(str): the id of the tool
        context_name Optional(str): the context name of the message
        route_response_to Optional(str): the id of the tool to route the response to
        ''' 
    self._message = message
    self._sender = sender
    self._message_type = message_type
    self._chat_id = chat_id
    self._tool_id = tool_id
    self._route_response_to = route_response_to
    if context_name is not None:
        self._context_name = context_name
    else:
        self._context_name = 'default'

WiseAgentTransport

Bases: YAMLObject

A transport for sending messages between agents.

Source code in wiseagents/wise_agent_messaging.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class WiseAgentTransport(YAMLObject):
    ''' A transport for sending messages between agents. '''    
    def set_call_backs(self, request_receiver: Optional[Callable[[], WiseAgentMessage]] = None,
                 event_receiver: Optional[Callable[[], WiseAgentEvent]] = None,
                 error_receiver: Optional[Callable[[], WiseAgentMessage]] = None,
                 response_receiver: Optional[Callable[[], WiseAgentMessage]] = None):
        '''Set the call back functions for the transport.

        Args:
            request_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving requests
            event_receiver Optional(Callable[[], WiseAgentEvent]): the call back function for receiving events
            error_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving errors
            response_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving responses
        '''
        self._request_receiver = request_receiver
        self._event_receiver = event_receiver
        self._error_receiver = error_receiver
        self._response_receiver = response_receiver

    @abstractmethod
    def start(self):
        """
        Start the transport.
        """
        pass

    @abstractmethod
    def send_request(self, message: WiseAgentMessage, dest_agent_name: str):
        """
        Send a request message to an agent.


        Args:
            message (WiseAgentMessage): the message to send
        """
        pass

    @abstractmethod
    def send_response(self, message: WiseAgentMessage, dest_agent_name: str):
        """
        Send a request message to an agent.


        Args:
            message (WiseAgentMessage): the message to send
        """
        pass

    @abstractmethod
    def stop(self):
        """
        Stop the transport.
        """
        pass

    @property
    def request_receiver(self) -> Optional[Callable[[], WiseAgentMessage]]:
        """Get the message receiver callback."""
        return self._request_receiver

    @property
    def event_receiver(self) -> Optional[Callable[[], WiseAgentEvent]]:
        """Get the event receiver callback."""
        return self._event_receiver

    @property
    def error_receiver(self) -> Optional[Callable[[], WiseAgentMessage]]:
        """Get the error receiver callback."""
        return self._error_receiver

    @property
    def response_receiver(self) -> Optional[Callable[[], WiseAgentMessage]]:
        """Get the response receiver callback."""
        return self._response_receiver

error_receiver: Optional[Callable[[], WiseAgentMessage]] property

Get the error receiver callback.

event_receiver: Optional[Callable[[], WiseAgentEvent]] property

Get the event receiver callback.

request_receiver: Optional[Callable[[], WiseAgentMessage]] property

Get the message receiver callback.

response_receiver: Optional[Callable[[], WiseAgentMessage]] property

Get the response receiver callback.

send_request(message, dest_agent_name)

Send a request message to an agent.

Parameters:
Source code in wiseagents/wise_agent_messaging.py
123
124
125
126
127
128
129
130
131
132
@abstractmethod
def send_request(self, message: WiseAgentMessage, dest_agent_name: str):
    """
    Send a request message to an agent.


    Args:
        message (WiseAgentMessage): the message to send
    """
    pass

send_response(message, dest_agent_name)

Send a request message to an agent.

Parameters:
Source code in wiseagents/wise_agent_messaging.py
134
135
136
137
138
139
140
141
142
143
@abstractmethod
def send_response(self, message: WiseAgentMessage, dest_agent_name: str):
    """
    Send a request message to an agent.


    Args:
        message (WiseAgentMessage): the message to send
    """
    pass

set_call_backs(request_receiver=None, event_receiver=None, error_receiver=None, response_receiver=None)

Set the call back functions for the transport.

Parameters:
  • request_receiver (Optional(Callable[[], WiseAgentMessage], default: None ) –

    the call back function for receiving requests

  • event_receiver (Optional(Callable[[], WiseAgentEvent], default: None ) –

    the call back function for receiving events

  • error_receiver (Optional(Callable[[], WiseAgentMessage], default: None ) –

    the call back function for receiving errors

  • response_receiver (Optional(Callable[[], WiseAgentMessage], default: None ) –

    the call back function for receiving responses

Source code in wiseagents/wise_agent_messaging.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def set_call_backs(self, request_receiver: Optional[Callable[[], WiseAgentMessage]] = None,
             event_receiver: Optional[Callable[[], WiseAgentEvent]] = None,
             error_receiver: Optional[Callable[[], WiseAgentMessage]] = None,
             response_receiver: Optional[Callable[[], WiseAgentMessage]] = None):
    '''Set the call back functions for the transport.

    Args:
        request_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving requests
        event_receiver Optional(Callable[[], WiseAgentEvent]): the call back function for receiving events
        error_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving errors
        response_receiver Optional(Callable[[], WiseAgentMessage]): the call back function for receiving responses
    '''
    self._request_receiver = request_receiver
    self._event_receiver = event_receiver
    self._error_receiver = error_receiver
    self._response_receiver = response_receiver

start()

Start the transport.

Source code in wiseagents/wise_agent_messaging.py
116
117
118
119
120
121
@abstractmethod
def start(self):
    """
    Start the transport.
    """
    pass

stop()

Stop the transport.

Source code in wiseagents/wise_agent_messaging.py
145
146
147
148
149
150
@abstractmethod
def stop(self):
    """
    Stop the transport.
    """
    pass