pbesa 4.0.4__tar.gz → 4.0.5__tar.gz

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.
Files changed (103) hide show
  1. {pbesa-4.0.4 → pbesa-4.0.5}/PKG-INFO +2 -3
  2. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/cognitive.py +13 -9
  3. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/dialog.py +2 -1
  4. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/dispatcher_team.py +15 -2
  5. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/prompts.py +24 -0
  6. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/selected_dispatcher_team.py +1 -1
  7. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa.egg-info/PKG-INFO +2 -3
  8. {pbesa-4.0.4 → pbesa-4.0.5}/setup.py +1 -1
  9. {pbesa-4.0.4 → pbesa-4.0.5}/.gitignore +0 -0
  10. {pbesa-4.0.4 → pbesa-4.0.5}/LICENSE +0 -0
  11. {pbesa-4.0.4 → pbesa-4.0.5}/LICENSE.txt +0 -0
  12. {pbesa-4.0.4 → pbesa-4.0.5}/MANIFEST +0 -0
  13. {pbesa-4.0.4 → pbesa-4.0.5}/README.md +0 -0
  14. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/db.sqlite3 +0 -0
  15. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__init__.py +0 -0
  16. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
  17. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
  18. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
  19. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
  20. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
  21. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/asgi.py +0 -0
  22. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/pbesa.py +0 -0
  23. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/settings.py +0 -0
  24. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/urls.py +0 -0
  25. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/helloworld/wsgi.py +0 -0
  26. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/manage.py +0 -0
  27. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__init__.py +0 -0
  28. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
  29. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
  30. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
  31. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
  32. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
  33. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
  34. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/admin.py +0 -0
  35. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/apps.py +0 -0
  36. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  37. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  38. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  39. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
  40. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
  41. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
  42. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  43. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  44. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
  45. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
  46. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
  47. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
  48. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/models.py +0 -0
  49. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/tests.py +0 -0
  50. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/urls.py +0 -0
  51. {pbesa-4.0.4 → pbesa-4.0.5}/examples/django/helloworld/translate/views.py +0 -0
  52. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
  53. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
  54. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
  55. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  56. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  57. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  58. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/countercontroller.py +0 -0
  59. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/counterdelegate.py +0 -0
  60. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/controller/counterresponse.py +0 -0
  61. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
  62. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
  63. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  64. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  65. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/counteragent.py +0 -0
  66. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/mas/worker/countertask.py +0 -0
  67. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/remote_a.py +0 -0
  68. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/remote_b.py +0 -0
  69. {pbesa-4.0.4 → pbesa-4.0.5}/examples/remote/remote_c.py +0 -0
  70. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/__init__.py +0 -0
  71. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/__init__.py +0 -0
  72. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/adapter.py +0 -0
  73. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/agent.py +0 -0
  74. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/io/__init__.py +0 -0
  75. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/io/system_file.py +0 -0
  76. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/io/tcp_server.py +0 -0
  77. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/__init__.py +0 -0
  78. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
  79. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
  80. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
  81. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
  82. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/res/conf.json +0 -0
  83. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/util.py +0 -0
  84. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/kernel/world.py +0 -0
  85. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/mas.py +0 -0
  86. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/models.py +0 -0
  87. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/__init__.py +0 -0
  88. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/adm_listener.py +0 -0
  89. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/adm_listener_handler.py +0 -0
  90. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/exceptions.py +0 -0
  91. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/remote_adm.py +0 -0
  92. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/remote/remote_adm_handler.py +0 -0
  93. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/__init__.py +0 -0
  94. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/collaborative_team.py +0 -0
  95. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/delegator.py +0 -0
  96. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/delegator_team.py +0 -0
  97. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/templates.py +0 -0
  98. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa/social/worker.py +0 -0
  99. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa.egg-info/SOURCES.txt +0 -0
  100. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa.egg-info/dependency_links.txt +0 -0
  101. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa.egg-info/requires.txt +0 -0
  102. {pbesa-4.0.4 → pbesa-4.0.5}/pbesa.egg-info/top_level.txt +0 -0
  103. {pbesa-4.0.4 → pbesa-4.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: pbesa
3
- Version: 4.0.4
3
+ Version: 4.0.5
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE.txt
6
6
  Requires-Dist: pymongo==4.6.3
@@ -8,4 +8,3 @@ Requires-Dist: requests==2.32.3
8
8
  Requires-Dist: azure-ai-projects==1.0.0b6
9
9
  Requires-Dist: azure-ai-inference==1.0.0b9
10
10
  Requires-Dist: azure-identity==1.20.0
11
- Dynamic: requires-dist
@@ -21,7 +21,7 @@ from typing import List, Optional
21
21
  from abc import ABC, abstractmethod
22
22
  from pbesa.models import AIFoundry, AzureInference, GPTService, ServiceProvider
23
23
  from pbesa.social.dialog import DialogState, imprimir_grafo, recorrer_interacciones, extraer_diccionario_nodos, ActionNode, DeclarativeNode#, TerminalNode
24
- from pbesa.social.prompts import CLASSIFICATION_PROMPT, DERIVE_PROMPT
24
+ from pbesa.social.prompts import CLASSIFICATION_PROMPT, DERIVE_PROMPT, RECOVERY_PROMPT
25
25
  # --------------------------------------------------------
26
26
  # Define DTOs
27
27
  # --------------------------------------------------------
@@ -518,29 +518,29 @@ class Dialog(ABC):
518
518
  self.setup_world()
519
519
  interations = agent_metadata.role.interactions
520
520
  grafo = recorrer_interacciones(interations)
521
- logging.info("")
521
+ logging.debug("")
522
522
  # Si el grafo es una lista de nodos, lo imprimimos cada uno
523
523
  if isinstance(grafo, list):
524
524
  for nodo in grafo:
525
525
  imprimir_grafo(nodo)
526
526
  else:
527
527
  imprimir_grafo(grafo)
528
- logging.info("")
528
+ logging.debug("")
529
529
  # Ejemplo de uso:
530
530
  self.__dfa = extraer_diccionario_nodos(grafo)
531
531
  # Mostrar el diccionario
532
532
  for clave, valor in self.__dfa.items():
533
- logging.info(f"{clave}: {valor.text}")
534
- logging.info("")
533
+ logging.debug(f"{clave}: {valor.text}")
534
+ logging.debug("")
535
535
  iniciadores = []
536
536
  for item in interations:
537
537
  for clave, valor in self.__dfa.items():
538
538
  if valor.text == item['texto']:
539
539
  iniciadores.append(valor)
540
- logging.info("Iniciadores:")
540
+ logging.debug("Iniciadores:")
541
541
  for iniciador in iniciadores:
542
- logging.info(iniciador.text)
543
- logging.info("")
542
+ logging.debug(iniciador.text)
543
+ logging.debug("")
544
544
  # Set dialog state
545
545
  self.__dfa['start'] = iniciadores
546
546
 
@@ -608,7 +608,11 @@ class Dialog(ABC):
608
608
  if not dialog_state in self.__dfa:
609
609
  logging.warning(f"------------Performativa no existe---------------")
610
610
  self.reset()
611
- return "Web", DialogState.START, "Lo lamento, no puedo responder en este momento", "Web"
611
+ prompt = RECOVERY_PROMPT % query
612
+ temp_work_memory = [{"role": "user", "content": query}]
613
+ res = self.__ai_service.generate(temp_work_memory)
614
+ res = self.get_text(res)
615
+ return "Web", DialogState.START, res, "Web"
612
616
 
613
617
  node = self.__dfa[dialog_state]
614
618
  if not isinstance(node, list):
@@ -13,6 +13,7 @@
13
13
  # Define resources
14
14
  # --------------------------------------------------------
15
15
 
16
+ import logging
16
17
  import datetime
17
18
  import traceback
18
19
  from .templates import AFIRMATIVE_RESPONSE, GET_DATE
@@ -199,6 +200,6 @@ def imprimir_grafo(nodo, nivel=0):
199
200
  indent = " " * nivel
200
201
  # Se muestra la clase del nodo y algunos atributos
201
202
  clase = nodo.__class__.__name__
202
- print(f"{indent}{clase} (performative: {nodo.performative}, text/action: {nodo.text if hasattr(nodo, 'text') and nodo.text is not None else getattr(nodo, 'action', None)}, terminal: {nodo.is_terminal})")
203
+ logging.debug(f"{indent}{clase} (performative: {nodo.performative}, text/action: {nodo.text if hasattr(nodo, 'text') and nodo.text is not None else getattr(nodo, 'action', None)}, terminal: {nodo.is_terminal})")
203
204
  for child in nodo.children:
204
205
  imprimir_grafo(child, nivel + 1)
@@ -130,7 +130,7 @@ class ResponseAction(Action):
130
130
  class DispatcherController(Agent):
131
131
  """ Represents the agent that delegates the execution of actions to other agents """
132
132
 
133
- def __init__(self, agent_id:str, buffer_size:int, pool_size:int) -> None:
133
+ def __init__(self, agent_id:str, buffer_size:int, pool_size:int, delegate=None) -> None:
134
134
  """ Constructor
135
135
  @param agent_id: Agent ID
136
136
  @param type: Pool type
@@ -139,15 +139,20 @@ class DispatcherController(Agent):
139
139
  """
140
140
  self.__buffer_size = buffer_size
141
141
  self.__request_dict = {}
142
+ self.__pool_size = pool_size
142
143
  self.__free_queue = Queue(pool_size)
143
144
  self.__agent_list = []
145
+ self.__delegate = delegate
144
146
  super().__init__(agent_id)
145
147
 
146
148
  def setup(self) -> None:
147
149
  """ Set up method """
148
150
  self._social = True
149
151
  self.add_behavior('Delegate')
150
- self.bind_action('Delegate', 'delegate', Delegate())
152
+ if self.__delegate:
153
+ self.bind_action('Delegate', 'delegate', self.__delegate())
154
+ else:
155
+ self.bind_action('Delegate', 'delegate', Delegate())
151
156
  self.add_behavior('Notify')
152
157
  self.bind_action('Notify', 'notify', NotifyFreeAction())
153
158
  self.add_behavior('Response')
@@ -161,6 +166,8 @@ class DispatcherController(Agent):
161
166
  self.__agent_list.append(agent.id)
162
167
  agent.set_controller(self.id)
163
168
  agent.set_controller_type('POOL')
169
+ if len(self.__agent_list) > self.__pool_size:
170
+ raise DispatcherException('[Warn, suscribeAgent]: The pool is full')
164
171
  self.__free_queue.put(agent.id)
165
172
  actions = agent.get_actions()
166
173
  for action in actions:
@@ -190,6 +197,12 @@ class DispatcherController(Agent):
190
197
  """ Builds the agent """
191
198
  pass
192
199
 
200
+ def get_agent_list(self) -> list:
201
+ """ Gets the agent list
202
+ @return: Agent list
203
+ """
204
+ return self.__agent_list
205
+
193
206
  def get_free_queue(self) -> Queue:
194
207
  """ Gets the free queue
195
208
  @return: Free queue
@@ -36,5 +36,29 @@ Ahora, evalúa el siguiente caso:
36
36
 
37
37
  Texto: "%s"
38
38
 
39
+ Respuesta:
40
+ """
41
+
42
+ RECOVERY_PROMPT = """
43
+ Instrucciones:
44
+
45
+ Eres un agente especializado en parafrasear. Tu tarea es analizar un texto principal y parafrasearlo generando opciones al usuario.
46
+
47
+ Requisitos:
48
+
49
+ - No incluyas explicaciones, razonamientos ni texto adicional.
50
+ - Genera opciones en lenguaje natural sin involucrar números o listas.
51
+ - Si no logras parafrasear el texto principal, responde solicitando más información.
52
+
53
+ Ejemplo:
54
+
55
+ Texto: "Hola mi caso esta relacionado con la Superfinanciera"
56
+
57
+ Respuesta: Perdona, tu solicitud ¿Es sobre la Superintendencia Financiera de Colombia o sobre la Superintendencia de Sociedades?
58
+
59
+ Ahora, evalúa el siguiente caso:
60
+
61
+ Texto: "%s"
62
+
39
63
  Respuesta:
40
64
  """
@@ -104,7 +104,7 @@ class DelegateAction(Action):
104
104
  self.__rewier[ag] = 0
105
105
  exit = True
106
106
  else:
107
- logging.info('The agent is not available')
107
+ logging.info('The agent is not operational')
108
108
  self.adm.send_event(agent_obj.get_controller(), 'notify', ag)
109
109
  if ag in self.__rewier:
110
110
  self.__rewier[ag] = self.__rewier[ag] + 1
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.1
2
2
  Name: pbesa
3
- Version: 4.0.4
3
+ Version: 4.0.5
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE.txt
6
6
  Requires-Dist: pymongo==4.6.3
@@ -8,4 +8,3 @@ Requires-Dist: requests==2.32.3
8
8
  Requires-Dist: azure-ai-projects==1.0.0b6
9
9
  Requires-Dist: azure-ai-inference==1.0.0b9
10
10
  Requires-Dist: azure-identity==1.20.0
11
- Dynamic: requires-dist
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name='pbesa',
7
- version='4.0.4',
7
+ version='4.0.5',
8
8
  packages=find_packages(),
9
9
  install_requires=[
10
10
  'pymongo==4.6.3',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes