pbesa 2.1__py3-none-any.whl → 4.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pbesa/__init__.py +4 -3
- pbesa/cognitive.py +475 -0
- pbesa/kernel/__init__.py +4 -6
- pbesa/kernel/adapter.py +165 -0
- pbesa/kernel/agent.py +558 -0
- pbesa/kernel/io/__init__.py +2 -2
- pbesa/kernel/io/system_file.py +38 -0
- pbesa/kernel/io/tcp_server.py +23 -0
- pbesa/kernel/util.py +217 -0
- pbesa/kernel/world.py +43 -0
- pbesa/mas.py +565 -0
- pbesa/remote/__init__.py +5 -0
- pbesa/remote/adm_listener.py +44 -0
- pbesa/{middleware/remote/AdmListenerHandler.py → remote/adm_listener_handler.py} +74 -57
- pbesa/remote/exceptions.py +18 -0
- pbesa/remote/remote_adm.py +42 -0
- pbesa/{middleware/remote/RemoteAdmHandler.py → remote/remote_adm_handler.py} +109 -83
- pbesa/social/__init__.py +4 -0
- pbesa/social/collaborative_team.py +299 -0
- pbesa/social/delegator.py +81 -0
- pbesa/social/delegator_team.py +334 -0
- pbesa/social/dialog.py +153 -0
- pbesa/social/dispatcher_team.py +319 -0
- pbesa/social/templates.py +18 -0
- pbesa/social/worker.py +188 -0
- {pbesa-2.1.dist-info → pbesa-4.0.0.dist-info}/LICENSE +21 -21
- {pbesa-2.1.dist-info → pbesa-4.0.0.dist-info}/LICENSE.txt +21 -21
- pbesa-4.0.0.dist-info/METADATA +8 -0
- pbesa-4.0.0.dist-info/RECORD +32 -0
- {pbesa-2.1.dist-info → pbesa-4.0.0.dist-info}/WHEEL +5 -5
- {pbesa-2.1.dist-info → pbesa-4.0.0.dist-info}/top_level.txt +0 -0
- pbesa/engine/__init__.py +0 -2
- pbesa/engine/bdi/BDIAg.py +0 -42
- pbesa/engine/bdi/BDILevel.py +0 -10
- pbesa/engine/bdi/BDIMachine.py +0 -116
- pbesa/engine/bdi/Goal.py +0 -28
- pbesa/engine/bdi/GoalExe.py +0 -36
- pbesa/engine/bdi/__init__.py +0 -5
- pbesa/engine/rational/ActionExe.py +0 -35
- pbesa/engine/rational/Brain.py +0 -10
- pbesa/engine/rational/RationalAg.py +0 -43
- pbesa/engine/rational/__init__.py +0 -3
- pbesa/kernel/adapter/Adapter.py +0 -26
- pbesa/kernel/adapter/FileAdapter.py +0 -23
- pbesa/kernel/adapter/__init__.py +0 -2
- pbesa/kernel/agent/Action.py +0 -19
- pbesa/kernel/agent/Agent.py +0 -91
- pbesa/kernel/agent/BehaviorExe.py +0 -33
- pbesa/kernel/agent/Channel.py +0 -10
- pbesa/kernel/agent/World.py +0 -15
- pbesa/kernel/agent/__init__.py +0 -5
- pbesa/kernel/io/SystemFile.py +0 -13
- pbesa/kernel/io/TCPServer.py +0 -4
- pbesa/kernel/system/Adm.py +0 -189
- pbesa/kernel/system/Directory.py +0 -36
- pbesa/kernel/system/__init__.py +0 -2
- pbesa/kernel/util/HashTable.py +0 -62
- pbesa/kernel/util/Queue.py +0 -231
- pbesa/kernel/util/__init__.py +0 -2
- pbesa/middleware/__init__.py +0 -3
- pbesa/middleware/adapter/GameAdapter.py +0 -64
- pbesa/middleware/adapter/MongoAdapter.py +0 -47
- pbesa/middleware/adapter/RESTAdapter.py +0 -52
- pbesa/middleware/adapter/SubProcessAdapter.py +0 -30
- pbesa/middleware/adapter/WSSAdapter.py +0 -89
- pbesa/middleware/adapter/WSSNJAdapter.py +0 -51
- pbesa/middleware/adapter/WSSNJHandler.py +0 -23
- pbesa/middleware/adapter/__init__.py +0 -7
- pbesa/middleware/remote/AdmListener.py +0 -17
- pbesa/middleware/remote/RemoteAdm.py +0 -17
- pbesa/middleware/remote/__init__.py +0 -4
- pbesa/middleware/web/WebAgTK.py +0 -15
- pbesa/middleware/web/__init__.py +0 -0
- pbesa-2.1.dist-info/METADATA +0 -25
- pbesa-2.1.dist-info/RECORD +0 -54
@@ -0,0 +1,319 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
----------------------------------------------------------
|
4
|
+
-------------------------- PBESA -------------------------
|
5
|
+
----------------------------------------------------------
|
6
|
+
|
7
|
+
@autor AKEN
|
8
|
+
@version 4.0.0
|
9
|
+
@date 09/08/24
|
10
|
+
|
11
|
+
The Dispatcher Team is a group of artificial intelligence
|
12
|
+
agents coordinated by a controller that acts as a task
|
13
|
+
dispatcher. Unlike teams that consolidate responses,
|
14
|
+
in this system, the controller simply assigns the task to
|
15
|
+
the first available agent. Each agent operates
|
16
|
+
independently and responds through Controller to the
|
17
|
+
client once they have processed the assigned task.
|
18
|
+
|
19
|
+
When the client sends a request, the controller directs
|
20
|
+
it to the agent who is free at that moment. If all agents
|
21
|
+
are busy, the request is put on hold until one of them
|
22
|
+
becomes available to handle it. This approach ensures
|
23
|
+
quick and efficient responses, optimizing the use of
|
24
|
+
available resources.
|
25
|
+
|
26
|
+
The Dispatcher Team is ideal for scenarios where fast and
|
27
|
+
direct responses are crucial, as it minimizes wait times
|
28
|
+
and simplifies task management, allowing the team to
|
29
|
+
operate in an agile and effective manner.
|
30
|
+
"""
|
31
|
+
|
32
|
+
# --------------------------------------------------------
|
33
|
+
# Define resources
|
34
|
+
# --------------------------------------------------------
|
35
|
+
|
36
|
+
from abc import abstractmethod
|
37
|
+
|
38
|
+
from .worker import Task, Worker
|
39
|
+
from ..kernel.agent import Queue
|
40
|
+
from ..kernel.agent import Agent
|
41
|
+
from ..kernel.agent import Action
|
42
|
+
from ..kernel.util import generate_short_uuid
|
43
|
+
|
44
|
+
# ----------------------------------------------------------
|
45
|
+
# Defines system component exceptions
|
46
|
+
# ----------------------------------------------------------
|
47
|
+
|
48
|
+
class DispatcherException(Exception):
|
49
|
+
""" Base class for exceptions of agent """
|
50
|
+
pass
|
51
|
+
|
52
|
+
# --------------------------------------------------------
|
53
|
+
# Define Delegate Action
|
54
|
+
# --------------------------------------------------------
|
55
|
+
|
56
|
+
class Delegate(Action):
|
57
|
+
""" An action is a response to the occurrence of an event """
|
58
|
+
|
59
|
+
def execute(self, data: any) -> None:
|
60
|
+
"""
|
61
|
+
Response.
|
62
|
+
@param data Event data
|
63
|
+
"""
|
64
|
+
ag = self.agent.get_free_queue().get()
|
65
|
+
self.agent.get_request_dict()[ag] = {
|
66
|
+
'gateway': data['gateway'],
|
67
|
+
'dtoList': []
|
68
|
+
}
|
69
|
+
self.adm.send_event(ag, 'task', data['dto'])
|
70
|
+
|
71
|
+
# --------------------------------------------------------
|
72
|
+
# Define DelegateAction
|
73
|
+
# --------------------------------------------------------
|
74
|
+
|
75
|
+
class DelegateAction(Action):
|
76
|
+
""" An action is a response to the occurrence of an event """
|
77
|
+
|
78
|
+
def execute(self, data: any) -> None:
|
79
|
+
"""
|
80
|
+
Response.
|
81
|
+
@param data Event data
|
82
|
+
"""
|
83
|
+
self.delegate(data)
|
84
|
+
|
85
|
+
def active_timeout(self, time: int) -> None:
|
86
|
+
""" Active timeout
|
87
|
+
@param time: Time
|
88
|
+
"""
|
89
|
+
self.adm.send_event(self.agent.id, 'timeout', {'time': time, 'dto': None})
|
90
|
+
|
91
|
+
def to_assign(self, data: any) -> None:
|
92
|
+
""" Assign
|
93
|
+
@param data: Data
|
94
|
+
"""
|
95
|
+
ag = self.agent.get_free_queue().get()
|
96
|
+
self.agent.get_request_dict()[ag] = {
|
97
|
+
'dtoList': []
|
98
|
+
}
|
99
|
+
self.adm.send_event(ag, 'task', data)
|
100
|
+
|
101
|
+
@abstractmethod
|
102
|
+
def delegate(self, data: any) -> None:
|
103
|
+
""" Delegate
|
104
|
+
@param data: Data
|
105
|
+
"""
|
106
|
+
pass
|
107
|
+
|
108
|
+
# --------------------------------------------------------
|
109
|
+
# Define Action
|
110
|
+
# --------------------------------------------------------
|
111
|
+
|
112
|
+
class NotifyFreeAction(Action):
|
113
|
+
""" An action is a response to the occurrence of an event """
|
114
|
+
|
115
|
+
def execute(self, data: any) -> None:
|
116
|
+
"""
|
117
|
+
Response.
|
118
|
+
@param data Event data
|
119
|
+
"""
|
120
|
+
self.agent.get_free_queue().put(data)
|
121
|
+
|
122
|
+
# --------------------------------------------------------
|
123
|
+
# Define Action
|
124
|
+
# --------------------------------------------------------
|
125
|
+
|
126
|
+
class ResponseAction(Action):
|
127
|
+
""" An action is a response to the occurrence of an event """
|
128
|
+
|
129
|
+
def send_response(self, request: dict) -> None:
|
130
|
+
""" Send response
|
131
|
+
@param request: Request
|
132
|
+
"""
|
133
|
+
if len(request['dtoList']) == 1:
|
134
|
+
request['gateway'].put(request['dtoList'][0])
|
135
|
+
else:
|
136
|
+
request['gateway'].put(request['dtoList'])
|
137
|
+
|
138
|
+
def execute(self, data: dict) -> None:
|
139
|
+
""" Execute
|
140
|
+
@param data: Data
|
141
|
+
"""
|
142
|
+
request = self.agent.get_request_dict()[data['source']]
|
143
|
+
if 'timeout' in data:
|
144
|
+
self.send_response(request)
|
145
|
+
else:
|
146
|
+
request['dtoList'].append(data['result'])
|
147
|
+
if len(request['dtoList']) >= self.agent.get_buffer_size():
|
148
|
+
self.send_response(request)
|
149
|
+
|
150
|
+
# --------------------------------------------------------
|
151
|
+
# Define component
|
152
|
+
# --------------------------------------------------------
|
153
|
+
|
154
|
+
class DispatcherController(Agent):
|
155
|
+
""" Represents the agent that delegates the execution of actions to other agents """
|
156
|
+
|
157
|
+
def __init__(self, agent_id:str, buffer_size:int, pool_size:int) -> None:
|
158
|
+
""" Constructor
|
159
|
+
@param agent_id: Agent ID
|
160
|
+
@param type: Pool type
|
161
|
+
@param buffer_size: Buffer size
|
162
|
+
@param pool_size: Pool size
|
163
|
+
"""
|
164
|
+
self.__buffer_size = buffer_size
|
165
|
+
self.__request_dict = {}
|
166
|
+
self.__free_queue = Queue(pool_size)
|
167
|
+
self.__agent_list = []
|
168
|
+
super().__init__(agent_id)
|
169
|
+
|
170
|
+
def setup(self) -> None:
|
171
|
+
""" Set up method """
|
172
|
+
self._social = True
|
173
|
+
self.add_behavior('Delegate')
|
174
|
+
self.bind_action('Delegate', 'delegate', Delegate())
|
175
|
+
self.add_behavior('Notify')
|
176
|
+
self.bind_action('Notify', 'notify', NotifyFreeAction())
|
177
|
+
self.add_behavior('Response')
|
178
|
+
self.bind_action('Response', 'response', ResponseAction())
|
179
|
+
self.build()
|
180
|
+
|
181
|
+
def suscribe_agent(self, agent:Agent) -> None:
|
182
|
+
""" Suscribes an agent to the controller
|
183
|
+
@param agent: Agent
|
184
|
+
"""
|
185
|
+
self.__agent_list.append(agent.id)
|
186
|
+
agent.set_controller(self.id)
|
187
|
+
agent.set_controller_type('POOL')
|
188
|
+
self.__free_queue.put(agent.id)
|
189
|
+
actions = agent.get_actions()
|
190
|
+
for action in actions:
|
191
|
+
action.set_is_pool(True)
|
192
|
+
action.set_enable_response(True)
|
193
|
+
|
194
|
+
def suscribe_remote_agent(self, agent_id:str) -> None:
|
195
|
+
""" Suscribes an agent to the controller
|
196
|
+
@param agent_id: Agent ID
|
197
|
+
"""
|
198
|
+
if not isinstance(agent_id, str):
|
199
|
+
raise DispatcherException('[Warn, suscribeRemoteAgent]: The object to subscribe is not an agent ID')
|
200
|
+
self.__agent_list.append(agent_id)
|
201
|
+
self.__free_queue.put(agent_id)
|
202
|
+
|
203
|
+
def broadcast_event(self, event:any, data:any) -> None:
|
204
|
+
""" Broadcasts an event to the agents
|
205
|
+
@param event: Event
|
206
|
+
@param data: Data
|
207
|
+
"""
|
208
|
+
from pbesa.kernel.system.adm import Adm
|
209
|
+
for agent_id in self.__agent_list:
|
210
|
+
Adm().send_event(agent_id, event, data)
|
211
|
+
|
212
|
+
@abstractmethod
|
213
|
+
def build(self) -> None:
|
214
|
+
""" Builds the agent """
|
215
|
+
pass
|
216
|
+
|
217
|
+
def get_free_queue(self) -> Queue:
|
218
|
+
""" Gets the free queue
|
219
|
+
@return: Free queue
|
220
|
+
"""
|
221
|
+
return self.__free_queue
|
222
|
+
|
223
|
+
def get_request_dict(self) -> dict:
|
224
|
+
""" Gets the request dictionary
|
225
|
+
@return: Request dictionary
|
226
|
+
"""
|
227
|
+
return self.__request_dict
|
228
|
+
|
229
|
+
def get_buffer_size(self) -> int:
|
230
|
+
""" Gets the buffer size
|
231
|
+
@return: Buffer size
|
232
|
+
"""
|
233
|
+
return self.__buffer_size
|
234
|
+
|
235
|
+
def is_block(self) -> bool:
|
236
|
+
""" Checks if the pool is blocking
|
237
|
+
@return: True if the pool is blocking, False otherwise
|
238
|
+
"""
|
239
|
+
return True
|
240
|
+
|
241
|
+
|
242
|
+
# --------------------------------------------------------
|
243
|
+
# Builder Methods
|
244
|
+
# --------------------------------------------------------
|
245
|
+
|
246
|
+
# --------------------------------------------------------
|
247
|
+
# Define Dispacher Agent
|
248
|
+
|
249
|
+
class DispacherAgent(DispatcherController):
|
250
|
+
""" Through a class the concept of agent is defined """
|
251
|
+
|
252
|
+
def build(self):
|
253
|
+
"""
|
254
|
+
Method that allows defining the structure and
|
255
|
+
resources of the agent
|
256
|
+
"""
|
257
|
+
pass
|
258
|
+
|
259
|
+
def shutdown(self):
|
260
|
+
""" Method to free up the resources taken by the agent """
|
261
|
+
pass
|
262
|
+
|
263
|
+
# --------------------------------------------------------
|
264
|
+
# Define Worker Agent
|
265
|
+
|
266
|
+
class WorkerAgent(Worker):
|
267
|
+
""" Through a class the concept of agent is defined """
|
268
|
+
|
269
|
+
def __init__(self, agent_id:str, task:Task) -> None:
|
270
|
+
""" Constructor
|
271
|
+
@param agent_id: Agent ID
|
272
|
+
@param task: Task
|
273
|
+
"""
|
274
|
+
self.__task = task
|
275
|
+
super().__init__(agent_id)
|
276
|
+
|
277
|
+
def build(self):
|
278
|
+
"""
|
279
|
+
Method that allows defining the structure and
|
280
|
+
resources of the agent
|
281
|
+
"""
|
282
|
+
# Assign an action to the behavior
|
283
|
+
self.bind_task(self.__task)
|
284
|
+
|
285
|
+
def shutdown(self):
|
286
|
+
""" Method to free up the resources taken by the agent """
|
287
|
+
pass
|
288
|
+
|
289
|
+
# --------------------------------------------------------
|
290
|
+
# Define build Method
|
291
|
+
|
292
|
+
def build_dispatcher_controller(name_team:str, agent_count, task_class:Task) -> DispatcherController:
|
293
|
+
""" Builds the controller
|
294
|
+
@param name_team: Team name
|
295
|
+
@param agent_count: Agent count
|
296
|
+
@param task_class: Task Class
|
297
|
+
@return: Controller
|
298
|
+
"""
|
299
|
+
# Define worker agent list
|
300
|
+
w_ag_list = []
|
301
|
+
# Iterate over the number of agents
|
302
|
+
for i in range(agent_count):
|
303
|
+
short_uuid = generate_short_uuid()
|
304
|
+
w_id = f"worker-agent-{i}-{short_uuid}"
|
305
|
+
# Create the agent
|
306
|
+
w_ag = WorkerAgent(w_id, task_class())
|
307
|
+
# Start the agent
|
308
|
+
w_ag.start()
|
309
|
+
# Add the agent to the list
|
310
|
+
w_ag_list.append(w_ag)
|
311
|
+
# Create the controller
|
312
|
+
dispatcher = DispacherAgent(name_team, 1, agent_count)
|
313
|
+
# Subscribe the agents to the controller
|
314
|
+
for w_ag in w_ag_list:
|
315
|
+
dispatcher.suscribe_agent(w_ag)
|
316
|
+
# Start the controller
|
317
|
+
dispatcher.start()
|
318
|
+
# Return the controller
|
319
|
+
return dispatcher
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
----------------------------------------------------------
|
4
|
+
-------------------------- PBESA -------------------------
|
5
|
+
----------------------------------------------------------
|
6
|
+
|
7
|
+
@autor AKEN
|
8
|
+
@version 4.0.0
|
9
|
+
@date 05/02/25
|
10
|
+
"""
|
11
|
+
|
12
|
+
GET_DATE="""
|
13
|
+
A partir la fecha actual: {fecha_actual}. A partir del siguiente texto: "{texto}" por favor identifica la fecha y hora. Responde solo en el siguiente formato: '%Y-%m-%d %H:%M:%S'. Si no puedes identificar la fecha responde solo con: 'N/A'
|
14
|
+
"""
|
15
|
+
|
16
|
+
AFIRMATIVE_RESPONSE="""
|
17
|
+
Responde 'SI_ES' si el siguiente texto corresponde a una respuesta afirmativa a una pregunta cualquiera: "%s", Responde 'N/A' si no corresponde a una respuesta afirmativa o si no sabes.
|
18
|
+
"""
|
pbesa/social/worker.py
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
----------------------------------------------------------
|
4
|
+
-------------------------- PBESA -------------------------
|
5
|
+
----------------------------------------------------------
|
6
|
+
|
7
|
+
@autor AKEN
|
8
|
+
@version 4.0.0
|
9
|
+
@date 09/08/24
|
10
|
+
"""
|
11
|
+
|
12
|
+
# --------------------------------------------------------
|
13
|
+
# Define resources
|
14
|
+
# --------------------------------------------------------
|
15
|
+
|
16
|
+
from threading import Timer
|
17
|
+
from abc import abstractmethod
|
18
|
+
from ..kernel.agent import Agent
|
19
|
+
from ..kernel.agent import Action
|
20
|
+
|
21
|
+
# ----------------------------------------------------------
|
22
|
+
# Defines system component exceptions
|
23
|
+
# ----------------------------------------------------------
|
24
|
+
|
25
|
+
class TaskException(Exception):
|
26
|
+
""" Base class for exceptions of agent """
|
27
|
+
pass
|
28
|
+
|
29
|
+
class WorkerException(Exception):
|
30
|
+
""" Base class for exceptions of agent """
|
31
|
+
pass
|
32
|
+
|
33
|
+
# ----------------------------------------------------------
|
34
|
+
# Define the TimeoutAction
|
35
|
+
# ----------------------------------------------------------
|
36
|
+
|
37
|
+
class TimeoutAction(Action):
|
38
|
+
"""
|
39
|
+
@See Action
|
40
|
+
"""
|
41
|
+
|
42
|
+
def handler(self) -> None:
|
43
|
+
""" Timeout handler """
|
44
|
+
if self.agent.is_timeout():
|
45
|
+
self.agent.set_timeout(False)
|
46
|
+
self.adm.send_event(self.agent.id, 'response', 'timeout')
|
47
|
+
|
48
|
+
def execute(self, data:any) -> None:
|
49
|
+
""" Execute
|
50
|
+
@param data: Data
|
51
|
+
"""
|
52
|
+
if not self.agent.is_timeout():
|
53
|
+
self.agent.set_timeout(True)
|
54
|
+
r = Timer(data['time'], self.handler)
|
55
|
+
r.start()
|
56
|
+
|
57
|
+
# --------------------------------------------------------
|
58
|
+
# Define Task Action
|
59
|
+
# --------------------------------------------------------
|
60
|
+
|
61
|
+
class Task(Action):
|
62
|
+
""" An action is a response to the occurrence of an event """
|
63
|
+
|
64
|
+
def __init__(self) -> None:
|
65
|
+
self.__is_pool = False
|
66
|
+
self.__enable_response = False
|
67
|
+
super().__init__()
|
68
|
+
|
69
|
+
def execute(self, data:any) -> None:
|
70
|
+
"""
|
71
|
+
Response.
|
72
|
+
@param data Event data
|
73
|
+
"""
|
74
|
+
self.run(data)
|
75
|
+
|
76
|
+
if self.__is_pool:
|
77
|
+
self.adm.send_event(self.agent.get_controller(), 'notify', self.agent.id)
|
78
|
+
|
79
|
+
def active_timeout(self, time:int) -> None:
|
80
|
+
""" Active timeout
|
81
|
+
@param time: Time
|
82
|
+
"""
|
83
|
+
self.adm.send_event(self.agent.id, 'timeout', {'time': time, 'dto': None})
|
84
|
+
|
85
|
+
def send_response(self, data:any) -> None:
|
86
|
+
""" Send response
|
87
|
+
@param data: Data
|
88
|
+
"""
|
89
|
+
if self.__enable_response:
|
90
|
+
response = {
|
91
|
+
'source': self.agent.id,
|
92
|
+
'result': data
|
93
|
+
}
|
94
|
+
self.adm.send_event(self.agent.get_controller(), 'response', response)
|
95
|
+
else:
|
96
|
+
raise TaskException('[Warn, sendResponse]: The type of control does not allow synchronous responses (see Linear or Pool type Block)')
|
97
|
+
|
98
|
+
@abstractmethod
|
99
|
+
def run(self, data:any) -> None:
|
100
|
+
""" Run
|
101
|
+
@param data: Data
|
102
|
+
"""
|
103
|
+
pass
|
104
|
+
|
105
|
+
def set_is_pool(self, is_pool:bool) -> None:
|
106
|
+
""" Set is pool
|
107
|
+
@param is_pool: Is pool
|
108
|
+
"""
|
109
|
+
self.__is_pool = is_pool
|
110
|
+
|
111
|
+
def set_enable_response(self, enable_response) -> None:
|
112
|
+
""" Set enable response
|
113
|
+
@param enable_response: Enable response
|
114
|
+
"""
|
115
|
+
self.__enable_response = enable_response
|
116
|
+
|
117
|
+
# --------------------------------------------------------
|
118
|
+
# Define Worker component
|
119
|
+
# --------------------------------------------------------
|
120
|
+
|
121
|
+
class Worker(Agent):
|
122
|
+
""" Represents the agent that executes the actions """
|
123
|
+
|
124
|
+
def __init__(self, agent_id:str) -> None:
|
125
|
+
""" Constructor
|
126
|
+
@param agent_id: Agent ID
|
127
|
+
"""
|
128
|
+
self.__task_list = []
|
129
|
+
self.__controller = None
|
130
|
+
self.__controller_type = None
|
131
|
+
super().__init__(agent_id)
|
132
|
+
|
133
|
+
def setup(self) -> None:
|
134
|
+
""" Set up method """
|
135
|
+
self.add_behavior('Task')
|
136
|
+
self.add_behavior('Timeout')
|
137
|
+
self.bind_action('Timeout', 'timeout', TimeoutAction())
|
138
|
+
self.build()
|
139
|
+
|
140
|
+
def bind_task(self, action:Task) -> None:
|
141
|
+
""" Bind task
|
142
|
+
@param action: Task
|
143
|
+
"""
|
144
|
+
if isinstance(action, Task):
|
145
|
+
self.__task_list.append(action)
|
146
|
+
self.bind_action('Task', 'task', action)
|
147
|
+
else:
|
148
|
+
raise WorkerException('[Warn, bindTask]: The action must inherit from the task type')
|
149
|
+
|
150
|
+
def suscribe_remote_controller(self, controller_id:str) -> None:
|
151
|
+
""" Suscribe remote controller
|
152
|
+
@param controller_id: Controller ID
|
153
|
+
"""
|
154
|
+
self.set_controller(controller_id)
|
155
|
+
self.set_controller_type('LINEAL')
|
156
|
+
actions = self.get_actions()
|
157
|
+
for action in actions:
|
158
|
+
action.set_is_pool(False)
|
159
|
+
action.set_enable_response(True)
|
160
|
+
|
161
|
+
@abstractmethod
|
162
|
+
def build(self) -> None:
|
163
|
+
""" Build """
|
164
|
+
pass
|
165
|
+
|
166
|
+
def get_actions(self) -> list:
|
167
|
+
""" Get actions
|
168
|
+
@return: Actions
|
169
|
+
"""
|
170
|
+
return self.__task_list
|
171
|
+
|
172
|
+
def get_controller(self) -> str:
|
173
|
+
""" Get controller
|
174
|
+
@return: Controller
|
175
|
+
"""
|
176
|
+
return self.__controller
|
177
|
+
|
178
|
+
def set_controller(self, controller:str) -> None:
|
179
|
+
""" Set controller
|
180
|
+
@param controller: Controller
|
181
|
+
"""
|
182
|
+
self.__controller = controller
|
183
|
+
|
184
|
+
def set_controller_type(self, controller_type:str) -> None:
|
185
|
+
""" Set controller type
|
186
|
+
@param controller_type: Controller type
|
187
|
+
"""
|
188
|
+
self.__controller_type = controller_type
|
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2020 Aken
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Aken
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018 Joel Barmettler
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Joel Barmettler
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
pbesa/__init__.py,sha256=RxAzZh-7Je5Yees_fAfeYINnyDjjqPYRwRo_3hcwxPs,90
|
2
|
+
pbesa/cognitive.py,sha256=Lj2EYPcovevonTpy7RonUiUrqhYU31EKq-5LH_5EdqA,14988
|
3
|
+
pbesa/mas.py,sha256=d3Dx7EiFZgMJcCOlKSkJ229ebPCq-QvV0vq45yegOLY,24788
|
4
|
+
pbesa/kernel/__init__.py,sha256=D7pFCNisMFoKsP21f45jAACNbSZHzV4HNWJmn63Oxow,80
|
5
|
+
pbesa/kernel/adapter.py,sha256=kG6M6D7BKQ7R9UsbBGJGZjYdMK-rklqn4BBtDtXIyiQ,4320
|
6
|
+
pbesa/kernel/agent.py,sha256=_4WvhQ3BZZ0OdQLCN28ZHNtoMt41EfFtj_HPR0nNMd4,18789
|
7
|
+
pbesa/kernel/util.py,sha256=EtnpfV8nQlRRkH1Wnq1FzYG4X_WUbpmNesL6q4nsML0,8135
|
8
|
+
pbesa/kernel/world.py,sha256=z90LpCPD9axg2jcqfmxzEh6BuE_EJC7-zgTIqwdNsGU,965
|
9
|
+
pbesa/kernel/io/__init__.py,sha256=vueOjermE1xADBLXPAwYieWJn5oo_PzAeVOLU0RcD1A,70
|
10
|
+
pbesa/kernel/io/system_file.py,sha256=s7aZ4ob5neVzOECiU8jEbOlnKkcfs5C9ui5iNe-5vBs,916
|
11
|
+
pbesa/kernel/io/tcp_server.py,sha256=mtfyHkg_o02avrpRPKTJYb6S9ZLQ74YKgkVPxgYW_XA,629
|
12
|
+
pbesa/kernel/res/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
+
pbesa/remote/__init__.py,sha256=lRrxD-EVUMpNq1C_BFh12BUBztqviPXJWKU9fWTaa6o,199
|
14
|
+
pbesa/remote/adm_listener.py,sha256=OrrhFkFNtIU4ETJJe7KbrqXJKTYTlDRGSrzNRkDWqbI,1117
|
15
|
+
pbesa/remote/adm_listener_handler.py,sha256=ylg_HKHM978D38Qgw4-dIfCka3l2E-RxaqV-oPHIRKw,2664
|
16
|
+
pbesa/remote/exceptions.py,sha256=UabAEHwhU5sX9_hNxFZOS-6whteRV-sCADzwD1r6YkM,520
|
17
|
+
pbesa/remote/remote_adm.py,sha256=MIxPQwEdOj_oMZFabejlLDb1-kP0M_p-IAjW8Ud9uqA,1103
|
18
|
+
pbesa/remote/remote_adm_handler.py,sha256=KJfrtJzsafIvfbtvWOfi1GKLFlq8_fy0DKywP2k_ZKU,4383
|
19
|
+
pbesa/social/__init__.py,sha256=jypNfV-mXpFvV9DPI5PgpMldtDmhyuFPUVMBdyFheew,112
|
20
|
+
pbesa/social/collaborative_team.py,sha256=FX50tjwxryZ2R6SUAZp4i_tBkyXtZDStY0rmLCTYI3c,9934
|
21
|
+
pbesa/social/delegator.py,sha256=VIkGv2ZUXKCIcQicHVkVNtTO8fh1hTY7-n0J6zsSeu0,2514
|
22
|
+
pbesa/social/delegator_team.py,sha256=TxIZtrzrVghEqq6Vjw6wiPn6dMXy3GItOxoLSxCGUwI,10695
|
23
|
+
pbesa/social/dialog.py,sha256=UNR8zwrmVM4yPVu6cjFDMcK8fLa1JxoJ_AorxXRzBRc,4558
|
24
|
+
pbesa/social/dispatcher_team.py,sha256=rTscxAbu8d08tXlcZqJj_W6_mI-DRyoWdQHlA1dRipY,10049
|
25
|
+
pbesa/social/templates.py,sha256=zM_r87XrRdOJ8unhFPo8-2qlgbQ0sf52iifFccF_XZo,725
|
26
|
+
pbesa/social/worker.py,sha256=KfKC5fjxYx5SdMMklrlCdNJDfX0tp7DM9bv-ghBRYgk,5527
|
27
|
+
pbesa-4.0.0.dist-info/LICENSE,sha256=RrFj4vGpoc9x5YjrUgXtg4fevhXih6WSCF8NtyR6C_k,1061
|
28
|
+
pbesa-4.0.0.dist-info/LICENSE.txt,sha256=eOjr40uPia8NI0XRqBavU1w1IaAM2AurWiXSWVnRc9U,1072
|
29
|
+
pbesa-4.0.0.dist-info/METADATA,sha256=tyYsQgnrikU7YQpKzOgkEDyQZ6ly3Os6NZGKyzRPBco,182
|
30
|
+
pbesa-4.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
31
|
+
pbesa-4.0.0.dist-info/top_level.txt,sha256=TrImx2eWQUKXJgNTI-Po1yBYSFK0U4j049PpgioXduY,6
|
32
|
+
pbesa-4.0.0.dist-info/RECORD,,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
Wheel-Version: 1.0
|
2
|
-
Generator:
|
3
|
-
Root-Is-Purelib: true
|
4
|
-
Tag: py3-none-any
|
5
|
-
|
1
|
+
Wheel-Version: 1.0
|
2
|
+
Generator: setuptools (75.8.0)
|
3
|
+
Root-Is-Purelib: true
|
4
|
+
Tag: py3-none-any
|
5
|
+
|
File without changes
|
pbesa/engine/__init__.py
DELETED