pbesa 4.0.16__tar.gz → 4.0.17__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 (112) hide show
  1. {pbesa-4.0.16 → pbesa-4.0.17}/PKG-INFO +1 -1
  2. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/cognitive.py +9 -4
  3. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/util.py +2 -1
  4. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/models.py +24 -11
  5. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa.egg-info/PKG-INFO +1 -1
  6. {pbesa-4.0.16 → pbesa-4.0.17}/setup.py +1 -1
  7. {pbesa-4.0.16 → pbesa-4.0.17}/.gitignore +0 -0
  8. {pbesa-4.0.16 → pbesa-4.0.17}/LICENSE +0 -0
  9. {pbesa-4.0.16 → pbesa-4.0.17}/LICENSE.txt +0 -0
  10. {pbesa-4.0.16 → pbesa-4.0.17}/MANIFEST +0 -0
  11. {pbesa-4.0.16 → pbesa-4.0.17}/README.md +0 -0
  12. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/db.sqlite3 +0 -0
  13. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__init__.py +0 -0
  14. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
  15. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
  16. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
  17. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
  18. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
  19. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/asgi.py +0 -0
  20. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/pbesa.py +0 -0
  21. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/settings.py +0 -0
  22. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/urls.py +0 -0
  23. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/helloworld/wsgi.py +0 -0
  24. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/manage.py +0 -0
  25. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__init__.py +0 -0
  26. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
  27. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
  28. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
  29. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
  30. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
  31. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
  32. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/admin.py +0 -0
  33. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/apps.py +0 -0
  34. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  35. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  36. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  37. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
  38. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
  39. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
  40. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  41. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  42. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
  43. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
  44. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
  45. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
  46. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/models.py +0 -0
  47. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/tests.py +0 -0
  48. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/urls.py +0 -0
  49. {pbesa-4.0.16 → pbesa-4.0.17}/examples/django/helloworld/translate/views.py +0 -0
  50. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
  51. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
  52. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
  53. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  54. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  55. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  56. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/countercontroller.py +0 -0
  57. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/counterdelegate.py +0 -0
  58. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/controller/counterresponse.py +0 -0
  59. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
  60. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
  61. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  62. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  63. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/counteragent.py +0 -0
  64. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/mas/worker/countertask.py +0 -0
  65. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/remote_a.py +0 -0
  66. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/remote_b.py +0 -0
  67. {pbesa-4.0.16 → pbesa-4.0.17}/examples/remote/remote_c.py +0 -0
  68. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/__init__.py +0 -0
  69. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/__init__.py +0 -0
  70. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_casos.py +0 -0
  71. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_consultas.py +0 -0
  72. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_datos_identificables.py +0 -0
  73. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_expertos.py +0 -0
  74. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_generar_documento.py +0 -0
  75. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_preguntas.py +0 -0
  76. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/celula_saludos.py +0 -0
  77. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/celulas/web.py +0 -0
  78. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/__init__.py +0 -0
  79. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/adapter.py +0 -0
  80. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/agent.py +0 -0
  81. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/io/__init__.py +0 -0
  82. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/io/system_file.py +0 -0
  83. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/io/tcp_server.py +0 -0
  84. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/__init__.py +0 -0
  85. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
  86. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
  87. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
  88. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
  89. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/res/conf.json +0 -0
  90. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/kernel/world.py +0 -0
  91. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/mas.py +0 -0
  92. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/__init__.py +0 -0
  93. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/adm_listener.py +0 -0
  94. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/adm_listener_handler.py +0 -0
  95. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/exceptions.py +0 -0
  96. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/remote_adm.py +0 -0
  97. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/remote/remote_adm_handler.py +0 -0
  98. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/__init__.py +0 -0
  99. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/collaborative_team.py +0 -0
  100. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/delegator.py +0 -0
  101. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/delegator_team.py +0 -0
  102. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/dialog.py +0 -0
  103. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/dispatcher_team.py +0 -0
  104. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/prompts.py +0 -0
  105. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/selected_dispatcher_team.py +0 -0
  106. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/templates.py +0 -0
  107. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa/social/worker.py +0 -0
  108. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa.egg-info/SOURCES.txt +0 -0
  109. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa.egg-info/dependency_links.txt +0 -0
  110. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa.egg-info/requires.txt +0 -0
  111. {pbesa-4.0.16 → pbesa-4.0.17}/pbesa.egg-info/top_level.txt +0 -0
  112. {pbesa-4.0.16 → pbesa-4.0.17}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pbesa
3
- Version: 4.0.16
3
+ Version: 4.0.17
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE.txt
6
6
  Requires-Dist: pymongo>=4.6.3
@@ -789,7 +789,10 @@ class Dialog(ABC):
789
789
 
790
790
  def recovery(self, session_id, query):
791
791
  try:
792
- self.__work_memory = self.system_work_memory.copy()
792
+ logging.info("\n\n\n")
793
+ logging.info(f"------------RECOVERY---------------")
794
+ logging.info("\n\n\n")
795
+ self.__work_memory = self.__system_work_memory.copy()
793
796
  prompt = RECOVERY_PROMPT % query
794
797
  temp_work_memory = [{"role": "system", "content": prompt}]
795
798
  res = self.__ai_service.generate(temp_work_memory, max_tokens=500)
@@ -803,7 +806,9 @@ class Dialog(ABC):
803
806
  self.notify(session_id, "STOP")
804
807
  return "Web", DialogState.START, self.RECOVERY_MSG, "Web"
805
808
  except Exception as e:
806
- return self.RECOVERY_MSG
809
+ logging.error(f"Error en la recuperación: {e}")
810
+ msg = "Lo lamento, no puedo responder en este momento."
811
+ return "Web", DialogState.START, msg, "Web"
807
812
 
