pbesa 4.0.1__tar.gz → 4.0.2__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.1 → pbesa-4.0.2}/PKG-INFO +1 -1
  2. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/cognitive.py +27 -6
  3. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/dialog.py +12 -11
  4. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa.egg-info/PKG-INFO +1 -1
  5. {pbesa-4.0.1 → pbesa-4.0.2}/setup.py +1 -1
  6. {pbesa-4.0.1 → pbesa-4.0.2}/.gitignore +0 -0
  7. {pbesa-4.0.1 → pbesa-4.0.2}/LICENSE +0 -0
  8. {pbesa-4.0.1 → pbesa-4.0.2}/LICENSE.txt +0 -0
  9. {pbesa-4.0.1 → pbesa-4.0.2}/MANIFEST +0 -0
  10. {pbesa-4.0.1 → pbesa-4.0.2}/README.md +0 -0
  11. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/db.sqlite3 +0 -0
  12. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__init__.py +0 -0
  13. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
  14. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
  15. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
  16. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
  17. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
  18. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/asgi.py +0 -0
  19. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/pbesa.py +0 -0
  20. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/settings.py +0 -0
  21. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/urls.py +0 -0
  22. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/helloworld/wsgi.py +0 -0
  23. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/manage.py +0 -0
  24. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__init__.py +0 -0
  25. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
  26. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
  27. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
  28. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
  29. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
  30. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
  31. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/admin.py +0 -0
  32. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/apps.py +0 -0
  33. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  34. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  35. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  36. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
  37. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
  38. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
  39. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  40. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  41. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
  42. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
  43. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
  44. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
  45. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/models.py +0 -0
  46. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/tests.py +0 -0
  47. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/urls.py +0 -0
  48. {pbesa-4.0.1 → pbesa-4.0.2}/examples/django/helloworld/translate/views.py +0 -0
  49. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
  50. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
  51. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
  52. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
  53. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
  54. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
  55. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/countercontroller.py +0 -0
  56. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/counterdelegate.py +0 -0
  57. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/controller/counterresponse.py +0 -0
  58. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
  59. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
  60. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
  61. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
  62. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/counteragent.py +0 -0
  63. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/mas/worker/countertask.py +0 -0
  64. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/remote_a.py +0 -0
  65. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/remote_b.py +0 -0
  66. {pbesa-4.0.1 → pbesa-4.0.2}/examples/remote/remote_c.py +0 -0
  67. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/__init__.py +0 -0
  68. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/__init__.py +0 -0
  69. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/adapter.py +0 -0
  70. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/agent.py +0 -0
  71. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/io/__init__.py +0 -0
  72. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/io/system_file.py +0 -0
  73. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/io/tcp_server.py +0 -0
  74. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/__init__.py +0 -0
  75. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
  76. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
  77. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
  78. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
  79. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/res/conf.json +0 -0
  80. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/util.py +0 -0
  81. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/kernel/world.py +0 -0
  82. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/mas.py +0 -0
  83. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/models.py +0 -0
  84. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/__init__.py +0 -0
  85. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/adm_listener.py +0 -0
  86. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/adm_listener_handler.py +0 -0
  87. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/exceptions.py +0 -0
  88. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/remote_adm.py +0 -0
  89. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/remote/remote_adm_handler.py +0 -0
  90. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/__init__.py +0 -0
  91. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/collaborative_team.py +0 -0
  92. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/delegator.py +0 -0
  93. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/delegator_team.py +0 -0
  94. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/dispatcher_team.py +0 -0
  95. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/prompts.py +0 -0
  96. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/selected_dispatcher_team.py +0 -0
  97. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/templates.py +0 -0
  98. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa/social/worker.py +0 -0
  99. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa.egg-info/SOURCES.txt +0 -0
  100. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa.egg-info/dependency_links.txt +0 -0
  101. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa.egg-info/requires.txt +0 -0
  102. {pbesa-4.0.1 → pbesa-4.0.2}/pbesa.egg-info/top_level.txt +0 -0
  103. {pbesa-4.0.1 → pbesa-4.0.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pbesa
3
- Version: 4.0.1
3
+ Version: 4.0.2
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE.txt
6
6
  Requires-Dist: pymongo==4.6.3
@@ -13,6 +13,7 @@
13
13
  # Define resources
14
14
  # --------------------------------------------------------
15
15
 
16
+ import re
16
17
  import traceback
17
18
  from pydantic import BaseModel
18
19
  from typing import List, Optional
@@ -577,6 +578,21 @@ class Dialog(ABC):
577
578
  if response['status']:
578
579
  return response['message']['response']
579
580
  return "Lo lamento, no puedo responder en este momento"
581
+
582
+ def get_text(self, inputs) -> str:
583
+ matches = re.findall(r'<\|im_start\|>(user|assistant)\n(.*?)<\|im_end\|>', inputs, re.DOTALL)
584
+ if matches:
585
+ messages = []
586
+ for speaker, text in matches:
587
+ messages.append({
588
+ "Assistant": speaker.capitalize(),
589
+ "User": text.strip()
590
+ })
591
+ if len(messages) > 0:
592
+ return messages[-1]["Assistant"]
593
+ else:
594
+ return messages[-1]["User"]
595
+ return inputs
580
596
 
581
597
  def transition(self, owner, dialog_state, query, team_source=False) -> str:
582
598
  text = ""
@@ -609,15 +625,17 @@ class Dialog(ABC):
609
625
  print(select_node.text)
610
626
  text = "Lo lamento, no puedo responder en este momento"
611
627
  print("???> text:", text)
628
+ text = self.get_text(text)
612
629
  return owner, DialogState.START, text, owner
613
630
 
614
631
  if team_source:
615
- self.__work_memory.append({"role": "system", "content": select_node.text})
632
+ self.__work_memory.append({"role": "user", "content": select_node.text})
616
633
  else:
617
634
  self.__work_memory.append({"role": "user", "content": query})
618
- self.__work_memory.append({"role": "system", "content": select_node.text})
635
+ self.__work_memory.append({"role": "user", "content": select_node.text})
619
636
 
620
637
  new_owner, new_dialog_state, text, team = self.do_transition(owner, select_node.children[0], query)
638
+ text = self.get_text(text)
621
639
  return new_owner, new_dialog_state, text, team
622
640
 
623
641
  def do_transition(self, owner, node, query) -> str:
@@ -626,7 +644,7 @@ class Dialog(ABC):
626
644
  """
627
645
  if isinstance(node, DeclarativeNode):
628
646
  print("-> node:", node.text)
629
- self.__work_memory.append({"role": "system", "content": node.text})
647
+ self.__work_memory.append({"role": "user", "content": node.text})
630
648
  elif isinstance(node, ActionNode):
631
649
 
632
650
  #------------------------------
@@ -636,7 +654,7 @@ class Dialog(ABC):
636
654
  print("-> node action:", node.action)
637
655
  if node.tool and not node.tool == "Ninguno":
638
656
  print("-> node tool:", node.tool)
639
- self.__work_memory.append({"role": "system", "content": node.text})
657
+ self.__work_memory.append({"role": "user", "content": node.text})
640
658
  res = self.__ai_service.generate(self.__work_memory)
641
659
 
642
660
  # Check if res is empty
@@ -658,8 +676,10 @@ class Dialog(ABC):
658
676
  # que el dialogo cambia de agente
659
677
  if node.is_terminal:
660
678
  print("-> node team -> es terminal -> " + node.text)
661
- self.__work_memory.append({"role": "system", "content": node.text})
679
+ self.__work_memory.append({"role": "user", "content": node.text})
662
680
  res = self.__ai_service.generate(self.__work_memory)
681
+ res = self.get_text(res)
682
+ self.__work_memory.append({"role": "system", "content": res})
663
683
 
664
684
  # Check if res is empty
665
685
  if not res or res == "":
@@ -671,7 +691,7 @@ class Dialog(ABC):
671
691
  return node.team, DialogState.START, res, node.team
672
692
  else:
673
693
  print("-> node team -> continua")
674
- self.__work_memory.append({"role": "system", "content": node.text})
694
+ self.__work_memory.append({"role": "user", "content": node.text})
675
695
  print("-> node team -> envia:", query)
676
696
  text = self.team_inquiry(node.team, query, node.tool, False)
677
697
 
@@ -685,6 +705,7 @@ class Dialog(ABC):
685
705
  print("!!!!!!!!!!!!!!!!!!!!!!!> Otro tipo de nodo:", node.text)
686
706
 
687
707
  res = self.__ai_service.generate(self.__work_memory)
708
+ res = self.get_text(res)
688
709
  self.__work_memory.append({"role": "system", "content": res})
689
710
 
690
711
  # Check if res is empty
@@ -34,26 +34,27 @@ class DialogState:
34
34
  #------------------------------------------
35
35
 
36
36
  class Node:
37
- def __init__(self, performative, text=None, is_terminal=False):
37
+ def __init__(self, actor, performative, text=None, is_terminal=False):
38
+ self.actor = actor
38
39
  self.performative = performative # Se asigna el ID del objeto (en str)
39
40
  self.text = text
40
41
  self.is_terminal = is_terminal
41
42
  self.children = []
42
43
 
43
44
  class ActionNode(Node):
44
- def __init__(self, performative, text, action=None, team=None, tool=None, is_terminal=False):
45
- super().__init__(performative=performative, text=text, is_terminal=is_terminal)
45
+ def __init__(self, actor, performative, text, action=None, team=None, tool=None, is_terminal=False):
46
+ super().__init__(actor, performative=performative, text=text, is_terminal=is_terminal)
46
47
  self.action = action
47
48
  self.team = team
48
49
  self.tool = tool
49
50
 
50
51
  class DeclarativeNode(Node):
51
- def __init__(self, performative, text, is_terminal=False):
52
- super().__init__(performative, text, is_terminal)
52
+ def __init__(self, actor, performative, text, is_terminal=False):
53
+ super().__init__(actor, performative, text, is_terminal)
53
54
 
54
55
  class ResponseNode(Node):
55
- def __init__(self, performative, text, is_terminal=False):
56
- super().__init__(performative=performative, text=text, is_terminal=is_terminal)
56
+ def __init__(self, actor, performative, text, is_terminal=False):
57
+ super().__init__(actor, performative=performative, text=text, is_terminal=is_terminal)
57
58
 
58
59
  #------------------------------------------
59
60
  # Define functions
@@ -143,13 +144,13 @@ def recorrer_interacciones(obj):
143
144
  # Normalizamos el valor de "tipo" (se pasa a minúsculas y se reemplaza "í" por "i")
144
145
  tipo = obj["tipo"].lower().replace("í", "i").strip()
145
146
  if tipo == "dialogo":
146
- nuevo_nodo = DeclarativeNode(performative=current_id, text=texto, is_terminal=is_terminal)
147
+ nuevo_nodo = DeclarativeNode(actor=obj["actor"], performative=current_id, text=texto, is_terminal=is_terminal)
147
148
  elif tipo == "llamada a equipo":
148
- nuevo_nodo = ActionNode(performative=current_id, text=texto, action=tipo, team=obj["equipo"], tool=obj["herramienta"], is_terminal=is_terminal)
149
+ nuevo_nodo = ActionNode(actor=obj["actor"], performative=current_id, text=texto, action=tipo, team=obj["equipo"], tool=obj["herramienta"], is_terminal=is_terminal)
149
150
  elif tipo == "respuesta de equipo":
150
- nuevo_nodo = ResponseNode(performative=current_id, text=texto, is_terminal=is_terminal)
151
+ nuevo_nodo = ResponseNode(actor=obj["actor"], performative=current_id, text=texto, is_terminal=is_terminal)
151
152
  else:
152
- nuevo_nodo = Node(performative=current_id, text=texto, is_terminal=is_terminal)
153
+ nuevo_nodo = Node(actor=obj["actor"], performative=current_id, text=texto, is_terminal=is_terminal)
153
154
 
154
155
  # Se asignan los nodos hijos construidos
155
156
  nuevo_nodo.children = children
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pbesa
3
- Version: 4.0.1
3
+ Version: 4.0.2
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.1',
7
+ version='4.0.002',
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
File without changes