pbesa 4.0.5__tar.gz → 4.0.6__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.
- {pbesa-4.0.5 → pbesa-4.0.6}/PKG-INFO +3 -2
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/cognitive.py +278 -186
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/dispatcher_team.py +1 -1
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/worker.py +3 -3
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa.egg-info/PKG-INFO +3 -2
- {pbesa-4.0.5 → pbesa-4.0.6}/setup.py +1 -1
- {pbesa-4.0.5 → pbesa-4.0.6}/.gitignore +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/LICENSE +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/LICENSE.txt +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/MANIFEST +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/README.md +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/db.sqlite3 +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/asgi.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/pbesa.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/settings.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/urls.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/wsgi.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/manage.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/admin.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/apps.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/models.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/tests.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/urls.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/views.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/countercontroller.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/counterdelegate.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/controller/counterresponse.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/counteragent.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/countertask.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/remote_a.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/remote_b.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/remote_c.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/adapter.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/agent.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/io/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/io/system_file.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/io/tcp_server.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/res/conf.json +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/util.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/kernel/world.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/mas.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/models.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/adm_listener.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/adm_listener_handler.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/exceptions.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/remote_adm.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/remote/remote_adm_handler.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/__init__.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/collaborative_team.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/delegator.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/delegator_team.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/dialog.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/prompts.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/selected_dispatcher_team.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa/social/templates.py +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa.egg-info/SOURCES.txt +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa.egg-info/dependency_links.txt +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa.egg-info/requires.txt +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/pbesa.egg-info/top_level.txt +0 -0
- {pbesa-4.0.5 → pbesa-4.0.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: pbesa
|
3
|
-
Version: 4.0.
|
3
|
+
Version: 4.0.6
|
4
4
|
License-File: LICENSE
|
5
5
|
License-File: LICENSE.txt
|
6
6
|
Requires-Dist: pymongo==4.6.3
|
@@ -8,3 +8,4 @@ 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
|
@@ -468,6 +468,15 @@ class Dialog(ABC):
|
|
468
468
|
self.__deep_limit = 3
|
469
469
|
# Define knowledge
|
470
470
|
self.knowledge = None
|
471
|
+
# Define point recovery
|
472
|
+
self.__recovery = {
|
473
|
+
"owner": "Web",
|
474
|
+
"team": "Web",
|
475
|
+
"performative": DialogState.START,
|
476
|
+
"counter": 0
|
477
|
+
}
|
478
|
+
# Define recovery message
|
479
|
+
self.RECOVERY_MSG = "Lo lamento, puedes darme más detalles o reformular"
|
471
480
|
|
472
481
|
def setup_world(self):
|
473
482
|
""" Set up model method """
|
@@ -561,223 +570,306 @@ class Dialog(ABC):
|
|
561
570
|
self.__work_memory = []
|
562
571
|
# Set up model
|
563
572
|
self.setup_world()
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
573
|
+
# Reset dialog state
|
574
|
+
self.__recovery = {
|
575
|
+
"owner": "Web",
|
576
|
+
"team": "Web",
|
577
|
+
"performative": DialogState.START,
|
578
|
+
"counter": 0
|
579
|
+
}
|
580
|
+
|
581
|
+
def notify(self, text):
|
582
|
+
try:
|
583
|
+
canales = self.state['canales']
|
584
|
+
canal = canales.get("Webhook")
|
585
|
+
session_id = self.state['session_id']
|
570
586
|
dto = {
|
571
|
-
"
|
572
|
-
|
573
|
-
'operation': operation
|
574
|
-
},
|
587
|
+
"session_id": session_id,
|
588
|
+
"text": text[0:100]
|
575
589
|
}
|
576
|
-
|
577
|
-
if
|
578
|
-
logging.info(f"
|
579
|
-
logging.info(f"------------RESET--------------- {data}")
|
580
|
-
self.reset()
|
581
|
-
return data
|
582
|
-
|
590
|
+
response = canal.post("notify", dto)
|
591
|
+
if response['status']:
|
592
|
+
logging.info(f"Notificación enviada: {text}")
|
583
593
|
else:
|
594
|
+
logging.warning(f"Notificación no enviada: {text}")
|
595
|
+
except Exception as e:
|
596
|
+
logging.error(f"Error al enviar notificación: {text}")
|
597
|
+
logging.erro(f"Error: {e}")
|
598
|
+
|
599
|
+
def team_inquiry(self, team, data, operation, session_flag) -> str:
|
600
|
+
try:
|
601
|
+
dto = None
|
602
|
+
canales = self.state['canales']
|
603
|
+
canal = canales.get(team)
|
604
|
+
if session_flag:
|
584
605
|
dto = {
|
585
606
|
"data": {
|
586
|
-
'text': data
|
607
|
+
'text': data,
|
608
|
+
'session_id': self.state['session_id'],
|
587
609
|
},
|
588
610
|
}
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
611
|
+
# Evia mensaje a los agentes remotos
|
612
|
+
logging.info('>>>> Call remote agent: team.\n')
|
613
|
+
response = canal.post(team.lower(), dto)
|
614
|
+
if response and not response['status']:
|
615
|
+
logging.error(f'No se pudo establecer la comunicación con el agente remoto')
|
616
|
+
return None
|
617
|
+
logging.info(f'>>>> Response: {response}')
|
618
|
+
return response['message']['response']
|
619
|
+
else:
|
620
|
+
if operation:
|
621
|
+
dto = {
|
622
|
+
"data": {
|
623
|
+
'text': data,
|
624
|
+
'operation': operation
|
625
|
+
},
|
626
|
+
}
|
627
|
+
else:
|
628
|
+
dto = {
|
629
|
+
"data": {
|
630
|
+
'text': data
|
631
|
+
},
|
632
|
+
}
|
633
|
+
response = canal.post(team.lower(), dto)
|
634
|
+
if response['status']:
|
635
|
+
return response['message']['response']
|
636
|
+
else:
|
637
|
+
return None
|
638
|
+
logging.info("END: team_inquiry")
|
639
|
+
except Exception as e:
|
640
|
+
logging.error(f"Error al consultar al equipo: {team}")
|
641
|
+
return None
|
606
642
|
|
607
|
-
|
608
|
-
if
|
609
|
-
|
610
|
-
|
643
|
+
def get_text(self, mensaje) -> str:
|
644
|
+
if mensaje:
|
645
|
+
mensaje_limpio = mensaje.replace("<|im_start|>user<|im_sep|>", "").replace("<|im_start|>system<|im_sep|>", "")
|
646
|
+
mensaje_limpio = mensaje_limpio.replace("<|im_start|>", "").replace("<|im_sep|>", "").replace("<|im_end|>", "")
|
647
|
+
mensaje_limpio = mensaje_limpio.replace("[Usuario]: ", "").replace("[Sistema]: ", "")
|
648
|
+
return mensaje_limpio.strip()
|
649
|
+
else:
|
650
|
+
return ""
|
651
|
+
|
652
|
+
def recovery(self, query):
|
653
|
+
try:
|
611
654
|
prompt = RECOVERY_PROMPT % query
|
612
|
-
temp_work_memory = [{"role": "user", "content":
|
655
|
+
temp_work_memory = [{"role": "user", "content": prompt}]
|
613
656
|
res = self.__ai_service.generate(temp_work_memory)
|
614
657
|
res = self.get_text(res)
|
615
|
-
|
658
|
+
if res and not res == "":
|
659
|
+
return self.__recovery['owner'], self.__recovery['performative'], res, self.__recovery['team']
|
660
|
+
else:
|
661
|
+
logging.info(f"------------RESET---------------")
|
662
|
+
logging.info(f"Recovery from: {self.__recovery['performative']}")
|
663
|
+
self.reset()
|
664
|
+
self.notify("STOP")
|
665
|
+
return "Web", DialogState.START, self.RECOVERY_MSG, "Web"
|
666
|
+
except Exception as e:
|
667
|
+
return self.RECOVERY_MSG
|
616
668
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
self.
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
select_node =
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
669
|
+
def transition(self, owner, dialog_state, query, team_source=False) -> str:
|
670
|
+
try:
|
671
|
+
res = ""
|
672
|
+
logging.info(f"TOPTQ: {owner} - {dialog_state} - {team_source} - {query}")
|
673
|
+
# Punto de restauración
|
674
|
+
counter = (self.__recovery['counter'] + 1) if self.__recovery['performative'] == dialog_state else self.__recovery['counter']
|
675
|
+
self.__recovery = {
|
676
|
+
"owner": owner,
|
677
|
+
"team": owner,
|
678
|
+
"performative": dialog_state,
|
679
|
+
"counter": counter
|
680
|
+
}
|
681
|
+
logging.info(f"Recovery attemps: {self.__recovery["counter"]}")
|
682
|
+
# Verifica si se ha alcanzado el límite de recuperación
|
683
|
+
if self.__recovery['counter'] <= 3:
|
684
|
+
self.notify("identificando la performativa...")
|
685
|
+
# Verifica que exista la performativa
|
686
|
+
if not dialog_state in self.__dfa:
|
687
|
+
self.notify("performativa no encontrada")
|
688
|
+
return self.recovery(query)
|
689
|
+
# Performativa encontrada
|
690
|
+
children = None
|
691
|
+
self.notify("performativa encontrada")
|
692
|
+
node = self.__dfa[dialog_state]
|
693
|
+
if not isinstance(node, list):
|
694
|
+
children = node.children
|
695
|
+
else:
|
696
|
+
children = node
|
697
|
+
# Flujo de selección
|
698
|
+
select_node = None
|
699
|
+
self.notify("flujo de seleccion...")
|
700
|
+
if children and len(children)> 1:
|
701
|
+
logging.info(f"--> Más de una opción.")
|
702
|
+
options = ""
|
703
|
+
cont = 1
|
704
|
+
for item in children:
|
705
|
+
options += f"{cont}) {item.text}\n"
|
706
|
+
cont += 1
|
707
|
+
prompt = CLASSIFICATION_PROMPT % (query, options)
|
708
|
+
logging.info(f"Query: {query},\n Options:\n{options}")
|
709
|
+
self.__meta_work_memory.append({"role": "user", "content": prompt})
|
710
|
+
res = self.__ai_service.generate(self.__meta_work_memory)
|
711
|
+
logging.info(f"Thought: {res}")
|
712
|
+
self.__meta_work_memory = []
|
713
|
+
res = self.get_text(res)
|
714
|
+
for option in range(1, cont):
|
715
|
+
if str(option) in res:
|
716
|
+
select_node = children[option-1]
|
717
|
+
logging.info(f"Select node: {select_node.text}")
|
718
|
+
break
|
719
|
+
if not select_node:
|
720
|
+
logging.info("=> No se seleccionó ninguna opción")
|
721
|
+
select_node = children[0]
|
722
|
+
logging.info(f"=> Selecciona el primer nodo: {select_node.text}")
|
723
|
+
elif children and len(children) == 1:
|
724
|
+
logging.info(f"--> Una opción.")
|
725
|
+
select_node = children[0]
|
726
|
+
else:
|
727
|
+
logging.info(f"???????????????????> text: {res} es terminal")
|
728
|
+
# Nuevo nodo
|
729
|
+
if select_node:
|
730
|
+
res = select_node.text
|
731
|
+
node = select_node.children[0]
|
732
|
+
# Nodo seleccionado
|
733
|
+
logging.info(f"Flujo normal: {res}")
|
734
|
+
self.notify(res)
|
735
|
+
if team_source:
|
736
|
+
self.__work_memory.append({"role": "user", "content": res})
|
737
|
+
else:
|
738
|
+
self.__work_memory.append({"role": "user", "content": query})
|
739
|
+
self.__work_memory.append({"role": "user", "content": res})
|
740
|
+
# Efectua inferencia
|
741
|
+
new_owner, new_dialog_state, res, team = self.do_transition(owner, node, query)
|
742
|
+
res = self.get_text(res)
|
743
|
+
return new_owner, new_dialog_state, res, team
|
744
|
+
else:
|
745
|
+
logging.info(f"------------RESET---------------")
|
746
|
+
self.notify("STOP")
|
747
|
+
self.reset()
|
748
|
+
return "Web", DialogState.START, self.RECOVERY_MSG, "Web"
|
749
|
+
logging.info("END: do_transition")
|
750
|
+
except Exception as e:
|
751
|
+
traceback.print_exc()
|
652
752
|
logging.info(f"------------RESET---------------")
|
653
753
|
self.reset()
|
654
|
-
|
655
|
-
|
656
|
-
return owner, DialogState.START, text, owner
|
657
|
-
|
658
|
-
# Flujo normal
|
659
|
-
logging.info(f"Flujo normal: {select_node.text}")
|
660
|
-
if team_source:
|
661
|
-
self.__work_memory.append({"role": "user", "content": select_node.text})
|
662
|
-
else:
|
663
|
-
self.__work_memory.append({"role": "user", "content": query})
|
664
|
-
self.__work_memory.append({"role": "user", "content": select_node.text})
|
665
|
-
new_owner, new_dialog_state, text, team = self.do_transition(owner, select_node.children[0], query)
|
666
|
-
text = self.get_text(text)
|
667
|
-
return new_owner, new_dialog_state, text, team
|
754
|
+
self.notify("STOP")
|
755
|
+
return owner, DialogState.START, "Lo lamento, no puedo responder en este momento", owner
|
668
756
|
|
669
757
|
def do_transition(self, owner, node, query) -> str:
|
670
758
|
""" Generate method
|
671
759
|
:return: str
|
672
|
-
"""
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
elif isinstance(node, ActionNode):
|
677
|
-
|
678
|
-
#------------------------------
|
679
|
-
# Accion
|
680
|
-
#------------------------------
|
681
|
-
|
682
|
-
logging.info(f"-> node action: {node.action}")
|
683
|
-
if node.tool and not node.tool == "Ninguno":
|
684
|
-
logging.info(f"-> node tool: {node.tool}")
|
685
|
-
self.__work_memory.append({"role": "user", "content": node.text})
|
686
|
-
logging.info("-----")
|
687
|
-
logging.info("\n%s", json.dumps(self.__work_memory, indent=4))
|
688
|
-
logging.info("-----")
|
689
|
-
res = self.__ai_service.generate(self.__work_memory)
|
690
|
-
logging.info(f"-> node tool: {res}")
|
691
|
-
res = self.get_text(res)
|
692
|
-
# Check if res is empty
|
693
|
-
if not res or res == "":
|
694
|
-
logging.info("1 -> res vacio")
|
695
|
-
res = "Lo lamento, no puedo responder en este momento"
|
696
|
-
|
697
|
-
logging.info(f"------------RESET---------------")
|
698
|
-
self.reset()
|
699
|
-
|
700
|
-
return owner, DialogState.START, res, owner
|
701
|
-
logging.info(f"-> node tool: envia -> {res}")
|
702
|
-
text = self.team_inquiry(node.team, res, node.tool, False)
|
703
|
-
else:
|
760
|
+
"""
|
761
|
+
try:
|
762
|
+
if isinstance(node, ActionNode):
|
763
|
+
self.notify("realizando acción...")
|
704
764
|
#------------------------------
|
705
|
-
#
|
765
|
+
# Accion
|
706
766
|
#------------------------------
|
707
|
-
logging.info(f"-> node
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
logging.info(f"-> node team -> es terminal -> {node.text}")
|
767
|
+
logging.info(f"-> node action: {node.action}")
|
768
|
+
if node.tool and not node.tool == "Ninguno":
|
769
|
+
self.notify("aplicando herramienta...")
|
770
|
+
logging.info(f"-> node tool: {node.tool}")
|
712
771
|
self.__work_memory.append({"role": "user", "content": node.text})
|
713
772
|
logging.info("-----")
|
714
773
|
logging.info("\n%s", json.dumps(self.__work_memory, indent=4))
|
715
|
-
logging.info("-----")
|
774
|
+
logging.info("-----")
|
716
775
|
res = self.__ai_service.generate(self.__work_memory)
|
776
|
+
logging.info(f"-> node tool: {res}")
|
717
777
|
res = self.get_text(res)
|
718
|
-
self.__work_memory.append({"role": "system", "content": res})
|
719
778
|
# Check if res is empty
|
720
779
|
if not res or res == "":
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
return owner, DialogState.START, res, owner
|
726
|
-
logging.info(f"-> node team -> envia: {res}")
|
727
|
-
text = self.team_inquiry(node.team, res, None, True)
|
728
|
-
return node.team, DialogState.START, res, node.team
|
780
|
+
self.notify("no pude hacer uso de la herramienta")
|
781
|
+
return self.recovery(query)
|
782
|
+
logging.info(f"-> node tool: envia -> {res}")
|
783
|
+
res = self.team_inquiry(node.team, res, node.tool, False)
|
729
784
|
else:
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
785
|
+
self.notify("realizando llamada...")
|
786
|
+
#------------------------------
|
787
|
+
# Lllamada
|
788
|
+
#------------------------------
|
789
|
+
logging.info(f"-> node team: {node.team}")
|
790
|
+
# Verifica si el nodo es termianl ya que significa
|
791
|
+
# que el dialogo cambia de agente
|
792
|
+
if node.is_terminal:
|
793
|
+
logging.info(f"-> node team -> es terminal -> {node.text}")
|
794
|
+
self.__work_memory.append({"role": "user", "content": node.text})
|
795
|
+
logging.info("-----")
|
796
|
+
logging.info("\n%s", json.dumps(self.__work_memory, indent=4))
|
797
|
+
logging.info("-----")
|
798
|
+
res = self.__ai_service.generate(self.__work_memory)
|
799
|
+
res = self.get_text(res)
|
800
|
+
self.__work_memory.append({"role": "system", "content": res})
|
801
|
+
# Check if res is empty
|
802
|
+
if not res or res == "":
|
803
|
+
self.notify(f"no pude contactar al agente: {node.team}")
|
804
|
+
return self.recovery(query)
|
805
|
+
self.notify(f"le envio al agente {node.team}: {res}")
|
806
|
+
logging.info(f"-> node team -> envia: {res}")
|
807
|
+
res = self.team_inquiry(node.team, res, None, True)
|
808
|
+
if res and not res == "ERROR" and not res == "":
|
809
|
+
logging.info(f"------------RESET---------------")
|
810
|
+
self.reset()
|
811
|
+
self.notify("STOP")
|
812
|
+
return node.team, DialogState.START, res, node.team
|
813
|
+
else:
|
814
|
+
return self.recovery(query)
|
815
|
+
else:
|
816
|
+
logging.info("-> node team -> continua")
|
817
|
+
self.__work_memory.append({"role": "user", "content": node.text})
|
818
|
+
logging.info(f"-> node team -> envia: {query}")
|
819
|
+
res = self.team_inquiry(node.team, query, node.tool, False)
|
820
|
+
self.notify(f"continuando con díalogo")
|
821
|
+
# Adiciona el texto al work memory
|
822
|
+
if res and not res == "ERROR" and not res == "":
|
823
|
+
logging.info(f"-> Adicion WM node team -> text: {res}")
|
824
|
+
self.__work_memory.append({"role": "system", "content": res})
|
825
|
+
else:
|
826
|
+
return self.recovery(query)
|
827
|
+
logging.info("#########> Procesa respuesta del equipo en profundidad")
|
828
|
+
# Verifica si se alcanzó el límite de profundidad
|
829
|
+
self.__deep_count += 1
|
830
|
+
if self.__deep_count < self.__deep_limit:
|
831
|
+
self.notify("efectuando inferencia en profundidad")
|
832
|
+
return self.transition(owner, node.performative, res, True)
|
833
|
+
else:
|
834
|
+
self.notify(f"se alcanzó el límite de profundidad: {self.__deep_count}")
|
835
|
+
self.__deep_count = 0
|
836
|
+
logging.info("-> node team -> deep limit")
|
837
|
+
logging.info(f"------------RESET---------------")
|
838
|
+
self.notify("STOP")
|
839
|
+
self.reset()
|
840
|
+
return "Web", DialogState.START, self.RECOVERY_MSG, "Web"
|
741
841
|
else:
|
742
|
-
self.
|
743
|
-
logging.info("-> node
|
744
|
-
|
745
|
-
logging.info(f"
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
842
|
+
self.notify("efectuando inferencia...")
|
843
|
+
logging.info(f"D -> node: {node.text}")
|
844
|
+
self.__work_memory.append({"role": "user", "content": node.text})
|
845
|
+
logging.info(f"=> !!!!: {query}")
|
846
|
+
logging.info("-----")
|
847
|
+
logging.info("\n%s", json.dumps(self.__work_memory, indent=4))
|
848
|
+
logging.info("-----")
|
849
|
+
res = self.__ai_service.generate(self.__work_memory)
|
850
|
+
res = self.get_text(res)
|
851
|
+
self.__work_memory.append({"role": "system", "content": res})
|
852
|
+
# Check if res is empty
|
853
|
+
if not res or res == "":
|
854
|
+
return self.recovery(query)
|
855
|
+
logging.info(f"=> Thought DEEP: {res}")
|
856
|
+
self.notify(f"Realizando inferencia: {res}")
|
857
|
+
new_dialog_state = node.performative
|
858
|
+
if not node.is_terminal:
|
859
|
+
self.notify(f"continuando díalogo de inferencia")
|
860
|
+
return owner, new_dialog_state, res, owner
|
861
|
+
self.notify(f"finalizando díalogo de inferencia")
|
862
|
+
logging.info(f"Tipe node: {type(node)}")
|
863
|
+
logging.info(f"$$$> new_owner: {owner} new_dialog_state: {new_dialog_state}")
|
864
|
+
self.notify("STOP")
|
865
|
+
return owner, new_dialog_state, res, owner
|
866
|
+
logging.info("END: do_transition")
|
867
|
+
except Exception as e:
|
868
|
+
traceback.print_exc()
|
764
869
|
logging.info(f"------------RESET---------------")
|
765
870
|
self.reset()
|
766
|
-
|
767
|
-
|
768
|
-
return owner, DialogState.START, res, owner
|
769
|
-
|
770
|
-
logging.info(f"=> Thought DEEP: {res}")
|
771
|
-
|
772
|
-
new_dialog_state = node.performative
|
773
|
-
if not node.is_terminal:
|
774
|
-
logging.info(f"=> new_owner: {owner} new_dialog_state: {new_dialog_state}")
|
775
|
-
return owner, new_dialog_state, res, owner
|
776
|
-
|
777
|
-
logging.info(f"Tipe node: {type(node)}")
|
778
|
-
|
779
|
-
logging.info(f"$$$> new_owner: {owner} new_dialog_state: {new_dialog_state}")
|
780
|
-
return owner, new_dialog_state, res, owner
|
871
|
+
self.notify("STOP")
|
872
|
+
return owner, DialogState.START, "Lo lamento, no puedo responder en este momento", owner
|
781
873
|
|
782
874
|
def set_knowledge(self, knowledge) -> str:
|
783
875
|
""" Set knowledge method
|
@@ -57,18 +57,18 @@ class TimeoutAction(Action):
|
|
57
57
|
""" Execute the action
|
58
58
|
@param data: Event data
|
59
59
|
"""
|
60
|
-
logging.
|
60
|
+
logging.debug(f"[TimeoutAction][{self.agent.id}]: Execute {data}")
|
61
61
|
if data['command'] == 'start':
|
62
62
|
if not self.agent.is_timeout():
|
63
63
|
self.agent.set_timeout(True)
|
64
64
|
self.__timer = Timer(data['time'], self.handler)
|
65
65
|
self.__timer.start()
|
66
|
-
logging.
|
66
|
+
logging.debug(f"[TimeoutAction][{self.agent.id}]: Timer started")
|
67
67
|
else:
|
68
68
|
if self.__timer:
|
69
69
|
self.__timer.cancel()
|
70
70
|
self.__timer = None
|
71
|
-
logging.
|
71
|
+
logging.debug(f"[TimeoutAction][{self.agent.id}]: Timer stopped")
|
72
72
|
|
73
73
|
# --------------------------------------------------------
|
74
74
|
# Define Task Action
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: pbesa
|
3
|
-
Version: 4.0.
|
3
|
+
Version: 4.0.6
|
4
4
|
License-File: LICENSE
|
5
5
|
License-File: LICENSE.txt
|
6
6
|
Requires-Dist: pymongo==4.6.3
|
@@ -8,3 +8,4 @@ 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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/translatedelegate.py
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/controller/translateresponse.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/django/helloworld/translate/mas/worker/translatetask.py
RENAMED
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
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.5 → pbesa-4.0.6}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc
RENAMED
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
|
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
|