pbesa 4.0.37__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.37 → pbesa-4.0.39}/PKG-INFO +1 -1
- pbesa-4.0.39/pbesa/celulas/celula_demanda.py +56 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/cognitive.py +132 -79
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa.egg-info/PKG-INFO +1 -1
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa.egg-info/SOURCES.txt +1 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/setup.py +1 -1
- {pbesa-4.0.37 → pbesa-4.0.39}/.gitignore +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/LICENSE +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/LICENSE.txt +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/MANIFEST +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/README.md +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/db.sqlite3 +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/asgi.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/pbesa.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/settings.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/urls.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/wsgi.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/manage.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/admin.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/apps.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/models.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/tests.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/urls.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/views.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/countercontroller.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/counterdelegate.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/controller/counterresponse.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/counteragent.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/countertask.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/remote_a.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/remote_b.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/remote_c.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_casos.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_consultas.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_conversador.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_cuestionador.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_datos_identificables.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_evaluador.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_expertos.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_extraccion.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_generar_caso.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_generar_documento.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_instruccion.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_parafraseo.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_pertinencia.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_preguntas.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_respuesta.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/celula_saludos.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/data_extraction_cel.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/celulas/web.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/adapter.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/agent.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/io/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/io/system_file.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/io/tcp_server.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/res/conf.json +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/util.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/kernel/world.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/mas.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/models.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/adm_listener.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/adm_listener_handler.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/exceptions.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/remote_adm.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/remote/remote_adm_handler.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/simulator/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/simulator/dialog_simulator.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/__init__.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/collaborative_team.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/delegator.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/delegator_team.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/dialog.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/dispatcher_team.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/prompts.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/sel_dispatcher_team.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/selected_dispatcher_team.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/templates.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa/social/worker.py +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa.egg-info/dependency_links.txt +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa.egg-info/requires.txt +0 -0
- {pbesa-4.0.37 → pbesa-4.0.39}/pbesa.egg-info/top_level.txt +0 -0
- {pbesa-4.0.37 → 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,85 +830,89 @@ class Dialog(ABC):
|
|
830
830
|
msg = DialogState.ERROR
|
831
831
|
return "Web", DialogState.START, msg, "Web"
|
832
832
|
|
833
|
-
|
834
|
-
def
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
833
|
+
|
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
|
841
|
+
|
842
|
+
def stage_one_analizer(self, session_id, messages, attemps, query):
|
844
843
|
self.__analaizer_work_memory:list = [{"role": "system", "content": ANALIZER_PROMPT}]
|
844
|
+
user_prompt = f"""
|
845
|
+
user: {query}Texto:
|
846
|
+
"%s"
|
847
|
+
|
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):
|
845
862
|
|
846
|
-
|
847
|
-
if len(messages) >= 3:
|
848
|
-
last_message = messages[-2]['text']
|
849
|
-
es_verificacion = '¿Desea que le ayude con una consulta o una demanda?' in last_message
|
850
|
-
|
851
|
-
if attemps > 1 and not es_verificacion:
|
852
|
-
saludo = "NO_SALUDO"
|
853
|
-
elif attemps > 2 or es_verificacion:
|
854
|
-
|
855
|
-
saludo = "NO_SALUDO"
|
856
|
-
self.__sintetizer_work_memory:list = [{"role": "system", "content": SINTETIZER_PROMPT}]
|
857
|
-
|
858
|
-
cont = 0
|
859
|
-
for message in messages:
|
860
|
-
if message['user']:
|
861
|
-
self.__analaizer_work_memory.append({"role": "user", "content": message['text']})
|
862
|
-
|
863
|
-
if cont == 0:
|
864
|
-
msg = f"""
|
865
|
-
Texto:
|
866
|
-
"%s"
|
863
|
+
self.__sintetizer_work_memory:list = [{"role": "system", "content": SINTETIZER_PROMPT}]
|
867
864
|
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
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"
|
872
874
|
|
873
|
-
|
875
|
+
Respuesta:
|
876
|
+
""" % message['text']
|
874
877
|
else:
|
875
|
-
|
876
|
-
self.__sintetizer_work_memory.append({"role": "assistant", "content": message['text']})
|
878
|
+
msg = message['text']
|
877
879
|
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
# conversacion, se utiliza el sintentizador
|
883
|
-
logging.info("\n\n\n--------------SINTETIZER------------------")
|
884
|
-
logging.info("\n%s", json.dumps(self.__sintetizer_work_memory, indent=4))
|
885
|
-
logging.info("\n\n\n")
|
886
|
-
query = self.__ai_service.generate(self.__sintetizer_work_memory, max_tokens=50)
|
887
|
-
res = self.get_text(query)
|
888
|
-
query = res
|
889
|
-
logging.info(f"[Stage-1][Sintetizer][Thought]: {query}")
|
890
|
-
else:
|
891
|
-
saludo = celula_saludos.derive(self.__ai_service, query, max_tkns=10)
|
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']})
|
892
884
|
|
893
|
-
|
894
|
-
|
895
|
-
|
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}")
|
896
891
|
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
892
|
+
if es_demanda:
|
893
|
+
return res
|
894
|
+
else:
|
895
|
+
consulta = celula_consultas.derive(self.__ai_service, res, max_tkns=10)
|
896
|
+
es_consulta = ("PREGUNTA_O_SOLICITUD" in consulta) and not ("NO_PREGUNTA" in consulta)
|
897
|
+
if es_consulta:
|
898
|
+
logging.info("[Stage-1][Sintetizer][Thought]: Se mantiene la consulta inicial.")
|
899
|
+
return query
|
900
|
+
else:
|
901
|
+
logging.info("[Stage-1][Sintetizer][Thought]: Se sustituye el query por el pensamiento.")
|
902
|
+
return res
|
901
903
|
|
904
|
+
def stage_one_evaluate(self, session_id, messages, attemps, query, es_demanda):
|
902
905
|
#----------------------------------
|
903
906
|
# Verifica si es una consulta o un caso
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
+
if attemps == 1:
|
908
|
+
saludo = celula_saludos.derive(self.__ai_service, query, max_tkns=10)
|
909
|
+
else:
|
910
|
+
saludo = "NO_SALUDO"
|
907
911
|
|
908
|
-
|
909
|
-
|
910
|
-
#es_caso = ("QUEJA_DEMANDA" in caso) and ("NO_PREGUNTA" in consulta) and ("NO_SALUDO" in saludo) and not ("NO_QUEJA_DEMANDA" in caso)
|
912
|
+
consulta = celula_consultas.derive(self.__ai_service, query, max_tkns=10)
|
913
|
+
caso = celula_casos.derive(self.__ai_service, query, max_tkns=10)
|
911
914
|
|
915
|
+
# Verifica si es un saludo, consulta o caso
|
912
916
|
es_saludo = ("SALUDO" in saludo) and not ("NO_SALUDO" in saludo)
|
913
917
|
es_consulta = ("PREGUNTA_O_SOLICITUD" in consulta) and not ("NO_PREGUNTA" in consulta)
|
914
918
|
es_caso = ("QUEJA_DEMANDA" in caso) and not ("NO_QUEJA_DEMANDA" in caso)
|
@@ -919,7 +923,9 @@ class Dialog(ABC):
|
|
919
923
|
logging.info("\n-----------------------------------------------------")
|
920
924
|
|
921
925
|
eva = 0
|
926
|
+
res = None
|
922
927
|
ambiguedad = False
|
928
|
+
dicriminador = None
|
923
929
|
eva = 1 if es_saludo else 0
|
924
930
|
eva += 1 if es_consulta else 0
|
925
931
|
eva += 1 if es_caso else 0
|
@@ -966,9 +972,15 @@ class Dialog(ABC):
|
|
966
972
|
|
967
973
|
# Casos ambiguos con consulta y caso
|
968
974
|
elif es_consulta and es_caso and not es_saludo:
|
969
|
-
|
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?"
|
970
981
|
else:
|
971
982
|
ambiguedad = True
|
983
|
+
query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
972
984
|
per_res = celula_pertinencia.derive(self.__ai_service, query, max_tkns=10)
|
973
985
|
if per_res and not per_res == "":
|
974
986
|
if "ABSURDO" in per_res:
|
@@ -981,25 +993,66 @@ class Dialog(ABC):
|
|
981
993
|
res = query
|
982
994
|
else:
|
983
995
|
ambiguedad = True
|
996
|
+
query = self.stage_one_sintetizer(session_id, messages, attemps, query, es_demanda)
|
984
997
|
per_res = celula_pertinencia.derive(self.__ai_service, query, max_tkns=10)
|
985
998
|
if per_res and not per_res == "":
|
986
999
|
if "ABSURDO" in per_res:
|
987
1000
|
dicriminador = None
|
988
1001
|
res = msg
|
989
1002
|
ambiguedad = False
|
1003
|
+
return dicriminador, ambiguedad, res
|
990
1004
|
|
991
|
-
if ambiguedad:
|
992
|
-
logging.info("[Stage-1]: Respuesta con ambiguedad")
|
993
|
-
self.notify(session_id, "identificando ambiguedad...")
|
994
|
-
logging.info("\n\n\n--------------ANALIZER------------------")
|
995
|
-
logging.info("\n%s", json.dumps(self.__analaizer_work_memory, indent=4))
|
996
|
-
logging.info("------------------------------------------\n\n\n")
|
997
|
-
res = self.__ai_service.generate(self.__analaizer_work_memory, max_tokens=50)
|
998
|
-
logging.info(f"[Stage-1][Thought]: {res}")
|
999
|
-
self.__analaizer_work_memory.append({"role": "assistant", "content": res})
|
1000
|
-
self.__sintetizer_work_memory.append({"role": "assistant", "content": res})
|
1001
|
-
#----------------------------------
|
1002
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]
|
1021
|
+
if not message['user'] and '¿Desea que le ayude con una consulta o una demanda?' in message['text']:
|
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?"
|
1052
|
+
break
|
1053
|
+
else:
|
1054
|
+
break
|
1055
|
+
|
1003
1056
|
return dicriminador, res
|
1004
1057
|
|
1005
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.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → 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.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → 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.37 → pbesa-4.0.39}/examples/django/helloworld/translate/mas/worker/translatetask.py
RENAMED
File without changes
|
{pbesa-4.0.37 → 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.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → pbesa-4.0.39}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.37 → 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
|