808
813
  def stage_one_classification(self, session_id, messages, attemps, query):
809
814
  """ Stage one classification """
@@ -1280,10 +1285,10 @@ class Dialog(ABC):
1280
1285
  res = self.__ai_service.generate(self.__work_memory, max_tokens=1000)
1281
1286
  res = self.get_text(res)
1282
1287
  logging.info(f"[Inferencia]:[Thought]:[DEEP]: {res}")
1283
- self.__work_memory.append({"role": "assistant", "content": res})
1284
1288
  # Check if res is empty
1285
- if not res or res == "":
1289
+ if not res or res == "" or res == "ERROR":
1286
1290
  return self.recovery(session['session_id'], query)
1291
+ self.__work_memory.append({"role": "assistant", "content": res})
1287
1292
  new_dialog_state = node.performative
1288
1293
  if not node.is_terminal:
1289
1294
  # Verifica recursion
@@ -73,7 +73,8 @@ class APIClient:
73
73
  url=f"{self.base_url}/{endpoint}",
74
74
  headers=self.headers,
75
75
  json=payload,
76
- timeout=self.timeout
76
+ timeout=self.timeout,
77
+ verify=False
77
78
  )
78
79
  response.raise_for_status()
79
80
  print(f"POST request to {endpoint} succeeded: {response.status_code}")
@@ -141,44 +141,51 @@ class AzureInference(AIService):
141
141
  self.deployment = self.model_conf['DEPLOYMENT_NAME']
142
142
 
143
143
  def generate(self, work_memory, max_tokens=2000, temperature=0, top_p=0.9) -> str:
144
+ again = False
144
145
  try:
145
146
  response = self.model.complete(
146
147
  messages= work_memory,
147
148
  model= self.deployment,
148
149
  max_tokens= self.max_tokens
149
150
  )
150
- return response.choices[0].message.content
151
+ res = response.choices[0].message.content
152
+ if not res or res == "" or res == "ERROR":
153
+ again = True
154
+ else:
155
+ return res
151
156
  except Exception as e:
152
157
  # Maneja otros errores
158
+ again = True
153
159
  trace_err = traceback.format_exc()
154
160
  err = str(e) + " - " + trace_err
155
161
  logging.info(f"Error en la respuesta de Azure: {err}")
162
+ if again:
156
163
  if self.model_conf['SUBSTITUDE_DEPLOYMENT_NAME'] == "Llama-3.3-70B-Instruct":
157
164
  logging.info("\n\n\n")
158
165
  logging.info("----------------------------------------")
159
- logging.info("Entra a jugar el sustituto")
166
+ logging.info("Sustitudo atiendendo Llama-3.3-70B-Instruct")
160
167
  try:
161
168
  logging.info("\n\n\n.............................................")
162
169
  logging.info("\n%s", json.dumps(work_memory, indent=4))
163
170
  logging.info("........................................\n\n\n")
164
-
165
171
  response = self.model.complete(
166
172
  messages= work_memory,
167
173
  model =self.model_conf['SUBSTITUDE_DEPLOYMENT_NAME'],
168
174
  max_tokens=self.model_conf['MAX_TOKENS']
169
175
  )
170
176
  logging.info("----------------------------------------")
171
- logging.info("\n\n\n")
172
-
177
+ logging.info("\n\n\n")
173
178
  return response.choices[0].message.content
174
179
  except Exception as e2:
175
180
  trace_err2 = traceback.format_exc()
176
181
  err2 = str(e2) + " - " + trace_err2
177
182
  logging.info(f"Error en la respuesta de Azure: {err2}")
178
183
  logging.info("----------------------------------------")
179
- logging.info("\n\n\n")
180
-
184
+ logging.info("\n\n\n")
181
185
  raise e2
186
+ logging.error("\n\n\n****************************************")
187
+ logging.error("No se pudo generar una respuesta válida.")
188
+ return ""
182
189
 
183
190
  class AzureOpenAIInference(AIService):
184
191
 
@@ -231,7 +238,8 @@ class AzureOpenAIInference(AIService):
231
238
  self.wait_time = 2 ** (self.wait_time // 60)
232
239
 
233
240
  def generate(self, work_memory, max_tokens=4096, temperature=0, top_p=0.9) -> str:
234
- try:
241
+ again = False
242
+ try:
235
243
  if self.main_model_enable:
236
244
  response = self.model.chat.completions.create(
237
245
  messages=work_memory,
@@ -268,14 +276,19 @@ class AzureOpenAIInference(AIService):
268
276
  logging.info(f"Esperando {self.wait_time} segundos antes de reintentar.")
269
277
  logging.info("---------------------\n")
270
278
  else:
271
- logging.info("\n--- Uso de Tokens no disponible en la respuesta ---")
272
- return response.choices[0].message.content
279
+ logging.info("\n--- Uso de Tokens no disponible en la respuesta ---")
280
+ res = response.choices[0].message.content
281
+ if not res or res == "" or res == "ERROR":
282
+ again = True
283
+ else:
284
+ return response.choices[0].message.content
273
285
  except Exception as e:
274
286
  self.wait_strategy_for_rate_limit(e)
275
287
  #----------------------------------
276
288
  # Exception mode
277
289
  #----------------------------------
278
- if not self.main_model_enable:
290
+ if not self.main_model_enable or again:
291
+ again = False
279
292
  # Si ha pasado más de 1 minuto desde la última excepción, reinicia el modelo principal
280
293
  current_t = time.time()
281
294
  elapsed_time = current_t - self.exception_time
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pbesa
3
- Version: 4.0.16
3
+ Version: 4.0.17
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE.txt
6
6
  Requires-Dist: pymongo>=4.6.3
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name='pbesa',
7
- version='4.0.16',
7
+ version='4.0.17',
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