pbesa 4.0.38__tar.gz → 4.0.39__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.38 → pbesa-4.0.39}/PKG-INFO +1 -1
- pbesa-4.0.39/pbesa/celulas/celula_demanda.py +56 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/cognitive.py +125 -91
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa.egg-info/PKG-INFO +1 -1
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa.egg-info/SOURCES.txt +1 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/setup.py +1 -1
- {pbesa-4.0.38 → pbesa-4.0.39}/.gitignore +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/LICENSE +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/LICENSE.txt +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/MANIFEST +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/README.md +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/db.sqlite3 +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/asgi.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/pbesa.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/settings.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/urls.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/wsgi.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/manage.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/admin.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/apps.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/models.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/tests.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/urls.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/views.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/countercontroller.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/counterdelegate.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/controller/counterresponse.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/counteragent.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/countertask.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/remote_a.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/remote_b.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/remote_c.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_casos.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_consultas.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_conversador.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_cuestionador.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_datos_identificables.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_evaluador.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_expertos.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_extraccion.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_generar_caso.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_generar_documento.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_instruccion.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_parafraseo.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_pertinencia.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_preguntas.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_respuesta.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/celula_saludos.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/data_extraction_cel.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/celulas/web.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/adapter.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/agent.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/io/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/io/system_file.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/io/tcp_server.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/res/conf.json +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/util.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/kernel/world.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/mas.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/models.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/adm_listener.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/adm_listener_handler.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/exceptions.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/remote_adm.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/remote/remote_adm_handler.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/simulator/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/simulator/dialog_simulator.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/__init__.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/collaborative_team.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/delegator.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/delegator_team.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/dialog.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/dispatcher_team.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/prompts.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/sel_dispatcher_team.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/selected_dispatcher_team.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/templates.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa/social/worker.py +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa.egg-info/dependency_links.txt +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa.egg-info/requires.txt +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/pbesa.egg-info/top_level.txt +0 -0
- {pbesa-4.0.38 → pbesa-4.0.39}/setup.cfg +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
SYSTEM_PROMPT = """
|
4
|
+
Eres un clasificador de texto altamente especializado. Tu única función es analizar un texto y responder con una de dos posibles palabras: DEMANDA o INDEFINIDO.
|
5
|
+
|
6
|
+
Al usuario se le ha hecho la siguiente pregunta: "¿Desea que le ayude con una consulta o una demanda?"
|
7
|
+
|
8
|
+
**Reglas de Clasificación:**
|
9
|
+
1. Si el texto del usuario expresa una intención clara de iniciar una demanda, clasifícalo como **DEMANDA**.
|
10
|
+
2. Para cualquier otro caso (consultas, dudas, respuestas confusas, o cualquier texto que no sea una afirmación clara de querer demandar), clasifícalo como **INDEFINIDO**.
|
11
|
+
|
12
|
+
**Formato de Respuesta Obligatorio:**
|
13
|
+
- Tu respuesta debe contener **únicamente** la palabra DEMANDA o la palabra INDEFINIDO.
|
14
|
+
- No agregues explicaciones, comentarios, puntuación ni ningún otro carácter. Tu respuesta debe ser una sola palabra.
|
15
|
+
|
16
|
+
**Ejemplos:**
|
17
|
+
- Texto: "demanda"
|
18
|
+
Respuesta: DEMANDA
|
19
|
+
|
20
|
+
- Texto: "Quiero poner una demanda"
|
21
|
+
Respuesta: DEMANDA
|
22
|
+
|
23
|
+
- Texto: "Es una consulta"
|
24
|
+
Respuesta: INDEFINIDO
|
25
|
+
|
26
|
+
- Texto: "No estoy seguro"
|
27
|
+
Respuesta: INDEFINIDO
|
28
|
+
|
29
|
+
"""
|
30
|
+
|
31
|
+
USER_PROMPT = """
|
32
|
+
|
33
|
+
Texto: "%s"
|
34
|
+
|
35
|
+
Respuesta:
|
36
|
+
|
37
|
+
"""
|
38
|
+
|
39
|
+
def derive(service, text, max_tkns=2000) -> any:
|
40
|
+
try:
|
41
|
+
tmp_work_memory = []
|
42
|
+
prompt = SYSTEM_PROMPT
|
43
|
+
tmp_work_memory.append({"role": "system", "content": prompt})
|
44
|
+
prompt = USER_PROMPT % text
|
45
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
46
|
+
res = service.generate(tmp_work_memory, max_tokens=max_tkns)
|
47
|
+
logging.info(f"\n[Celula][Saludos][Proceso]: {text}")
|
48
|
+
logging.info(f"[Celula][Saludos][Respuesta]: {res}")
|
49
|
+
if not res or res == "":
|
50
|
+
res = text
|
51
|
+
logging.warning(f"No obtener una respuesta.")
|
52
|
+
return res
|
53
|
+
except Exception as e:
|
54
|
+
logging.error(f"Error al procesar: {text}")
|
55
|
+
logging.error(e)
|
56
|
+
return None
|
@@ -29,7 +29,7 @@ from pbesa.social.dialog import (
|
|
29
29
|
from .celulas import (celula_casos, celula_consultas, celula_saludos, celula_datos_identificables,
|
30
30
|
celula_generar_documento, celula_expertos, celula_pertinencia, celula_extraccion,
|
31
31
|
celula_evaluador, celula_respuesta, celula_conversador, celula_parafraseo, celula_cuestionador,
|
32
|
-
celula_instruccion, celula_generar_caso)
|
32
|
+
celula_instruccion, celula_generar_caso, celula_demanda)
|
33
33
|
from pbesa.social.prompts import ANALIZER_PROMPT, CLASSIFICATION_PROMPT, DERIVE_PROMPT, RECOVERY_PROMPT, ADAPT_PROMPT, SINTETIZER_PROMPT
|
34
34
|
|
35
35
|
# --------------------------------------------------------
|
@@ -830,94 +830,88 @@ class Dialog(ABC):
|
|
830
830
|
msg = DialogState.ERROR
|
831
831
|
return "Web", DialogState.START, msg, "Web"
|
832
832
|
|
833
|
-
|
834
|
-
def stage_one_classification(self, session_id, messages, attemps, query):
|
835
|
-
""" Stage one classification """
|
836
|
-
res = ""
|
837
833
|
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
#es_verificacion = False
|
846
|
-
#if len(messages) >= 3:
|
847
|
-
# last_message = messages[-2]['text']
|
848
|
-
# es_verificacion = '¿Desea que le ayude con una consulta o una demanda?' in last_message
|
849
|
-
|
850
|
-
#if attemps == 2:
|
851
|
-
# saludo = "NO_SALUDO"
|
852
|
-
# consulta = celula_consultas.derive(self.__ai_service, query, max_tkns=10)
|
834
|
+
def stage_one_check(self, session_id, messages, attemps, query):
|
835
|
+
aclaracion_fired = False
|
836
|
+
for message in messages:
|
837
|
+
if not message['user'] and '¿Desea que le ayude con una consulta o una demanda?' in message['text']:
|
838
|
+
aclaracion_fired = True
|
839
|
+
break
|
840
|
+
return aclaracion_fired
|
853
841
|
|
854
|
-
|
855
|
-
|
842
|
+
def stage_one_analizer(self, session_id, messages, attemps, query):
|
843
|
+
self.__analaizer_work_memory:list = [{"role": "system", "content": ANALIZER_PROMPT}]
|
844
|
+
user_prompt = f"""
|
845
|
+
user: {query}Texto:
|
846
|
+
"%s"
|
856
847
|
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
"%s"
|
848
|
+
Respuesta:
|
849
|
+
"""
|
850
|
+
self.__analaizer_work_memory.append({"role": "user", "content": user_prompt})
|
851
|
+
|
852
|
+
logging.info("\n\n\n--------------ANALIZER------------------")
|
853
|
+
logging.info("\n%s", json.dumps(self.__analaizer_work_memory, indent=4))
|
854
|
+
logging.info("------------------------------------------\n\n\n")
|
855
|
+
res = self.__ai_service.generate(self.__analaizer_work_memory, max_tokens=50)
|
856
|
+
logging.info(f"[Stage-1][Thought]: {res}")
|
857
|
+
self.__analaizer_work_memory.append({"role": "assistant", "content": res})
|
858
|
+
self.__sintetizer_work_memory.append({"role": "assistant", "content": res})
|
859
|
+
return res
|
860
|
+
|
861
|
+
def stage_one_sintetizer(self, session_id, messages, attemps, query, es_demanda):
|
862
|
+
|
863
|
+
self.__sintetizer_work_memory:list = [{"role": "system", "content": SINTETIZER_PROMPT}]
|
874
864
|
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
865
|
+
cont = 0
|
866
|
+
for message in messages:
|
867
|
+
if message['user']:
|
868
|
+
self.__analaizer_work_memory.append({"role": "user", "content": message['text']})
|
869
|
+
|
870
|
+
if cont == 0:
|
871
|
+
msg = f"""
|
872
|
+
Texto:
|
873
|
+
"%s"
|
879
874
|
|
880
|
-
|
875
|
+
Respuesta:
|
876
|
+
""" % message['text']
|
881
877
|
else:
|
882
|
-
|
883
|
-
self.__sintetizer_work_memory.append({"role": "assistant", "content": message['text']})
|
878
|
+
msg = message['text']
|
884
879
|
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
res = self.get_text(res)
|
890
|
-
logging.info(f"[Stage-1][Sintetizer][Thought]: {res}")
|
880
|
+
self.__sintetizer_work_memory.append({"role": "user", "content": msg})
|
881
|
+
else:
|
882
|
+
self.__analaizer_work_memory.append({"role": "assistant", "content": message['text']})
|
883
|
+
self.__sintetizer_work_memory.append({"role": "assistant", "content": message['text']})
|
891
884
|
|
885
|
+
logging.info("\n\n\n--------------SINTETIZER------------------")
|
886
|
+
logging.info("\n%s", json.dumps(self.__sintetizer_work_memory, indent=4))
|
887
|
+
logging.info("\n\n\n")
|
888
|
+
res = self.__ai_service.generate(self.__sintetizer_work_memory, max_tokens=50)
|
889
|
+
res = self.get_text(res)
|
890
|
+
logging.info(f"[Stage-1][Sintetizer][Thought]: {res}")
|
891
|
+
|
892
|
+
if es_demanda:
|
893
|
+
return res
|
894
|
+
else:
|
892
895
|
consulta = celula_consultas.derive(self.__ai_service, res, max_tkns=10)
|
893
896
|
es_consulta = ("PREGUNTA_O_SOLICITUD" in consulta) and not ("NO_PREGUNTA" in consulta)
|
894
897
|
if es_consulta:
|
895
|
-
|
896
|
-
|
897
|
-
if not rectificacion_consulta == 2:
|
898
|
-
query = res
|
899
|
-
logging.info("[Stage-1][Sintetizer][Thought]: Se sustituye el query por el pensamiento.")
|
898
|
+
logging.info("[Stage-1][Sintetizer][Thought]: Se mantiene la consulta inicial.")
|
899
|
+
return query
|
900
900
|
else:
|
901
|
-
logging.info("[Stage-1][Sintetizer][Thought]: Se
|
902
|
-
|
903
|
-
else:
|
904
|
-
saludo = celula_saludos.derive(self.__ai_service, query, max_tkns=10)
|
905
|
-
consulta = celula_consultas.derive(self.__ai_service, res, max_tkns=10)
|
906
|
-
|
907
|
-
user_prompt = f"""
|
908
|
-
user: {query}Texto:
|
909
|
-
"%s"
|
910
|
-
|
911
|
-
Respuesta:
|
912
|
-
"""
|
913
|
-
self.__analaizer_work_memory.append({"role": "user", "content": user_prompt})
|
914
|
-
|
901
|
+
logging.info("[Stage-1][Sintetizer][Thought]: Se sustituye el query por el pensamiento.")
|
902
|
+
return res
|
915
903
|
|
904
|
+
def stage_one_evaluate(self, session_id, messages, attemps, query, es_demanda):
|
916
905
|
#----------------------------------
|
917
906
|
# Verifica si es una consulta o un caso
|
907
|
+
if attemps == 1:
|
908
|
+
saludo = celula_saludos.derive(self.__ai_service, query, max_tkns=10)
|
909
|
+
else:
|
910
|
+
saludo = "NO_SALUDO"
|
911
|
+
|
912
|
+
consulta = celula_consultas.derive(self.__ai_service, query, max_tkns=10)
|
918
913
|
caso = celula_casos.derive(self.__ai_service, query, max_tkns=10)
|
919
914
|
|
920
|
-
|
921
915
|
# Verifica si es un saludo, consulta o caso
|
922
916
|
es_saludo = ("SALUDO" in saludo) and not ("NO_SALUDO" in saludo)
|
923
917
|
es_consulta = ("PREGUNTA_O_SOLICITUD" in consulta) and not ("NO_PREGUNTA" in consulta)
|
@@ -929,7 +923,9 @@ class Dialog(ABC):
|
|
929
923
|
logging.info("\n-----------------------------------------------------")
|
930
924
|
|
931
925
|
eva = 0
|
926
|
+
res = None
|
932
927
|
ambiguedad = False
|
928
|
+
dicriminador = None
|
933
929
|
eva = 1 if es_saludo else 0
|
934
930
|
eva += 1 if es_consulta else 0
|
935
931
|
eva += 1 if es_caso else 0
|
@@ -976,9 +972,15 @@ class Dialog(ABC):
|
|
976
972
|
|
977
973
|
# Casos ambiguos con consulta y caso
|
978
974
|
elif es_consulta and es_caso and not es_saludo:
|
979
|
-
|
975
|
+
if es_demanda:
|
976
|
+
dicriminador = "caso"
|
977
|
+
res = query
|
978
|
+
ambiguedad = False
|
979
|
+
else:
|
980
|
+
res = "¿Desea que le ayude con una consulta o una demanda?"
|
980
981
|
else:
|
981
982
|
ambiguedad = True
|
983
|
+
query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
982
984
|
per_res = celula_pertinencia.derive(self.__ai_service, query, max_tkns=10)
|
983
985
|
if per_res and not per_res == "":
|
984
986
|
if "ABSURDO" in per_res:
|
@@ -991,34 +993,66 @@ class Dialog(ABC):
|
|
991
993
|
res = query
|
992
994
|
else:
|
993
995
|
ambiguedad = True
|
996
|
+
query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
994
997
|
per_res = celula_pertinencia.derive(self.__ai_service, query, max_tkns=10)
|
995
998
|
if per_res and not per_res == "":
|
996
999
|
if "ABSURDO" in per_res:
|
997
1000
|
dicriminador = None
|
998
1001
|
res = msg
|
999
1002
|
ambiguedad = False
|
1003
|
+
return dicriminador, ambiguedad, res
|
1000
1004
|
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1005
|
+
|
1006
|
+
def stage_one_classification(self, session_id, messages, attemps, query):
|
1007
|
+
""" Stage one classification """
|
1008
|
+
res = ""
|
1009
|
+
|
1010
|
+
dicriminador = None
|
1011
|
+
logging.info(f"------------Flujo de excepcion---------------")
|
1012
|
+
self.notify(session_id, "identificando intención...")
|
1013
|
+
logging.info(f"Intento de dialogo: {attemps}")
|
1014
|
+
|
1015
|
+
for internal_attemp in range(2):
|
1016
|
+
logging.info(f"Intento de reflexion: {internal_attemp + 1}")
|
1017
|
+
|
1018
|
+
es_demanda = False
|
1019
|
+
if len(messages) > 1:
|
1020
|
+
message = messages[-2]
|
1007
1021
|
if not message['user'] and '¿Desea que le ayude con una consulta o una demanda?' in message['text']:
|
1008
|
-
|
1022
|
+
demanda = celula_demanda.derive(self.__ai_service, query, max_tkns=10)
|
1023
|
+
es_demanda = ("DEMANDA" in demanda) and not ("INDEFINIDO" in demanda)
|
1024
|
+
if es_demanda:
|
1025
|
+
res = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
1026
|
+
dicriminador = "caso"
|
1027
|
+
return dicriminador, res
|
1028
|
+
|
1029
|
+
dicriminador, ambiguedad, res = self.stage_one_evaluate(session_id, messages, attemps, query, es_demanda)
|
1030
|
+
|
1031
|
+
if dicriminador == 'consulta':
|
1032
|
+
aclaracion_fired = self.stage_one_check(session_id, messages, attemps, query)
|
1033
|
+
if aclaracion_fired:
|
1034
|
+
new_query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
1035
|
+
if not new_query == query:
|
1036
|
+
query = new_query
|
1037
|
+
continue
|
1038
|
+
else:
|
1039
|
+
res = "¿Desea que le ayude con una consulta o una demanda?"
|
1040
|
+
dicriminador = None
|
1041
|
+
break
|
1042
|
+
|
1043
|
+
if ambiguedad:
|
1044
|
+
logging.info("[Stage-1]: Respuesta con ambiguedad")
|
1045
|
+
self.notify(session_id, "identificando ambiguedad...")
|
1046
|
+
|
1047
|
+
aclaracion_fired = self.stage_one_check(session_id, messages, attemps, query)
|
1048
|
+
if aclaracion_fired:
|
1049
|
+
query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
1050
|
+
else:
|
1051
|
+
res = "¿Desea que le ayude con una consulta o una demanda?"
|
1009
1052
|
break
|
1010
|
-
|
1011
|
-
if aclaracion_fired:
|
1012
|
-
logging.info("\n\n\n--------------ANALIZER------------------")
|
1013
|
-
logging.info("\n%s", json.dumps(self.__analaizer_work_memory, indent=4))
|
1014
|
-
logging.info("------------------------------------------\n\n\n")
|
1015
|
-
res = self.__ai_service.generate(self.__analaizer_work_memory, max_tokens=50)
|
1016
|
-
logging.info(f"[Stage-1][Thought]: {res}")
|
1017
|
-
self.__analaizer_work_memory.append({"role": "assistant", "content": res})
|
1018
|
-
self.__sintetizer_work_memory.append({"role": "assistant", "content": res})
|
1019
1053
|
else:
|
1020
|
-
|
1021
|
-
|
1054
|
+
break
|
1055
|
+
|
1022
1056
|
return dicriminador, res
|
1023
1057
|
|
1024
1058
|
def get_node(self, performative):
|
@@ -76,6 +76,7 @@ pbesa/celulas/celula_consultas.py
|
|
76
76
|
pbesa/celulas/celula_conversador.py
|
77
77
|
pbesa/celulas/celula_cuestionador.py
|
78
78
|
pbesa/celulas/celula_datos_identificables.py
|
79
|
+
pbesa/celulas/celula_demanda.py
|
79
80
|
pbesa/celulas/celula_evaluador.py
|
80
81
|
pbesa/celulas/celula_expertos.py
|
81
82
|
pbesa/celulas/celula_extraccion.py
|
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.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/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
|
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/translatetask.py
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/workeragent.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
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.38 → pbesa-4.0.39}/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
|
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
|