pbesa 4.0.8__tar.gz → 4.0.10__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.8 → pbesa-4.0.10}/PKG-INFO +1 -1
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/__init__.py +2 -1
- pbesa-4.0.10/pbesa/celulas/__init__.py +3 -0
- pbesa-4.0.10/pbesa/celulas/celula_casos.py +60 -0
- pbesa-4.0.10/pbesa/celulas/celula_consultas.py +45 -0
- pbesa-4.0.10/pbesa/celulas/celula_saludos.py +41 -0
- pbesa-4.0.10/pbesa/celulas/web.py +49 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/cognitive.py +119 -51
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa.egg-info/PKG-INFO +1 -1
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa.egg-info/SOURCES.txt +5 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/setup.py +1 -1
- {pbesa-4.0.8 → pbesa-4.0.10}/.gitignore +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/LICENSE +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/LICENSE.txt +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/MANIFEST +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/README.md +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/db.sqlite3 +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/asgi.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/pbesa.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/settings.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/urls.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/wsgi.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/manage.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/admin.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/apps.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/models.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/tests.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/urls.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/views.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/countercontroller.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/counterdelegate.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/controller/counterresponse.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/counteragent.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/countertask.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/remote_a.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/remote_b.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/remote_c.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/adapter.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/agent.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/io/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/io/system_file.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/io/tcp_server.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/res/conf.json +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/util.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/kernel/world.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/mas.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/models.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/adm_listener.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/adm_listener_handler.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/exceptions.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/remote_adm.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/remote/remote_adm_handler.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/__init__.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/collaborative_team.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/delegator.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/delegator_team.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/dialog.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/dispatcher_team.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/prompts.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/selected_dispatcher_team.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/templates.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa/social/worker.py +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa.egg-info/dependency_links.txt +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa.egg-info/requires.txt +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/pbesa.egg-info/top_level.txt +0 -0
- {pbesa-4.0.8 → pbesa-4.0.10}/setup.cfg +0 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
PROMPT = """
|
4
|
+
Eres un clasificador que identifica si un texto corresponde a una queja o demanda que debe ser radicada ante un ente de control del Estado colombiano.
|
5
|
+
|
6
|
+
Responde únicamente con:
|
7
|
+
- QUEJA_DEMANDA
|
8
|
+
- NO_QUEJA_DEMANDA
|
9
|
+
|
10
|
+
**Definición de QUEJA_DEMANDA**: El texto describe hechos, situaciones o infracciones por parte de una empresa, entidad o persona que pueden requerir la intervención de entidades como:
|
11
|
+
|
12
|
+
- Superintendencia de Sociedades
|
13
|
+
- Superintendencia de Industria y Comercio
|
14
|
+
- Supersalud
|
15
|
+
- Dirección General Marítima
|
16
|
+
- Superintendencia Financiera de Colombia
|
17
|
+
- Instituto Colombiano Agropecuario (ICA)
|
18
|
+
- Dirección Nacional de Derecho de Autor
|
19
|
+
- Autoridades de protección al consumidor
|
20
|
+
- Casos de competencia desleal o propiedad industrial
|
21
|
+
|
22
|
+
**NO_QUEJA_DEMANDA**: El texto no describe una inconformidad, infracción ni intención de denuncia. Puede ser una pregunta, saludo, comentario o solicitud de orientación.
|
23
|
+
|
24
|
+
---
|
25
|
+
|
26
|
+
**Ejemplos:**
|
27
|
+
|
28
|
+
1. "Quiero presentar una denuncia contra la empresa Colmédica por incumplimiento en la prestación de servicios de salud." → QUEJA_DEMANDA
|
29
|
+
2. "La empresa Navemar ha incurrido en prácticas marítimas irregulares y omisión de protocolos de seguridad." → QUEJA_DEMANDA
|
30
|
+
3. "Explícame cómo radicar una queja" → NO_QUEJA_DEMANDA
|
31
|
+
4. "Hola, buen día" → NO_QUEJA_DEMANDA
|
32
|
+
5. "Evacol S.A.S. está copiando diseños registrados de Crocs Inc. y aprovechando su reputación." → QUEJA_DEMANDA
|
33
|
+
6. "¿Dónde puedo radicar una demanda?" → NO_QUEJA_DEMANDA
|
34
|
+
7. "El supermercado está vendiendo productos vencidos que afectaron mi salud." → QUEJA_DEMANDA
|
35
|
+
8. "Necesito orientación sobre propiedad industrial" → NO_QUEJA_DEMANDA
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
Texto: "%s"
|
40
|
+
|
41
|
+
Clasificación:
|
42
|
+
"""
|
43
|
+
|
44
|
+
# Efectua la inferencia del modelo.
|
45
|
+
def derive(service, text) -> any:
|
46
|
+
try:
|
47
|
+
logging.info(f"Procesando: {text}")
|
48
|
+
tmp_work_memory = []
|
49
|
+
prompt = PROMPT % text
|
50
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
51
|
+
res = service.generate(tmp_work_memory)
|
52
|
+
logging.info(f"Respuesta: {res}")
|
53
|
+
if not res or res == "":
|
54
|
+
res = text
|
55
|
+
logging.warning(f"No obtener una respuesta.")
|
56
|
+
return res
|
57
|
+
except Exception as e:
|
58
|
+
logging.error(f"Error al procesar: {text}")
|
59
|
+
logging.error(e)
|
60
|
+
return None
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
PROMPT = """
|
4
|
+
Eres un clasificador de intenciones. Tu tarea es analizar el siguiente texto y determinar si representa una **pregunta** o **solicitud de información**.
|
5
|
+
|
6
|
+
Responde solo con:
|
7
|
+
- PREGUNTA_O_SOLICITUD
|
8
|
+
- NO_PREGUNTA
|
9
|
+
|
10
|
+
**Definiciones:**
|
11
|
+
- **PREGUNTA_O_SOLICITUD**: El texto expresa claramente una intención de obtener información, ya sea mediante una pregunta directa ("¿Qué hora es?") o una solicitud indirecta ("Quisiera saber el estado del pedido").
|
12
|
+
- **NO_PREGUNTA**: El texto no busca información. Puede ser un saludo, afirmación, comentario, instrucción, etc.
|
13
|
+
|
14
|
+
**Ejemplos:**
|
15
|
+
1. "¿Cuál es el horario de atención?" → PREGUNTA_O_SOLICITUD
|
16
|
+
2. "Necesito saber cómo ingresar al sistema" → PREGUNTA_O_SOLICITUD
|
17
|
+
3. "Hola, buen día" → NO_PREGUNTA
|
18
|
+
4. "Ya envié el informe" → NO_PREGUNTA
|
19
|
+
5. "¿Me puedes confirmar la dirección?" → PREGUNTA_O_SOLICITUD
|
20
|
+
6. "Saludos" → NO_PREGUNTA
|
21
|
+
7. "Explícame cómo hacerlo" → PREGUNTA_O_SOLICITUD
|
22
|
+
8. "No tengo acceso" → NO_PREGUNTA
|
23
|
+
|
24
|
+
Texto: "%s"
|
25
|
+
|
26
|
+
Clasificación:
|
27
|
+
"""
|
28
|
+
|
29
|
+
# Efectua la inferencia del modelo.
|
30
|
+
def derive(service, text) -> any:
|
31
|
+
try:
|
32
|
+
logging.info(f"Procesando: {text}")
|
33
|
+
tmp_work_memory = []
|
34
|
+
prompt = PROMPT % text
|
35
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
36
|
+
res = service.generate(tmp_work_memory)
|
37
|
+
logging.info(f"Respuesta: {res}")
|
38
|
+
if not res or res == "":
|
39
|
+
res = text
|
40
|
+
logging.warning(f"No obtener una respuesta.")
|
41
|
+
return res
|
42
|
+
except Exception as e:
|
43
|
+
logging.error(f"Error al procesar: {text}")
|
44
|
+
logging.error(e)
|
45
|
+
return None
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
PROMPT = """
|
4
|
+
Eres un clasificador de saludos. Tu tarea es analizar el siguiente texto y determinar si es un saludo.
|
5
|
+
|
6
|
+
Responde únicamente con una de estas opciones:
|
7
|
+
- SALUDO
|
8
|
+
- NO_SALUDO
|
9
|
+
|
10
|
+
**Definición de saludo**: Un saludo es cualquier forma de cortesía o expresión inicial utilizada para iniciar una conversación. Esto incluye "Hola", "Buenos días", "Qué tal", "Ey", "Saludos", etc., incluso si van acompañados de una pregunta o comentario breve. No se consideran saludos las preguntas o afirmaciones que van directo al contenido sin intención de cortesía.
|
11
|
+
|
12
|
+
Ejemplos:
|
13
|
+
- "Hola, ¿cómo estás?" → SALUDO
|
14
|
+
- "Buenos días, equipo" → SALUDO
|
15
|
+
- "¿Cómo se hace este análisis?" → NO_SALUDO
|
16
|
+
- "Ey, qué más" → SALUDO
|
17
|
+
- "Necesito ayuda con el código" → NO_SALUDO
|
18
|
+
- "Saludos" → SALUDO
|
19
|
+
|
20
|
+
Texto: "%s"
|
21
|
+
|
22
|
+
Clasificación:
|
23
|
+
"""
|
24
|
+
|
25
|
+
# Efectua la inferencia del modelo.
|
26
|
+
def derive(service, text) -> any:
|
27
|
+
try:
|
28
|
+
logging.info(f"Procesando: {text}")
|
29
|
+
tmp_work_memory = []
|
30
|
+
prompt = PROMPT % text
|
31
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
32
|
+
res = service.generate(tmp_work_memory)
|
33
|
+
logging.info(f"Respuesta: {res}")
|
34
|
+
if not res or res == "":
|
35
|
+
res = text
|
36
|
+
logging.warning(f"No obtener una respuesta.")
|
37
|
+
return res
|
38
|
+
except Exception as e:
|
39
|
+
logging.error(f"Error al procesar: {text}")
|
40
|
+
logging.error(e)
|
41
|
+
return None
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
PROMPT = """
|
4
|
+
Eres un clasificador de intenciones de texto. Debes analizar el texto proporcionado y clasificarlo en una de las siguientes categorías:
|
5
|
+
|
6
|
+
1. SALUDO: El texto contiene un saludo inicial como "hola", "buen día", "buenas tardes", "qué tal", "saludos", etc.
|
7
|
+
2. PREGUNTA_O_SOLICITUD: El texto busca obtener información, ya sea mediante una pregunta directa ("¿Qué hora es?") o una solicitud indirecta ("Necesito saber cómo ingresar").
|
8
|
+
3. QUEJA_DEMANDA: El texto describe una inconformidad o denuncia que debe ser radicada ante un ente de control estatal, como la Superintendencia de Industria y Comercio, Supersalud, ICA, Dirección Nacional de Derecho de Autor, etc.
|
9
|
+
4. NINGUNA: El texto no encaja en ninguna de las categorías anteriores.
|
10
|
+
|
11
|
+
Responde solo con una de estas cuatro categorías, en mayúsculas.
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
**Ejemplos:**
|
16
|
+
|
17
|
+
- "Hola, buen día" → SALUDO
|
18
|
+
- "¿Dónde puedo radicar una queja?" → PREGUNTA_O_SOLICITUD
|
19
|
+
- "Quiero demandar a una empresa que está usando mi marca registrada" → QUEJA_DEMANDA
|
20
|
+
- "Ya envié el documento que solicitaste" → NINGUNA
|
21
|
+
- "Explícame cómo hacerlo" → PREGUNTA_O_SOLICITUD
|
22
|
+
- "Evacol S.A.S. está copiando diseños de Crocs Inc. para confundir a los consumidores" → QUEJA_DEMANDA
|
23
|
+
- "Saludos cordiales" → SALUDO
|
24
|
+
- "Estoy confirmando la reunión de mañana" → NINGUNA
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
Texto: "%s"
|
29
|
+
|
30
|
+
Clasificación:
|
31
|
+
"""
|
32
|
+
|
33
|
+
# Efectua la inferencia del modelo.
|
34
|
+
def derive(service, text) -> any:
|
35
|
+
try:
|
36
|
+
logging.info(f"Procesando: {text}")
|
37
|
+
tmp_work_memory = []
|
38
|
+
prompt = PROMPT % text
|
39
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
40
|
+
res = service.generate(tmp_work_memory)
|
41
|
+
logging.info(f"Respuesta: {res}")
|
42
|
+
if not res or res == "":
|
43
|
+
res = text
|
44
|
+
logging.warning(f"No obtener una respuesta.")
|
45
|
+
return res
|
46
|
+
except Exception as e:
|
47
|
+
logging.error(f"Error al procesar: {text}")
|
48
|
+
logging.error(e)
|
49
|
+
return None
|
@@ -21,6 +21,7 @@ from .mas import Adm
|
|
21
21
|
from pydantic import BaseModel
|
22
22
|
from typing import List, Optional
|
23
23
|
from abc import ABC, abstractmethod
|
24
|
+
from .celulas import celula_casos, celula_consultas, celula_saludos
|
24
25
|
from pbesa.models import AIFoundry, AzureInference, GPTService, ServiceProvider
|
25
26
|
from pbesa.social.dialog import (
|
26
27
|
DialogState, imprimir_grafo, recorrer_interacciones, extraer_diccionario_nodos,
|
@@ -702,59 +703,126 @@ class Dialog(ABC):
|
|
702
703
|
}
|
703
704
|
logging.info(f"Recovery attemps: {self.__recovery["counter"]}")
|
704
705
|
# Verifica si se ha alcanzado el límite de recuperación
|
705
|
-
if self.__recovery['counter'] <= 3 and self.__visited_nodes <= 3:
|
706
|
-
self.notify("identificando concepto...")
|
707
|
-
#--------------------------
|
708
|
-
# Verifica que exista la performativa
|
709
|
-
if not dialog_state in self.__dfa:
|
710
|
-
self.notify("concepto no encontrado")
|
711
|
-
return self.recovery(query)
|
712
|
-
# Performativa encontrada
|
713
|
-
children = None
|
714
|
-
self.notify("concepto encontrado")
|
715
|
-
#--------------------------
|
716
|
-
# Obtiene los hijos del nodo
|
717
|
-
node = self.__dfa[dialog_state]
|
718
|
-
if not isinstance(node, list):
|
719
|
-
children = node.children
|
720
|
-
else:
|
721
|
-
# Es una lista de nodos
|
722
|
-
children = node
|
723
|
-
#--------------------------
|
724
|
-
# Flujo de selección
|
706
|
+
if self.__recovery['counter'] <= 3 and self.__visited_nodes <= 3:
|
725
707
|
select_node = None
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
self.
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
708
|
+
#------------------------------
|
709
|
+
# Flujode de excepcion
|
710
|
+
#------------------------------
|
711
|
+
if owner == "Web" and dialog_state == DialogState.START:
|
712
|
+
logging.info(f"TOPTQ: {owner} - {dialog_state} - {team_source} - {query}")
|
713
|
+
logging.info(f"------------Flujo de excepcion---------------")
|
714
|
+
self.notify("identificando intencion...")
|
715
|
+
# Obtiene discriminadores
|
716
|
+
caso = celula_casos.derive(self.__ai_service, query)
|
717
|
+
consulta = celula_consultas.derive(self.__ai_service, query)
|
718
|
+
saludo = celula_saludos.derive(self.__ai_service, query)
|
719
|
+
# Verifica si es un saludo
|
720
|
+
es_saludo = ("SALUDO" in saludo) and ("NO_PREGUNTA" in consulta) and ("NO_QUEJA_DEMANDA" in caso)
|
721
|
+
es_consulta = ("PREGUNTA_O_SOLICITUD" in consulta) and ("NO_QUEJA_DEMANDA" in caso) and ("NO_SALUDO" in saludo)
|
722
|
+
es_caso = ("QUEJA_DEMANDA" in caso) and ("NO_PREGUNTA" in consulta) and ("NO_SALUDO" in saludo)
|
723
|
+
logging.info(f"==> Saludo: {saludo}, Consulta: {consulta}, Caso: {caso}")
|
724
|
+
logging.info(f"==> Es saludo: {es_saludo}, Es consulta: {es_consulta}, Es caso: {es_caso}")
|
725
|
+
# Verifica los casos
|
726
|
+
dicriminador = "Ninguno"
|
727
|
+
if es_saludo or es_consulta or es_caso:
|
728
|
+
logging.info("Respuesta Clara")
|
729
|
+
self.notify("discriminando...")
|
730
|
+
if es_saludo:
|
731
|
+
dicriminador = "saluda"
|
732
|
+
elif es_consulta:
|
733
|
+
dicriminador = "consulta"
|
734
|
+
elif es_caso:
|
735
|
+
dicriminador = "caso"
|
736
|
+
else:
|
737
|
+
logging.info("Respuesta con ambiguedad")
|
738
|
+
self.notify("identificando ambiguedad...")
|
739
|
+
if caso == "QUEJA_DEMANDA":
|
740
|
+
dicriminador = "caso"
|
741
|
+
elif consulta == "PREGUNTA_O_SOLICITUD":
|
742
|
+
dicriminador = "consulta"
|
743
|
+
elif saludo == "SALUDO":
|
744
|
+
dicriminador = "saluda"
|
745
|
+
#--------------------------
|
746
|
+
# Obtiene los hijos del
|
747
|
+
# nodo
|
748
|
+
children = None
|
749
|
+
node = self.__dfa[dialog_state]
|
750
|
+
if not isinstance(node, list):
|
751
|
+
children = node.children
|
752
|
+
else:
|
753
|
+
# Es una lista de nodos
|
754
|
+
children = node
|
755
|
+
#--------------------------
|
756
|
+
# Flujo de selección
|
757
|
+
self.notify("flujo de seleccion...")
|
758
|
+
if children and len(children)> 1:
|
759
|
+
logging.info(f"--> Más de una opción.")
|
760
|
+
options = ""
|
761
|
+
cont = 1
|
762
|
+
for item in children:
|
763
|
+
if dicriminador in item.text:
|
764
|
+
select_node = item
|
765
|
+
break
|
766
|
+
else:
|
767
|
+
#------------------------------
|
768
|
+
# Fulo normal
|
769
|
+
#------------------------------
|
770
|
+
logging.info("Flujo normal")
|
771
|
+
self.notify("identificando concepto...")
|
772
|
+
#----------------------
|
773
|
+
# Verifica que exista
|
774
|
+
# la performativa
|
775
|
+
if not dialog_state in self.__dfa:
|
776
|
+
self.notify("concepto no encontrado")
|
777
|
+
return self.recovery(query)
|
778
|
+
# Performativa encontrada
|
779
|
+
children = None
|
780
|
+
self.notify("concepto encontrado")
|
781
|
+
#----------------------
|
782
|
+
# Obtiene los hijos del
|
783
|
+
# nodo
|
784
|
+
node = self.__dfa[dialog_state]
|
785
|
+
if not isinstance(node, list):
|
786
|
+
children = node.children
|
787
|
+
else:
|
788
|
+
# Es una lista de nodos
|
789
|
+
children = node
|
790
|
+
#----------------------
|
791
|
+
# Flujo de selección
|
792
|
+
select_node = None
|
793
|
+
self.notify("flujo de seleccion...")
|
794
|
+
if children and len(children)> 1:
|
795
|
+
logging.info(f"--> Más de una opción.")
|
796
|
+
options = ""
|
797
|
+
cont = 1
|
798
|
+
for item in children:
|
799
|
+
options += f"{cont}) {item.text}\n"
|
800
|
+
cont += 1
|
801
|
+
prompt = CLASSIFICATION_PROMPT % (query, options)
|
802
|
+
logging.info(f"Query: {query},\n Options:\n{options}")
|
803
|
+
self.__meta_work_memory.append({"role": "user", "content": prompt})
|
804
|
+
res = self.__ai_service.generate(self.__meta_work_memory)
|
805
|
+
logging.info(f"Thought: {res}")
|
806
|
+
self.__meta_work_memory = []
|
807
|
+
res = self.get_text(res)
|
808
|
+
for option in range(1, cont):
|
809
|
+
if str(option) in res:
|
810
|
+
select_node = children[option-1]
|
811
|
+
logging.info(f"Select node: {select_node.text}")
|
812
|
+
break
|
813
|
+
if not select_node:
|
814
|
+
logging.info("=> No se seleccionó ninguna opción")
|
815
|
+
select_node = children[0]
|
816
|
+
logging.info(f"=> Selecciona el primer nodo: {select_node.text}")
|
817
|
+
elif children and len(children) == 1:
|
818
|
+
logging.info(f"--> Una opción.")
|
748
819
|
select_node = children[0]
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
logging.warning(f"???> Es un nodo terminal o iniciador: {node.text}")
|
756
|
-
logging.warning(f"???> Es un nodo terminal o iniciador: {node.performative}")
|
757
|
-
return self.recovery(query)
|
820
|
+
else:
|
821
|
+
logging.info("???> Es un nodo terminal o iniciador")
|
822
|
+
logging.warning(f"???> Es un nodo terminal o iniciador: {node.text}")
|
823
|
+
logging.warning(f"???> Es un nodo terminal o iniciador: {node.performative}")
|
824
|
+
return self.recovery(query)
|
825
|
+
|
758
826
|
#--------------------------
|
759
827
|
# Verifica si es un nodo
|
760
828
|
# que ya fue recorrido
|
@@ -70,6 +70,11 @@ pbesa.egg-info/SOURCES.txt
|
|
70
70
|
pbesa.egg-info/dependency_links.txt
|
71
71
|
pbesa.egg-info/requires.txt
|
72
72
|
pbesa.egg-info/top_level.txt
|
73
|
+
pbesa/celulas/__init__.py
|
74
|
+
pbesa/celulas/celula_casos.py
|
75
|
+
pbesa/celulas/celula_consultas.py
|
76
|
+
pbesa/celulas/celula_saludos.py
|
77
|
+
pbesa/celulas/web.py
|
73
78
|
pbesa/kernel/__init__.py
|
74
79
|
pbesa/kernel/adapter.py
|
75
80
|
pbesa/kernel/agent.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.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/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.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/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.8 → pbesa-4.0.10}/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.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.8 → pbesa-4.0.10}/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
|