pbesa 4.0.29__tar.gz → 4.0.31__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.29 → pbesa-4.0.31}/PKG-INFO +1 -1
- pbesa-4.0.31/pbesa/celulas/celula_cuestionador.py +62 -0
- pbesa-4.0.31/pbesa/celulas/celula_generar_caso.py +58 -0
- pbesa-4.0.31/pbesa/celulas/celula_instruccion.py +57 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/cognitive.py +29 -7
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa.egg-info/PKG-INFO +1 -1
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa.egg-info/SOURCES.txt +3 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/setup.py +1 -1
- {pbesa-4.0.29 → pbesa-4.0.31}/.gitignore +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/LICENSE +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/LICENSE.txt +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/MANIFEST +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/README.md +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/db.sqlite3 +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/settings.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/wsgi.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/asgi.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/pbesa.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/settings.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/urls.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/wsgi.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/manage.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/views.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/admin.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/apps.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/translatecontroller.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/translatedelegate.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/controller/translateresponse.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/worker/translatetask.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/worker/workeragent.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/migrations/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/migrations/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/models.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/tests.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/urls.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/views.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/countercontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/counterdelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/counterresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/translatecontroller.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/translatedelegate.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/__pycache__/translateresponse.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/countercontroller.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/counterdelegate.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/controller/counterresponse.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/workeragent.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/counteragent.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/countertask.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/remote_a.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/remote_b.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/remote_c.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_casos.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_consultas.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_conversador.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_datos_identificables.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_evaluador.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_expertos.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_extraccion.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_generar_documento.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_parafraseo.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_pertinencia.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_preguntas.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_respuesta.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_saludos.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/celula_simulador_ciudadano.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/data_extraction_cel.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/celulas/web.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/adapter.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/agent.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/io/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/io/system_file.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/io/tcp_server.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/__pycache__/__init__.cpython-36.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/__pycache__/__init__.cpython-37.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/__pycache__/__init__.cpython-38.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/__pycache__/__init__.cpython-39.pyc +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/res/conf.json +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/util.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/kernel/world.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/mas.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/models.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/adm_listener.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/adm_listener_handler.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/exceptions.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/remote_adm.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/remote/remote_adm_handler.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/__init__.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/collaborative_team.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/delegator.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/delegator_team.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/dialog.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/dispatcher_team.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/prompts.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/selected_dispatcher_team.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/templates.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa/social/worker.py +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa.egg-info/dependency_links.txt +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa.egg-info/requires.txt +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/pbesa.egg-info/top_level.txt +0 -0
- {pbesa-4.0.29 → pbesa-4.0.31}/setup.cfg +0 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
SYSTEM_PROMPT = """
|
4
|
+
Eres un agente cognitivo que simula ser un usuario. Tu tarea es convertir un texto o una idea en una pregunta clara y natural.
|
5
|
+
|
6
|
+
Analiza el texto proporcionado y genera una pregunta que un usuario haría para obtener más información, resolver un problema o iniciar una conversación sobre ese tema.
|
7
|
+
|
8
|
+
Si el texto es demasiado corto, vago o no contiene suficiente información para formular una pregunta coherente, responde únicamente con la palabra: FALTA.
|
9
|
+
|
10
|
+
**Instrucciones:**
|
11
|
+
1. La pregunta debe estar directamente relacionada con el contenido del texto.
|
12
|
+
2. Formula la pregunta desde la perspectiva de un usuario.
|
13
|
+
3. Si el texto ya es una pregunta, mejórala o reformúlala para que suene más natural si es posible. Si ya es una buena pregunta, puedes usarla tal cual.
|
14
|
+
|
15
|
+
**Ejemplos:**
|
16
|
+
- Texto: "El rendimiento de la base de datos ha disminuido después de la última actualización."
|
17
|
+
Pregunta generada: "¿Por qué ha disminuido el rendimiento de la base de datos después de la última actualización y cómo podemos solucionarlo?"
|
18
|
+
|
19
|
+
- Texto: "Necesito configurar el acceso VPN para un nuevo empleado."
|
20
|
+
Pregunta generada: "¿Cuáles son los pasos para configurar una nueva cuenta de VPN para un empleado?"
|
21
|
+
|
22
|
+
- Texto: "Error al compilar el proyecto en Java."
|
23
|
+
Pregunta generada: "Estoy recibiendo un error al compilar mi proyecto en Java, ¿alguien puede ayudarme a identificar la causa?"
|
24
|
+
|
25
|
+
- Texto: "informe"
|
26
|
+
Pregunta generada: FALTA
|
27
|
+
|
28
|
+
- Texto: "no funciona"
|
29
|
+
Pregunta generada: FALTA
|
30
|
+
|
31
|
+
- Texto: "la reunión de ayer"
|
32
|
+
Pregunta generada: "¿Podrían compartir un resumen o las notas de la reunión de ayer?"
|
33
|
+
|
34
|
+
"""
|
35
|
+
|
36
|
+
USER_PROMPT = """
|
37
|
+
|
38
|
+
Texto: "%s"
|
39
|
+
|
40
|
+
Pregunta generada:
|
41
|
+
|
42
|
+
"""
|
43
|
+
|
44
|
+
# Efectua la inferencia del modelo.
|
45
|
+
def derive(service, text, max_tkns=2000) -> any:
|
46
|
+
try:
|
47
|
+
tmp_work_memory = []
|
48
|
+
prompt = SYSTEM_PROMPT
|
49
|
+
tmp_work_memory.append({"role": "system", "content": prompt})
|
50
|
+
prompt = USER_PROMPT % text
|
51
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
52
|
+
res = service.generate(tmp_work_memory, max_tokens=max_tkns)
|
53
|
+
logging.info(f"\n\n\nProcesando:texto: {text}")
|
54
|
+
logging.info(f"Respuesta: {res}")
|
55
|
+
if not res or res == "":
|
56
|
+
res = text
|
57
|
+
logging.warning(f"No obtener una respuesta.")
|
58
|
+
return res
|
59
|
+
except Exception as e:
|
60
|
+
logging.error(f"Error al procesar: {text}")
|
61
|
+
logging.error(e)
|
62
|
+
return None
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
SYSTEM_PROMPT = """
|
4
|
+
Eres un generador de casos legales simulados para un agente cognitivo. Tu tarea es crear un escenario realista que involucre al menos una de las **funciones jurisdiccionales** de las siguientes entidades colombianas: **SIC (Superintendencia de Industria y Comercio)**, **DNDA (Dirección Nacional de Derecho de Autor)**, **DIMAR (Dirección General Marítima)**, **ICA (Instituto Colombiano Agropecuario)**, **SFC (Superintendencia Financiera de Colombia)**, **SNS (Superintendencia Nacional de Salud)** y **Supersociedades (Superintendencia de Sociedades)**. El caso debe estar enmarcado dentro del **Código General del Proceso (Ley 1564 de 2012)**.
|
5
|
+
|
6
|
+
Se te proporcionarán **definiciones clave** y **reglas específicas** que debes seguir. Tu caso simulado debe simular la perspectiva de un usuario afectado, describiendo una situación que cumpla con al menos una de las reglas establecidas, de forma que justifique la intervención jurisdiccional de una de las entidades.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**DEFINICIONES CLAVE:**
|
11
|
+
%s
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
**REGLAS PARA LA GENERACIÓN DEL CASO:**
|
16
|
+
%s
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
**FORMATO DE SALIDA:**
|
21
|
+
|
22
|
+
Se conciso y directo. El caso debe tener menos de 100 palabras.
|
23
|
+
|
24
|
+
Simula la descripción del caso desde la perspectiva de la persona afectada, incluyendo los detalles necesarios para comprender la situación y la entidad jurisdiccional que debería intervenir.
|
25
|
+
|
26
|
+
**Ejemplo de salida esperada (si la regla 1 fuera "Problema con la garantía de un electrodoméstico"):**
|
27
|
+
|
28
|
+
"Mi nombre es Laura y hace tres meses compré una nevera de última generación en la tienda 'ElectroHogar S.A.'. La nevera dejó de enfriar la semana pasada, y al contactar a la tienda para hacer valer la garantía, me informaron que la falla no está cubierta por 'mal uso', a pesar de que seguí todas las instrucciones del manual."
|
29
|
+
---
|
30
|
+
|
31
|
+
"""
|
32
|
+
|
33
|
+
USER_PROMPT = """
|
34
|
+
|
35
|
+
Ahora, genera un caso simulado que cumpla con al menos una de las reglas anteriores.
|
36
|
+
|
37
|
+
Respuesta:
|
38
|
+
"""
|
39
|
+
|
40
|
+
# Efectua la inferencia del modelo.
|
41
|
+
def derive(service, definiciones, reglas, max_tkns=2000) -> any:
|
42
|
+
try:
|
43
|
+
tmp_work_memory = []
|
44
|
+
prompt = SYSTEM_PROMPT % (definiciones, reglas)
|
45
|
+
tmp_work_memory.append({"role": "system", "content": prompt})
|
46
|
+
prompt = USER_PROMPT
|
47
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
48
|
+
res = service.generate(tmp_work_memory, max_tokens=max_tkns)
|
49
|
+
logging.info(f"\n\n\nProcesando:texto: {definiciones}")
|
50
|
+
logging.info(f"Respuesta: {res}")
|
51
|
+
if not res or res == "":
|
52
|
+
res = definiciones
|
53
|
+
logging.warning(f"No obtener una respuesta.")
|
54
|
+
return res
|
55
|
+
except Exception as e:
|
56
|
+
logging.error(f"Error al procesar: {definiciones}")
|
57
|
+
logging.error(e)
|
58
|
+
return None
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
SYSTEM_PROMPT = """
|
4
|
+
Eres un asistente conversacional diseñado para responder directamente a la instrucción proporcionada por el usuario. Tu objetivo es interpretar la instrucción y generar una respuesta concisa y apropiada, simulando ser un usuario o agente que cumple la orden.
|
5
|
+
|
6
|
+
Si la instrucción no es clara o no se puede cumplir directamente con una respuesta simple, debes pedir más información o indicar que la instrucción no es suficiente.
|
7
|
+
|
8
|
+
Ejemplos:
|
9
|
+
- Instrucción: "Saluda"
|
10
|
+
Respuesta: "¡Hola! ¿Cómo estás?"
|
11
|
+
|
12
|
+
- Instrucción: "Di 'Adiós'"
|
13
|
+
Respuesta: "Adiós"
|
14
|
+
|
15
|
+
- Instrucción: "Pregunta la hora"
|
16
|
+
Respuesta: "¿Qué hora es?"
|
17
|
+
|
18
|
+
- Instrucción: "Agradece"
|
19
|
+
Respuesta: "¡Muchas gracias!"
|
20
|
+
|
21
|
+
- Instrucción: "Pide que te expliquen un tema"
|
22
|
+
Respuesta: "¿Podrías explicarme más sobre este tema?"
|
23
|
+
|
24
|
+
- Instrucción: "Haz un resumen de un libro"
|
25
|
+
Respuesta: "Necesito el nombre del libro para poder hacer un resumen."
|
26
|
+
|
27
|
+
- Instrucción: "Dime qué piensas del clima"
|
28
|
+
Respuesta: "No tengo opiniones sobre el clima, soy una inteligencia artificial."
|
29
|
+
|
30
|
+
"""
|
31
|
+
|
32
|
+
USER_PROMPT = """
|
33
|
+
|
34
|
+
Instrucción: "%s"
|
35
|
+
|
36
|
+
Respuesta:
|
37
|
+
"""
|
38
|
+
|
39
|
+
# Efectua la inferencia del modelo.
|
40
|
+
def derive(service, text, max_tkns=2000) -> any:
|
41
|
+
try:
|
42
|
+
tmp_work_memory = []
|
43
|
+
prompt = SYSTEM_PROMPT
|
44
|
+
tmp_work_memory.append({"role": "system", "content": prompt})
|
45
|
+
prompt = USER_PROMPT % text
|
46
|
+
tmp_work_memory.append({"role": "user", "content": prompt})
|
47
|
+
res = service.generate(tmp_work_memory, max_tokens=max_tkns)
|
48
|
+
logging.info(f"\n\n\nProcesando:texto: {text}")
|
49
|
+
logging.info(f"Respuesta: {res}")
|
50
|
+
if not res or res == "":
|
51
|
+
res = text
|
52
|
+
logging.warning(f"No obtener una respuesta.")
|
53
|
+
return res
|
54
|
+
except Exception as e:
|
55
|
+
logging.error(f"Error al procesar: {text}")
|
56
|
+
logging.error(e)
|
57
|
+
return None
|
@@ -28,7 +28,8 @@ from pbesa.social.dialog import (
|
|
28
28
|
ActionNode, DeclarativeNode, GotoNode)
|
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
|
-
celula_evaluador, celula_respuesta, celula_conversador, celula_parafraseo
|
31
|
+
celula_evaluador, celula_respuesta, celula_conversador, celula_parafraseo, celula_cuestionador,
|
32
|
+
celula_instruccion, celula_generar_caso, celula_simulador_ciudadano)
|
32
33
|
from pbesa.social.prompts import ANALIZER_PROMPT, CLASSIFICATION_PROMPT, DERIVE_PROMPT, RECOVERY_PROMPT, ADAPT_PROMPT, SINTETIZER_PROMPT
|
33
34
|
|
34
35
|
# --------------------------------------------------------
|
@@ -588,6 +589,7 @@ class Dialog(ABC):
|
|
588
589
|
self.rules = None
|
589
590
|
self.__q_attemps = 0
|
590
591
|
|
592
|
+
|
591
593
|
def setup_world(self):
|
592
594
|
""" Set up model method """
|
593
595
|
# Define role
|
@@ -833,10 +835,16 @@ class Dialog(ABC):
|
|
833
835
|
|
834
836
|
self.__analaizer_work_memory:list = [{"role": "system", "content": ANALIZER_PROMPT}]
|
835
837
|
|
838
|
+
es_verificacion = False
|
839
|
+
if len(messages) >= 3:
|
840
|
+
last_message = messages[-2]['text']
|
841
|
+
es_verificacion = '¿Desea que le ayude con una consulta o una demanda?' in last_message
|
836
842
|
|
837
|
-
if attemps > 1:
|
843
|
+
if attemps > 1 and not es_verificacion:
|
844
|
+
saludo = "NO_SALUDO"
|
845
|
+
elif attemps > 2 or es_verificacion:
|
846
|
+
|
838
847
|
saludo = "NO_SALUDO"
|
839
|
-
|
840
848
|
self.__sintetizer_work_memory:list = [{"role": "system", "content": SINTETIZER_PROMPT}]
|
841
849
|
|
842
850
|
cont = 0
|
@@ -1493,6 +1501,14 @@ class Dialog(ABC):
|
|
1493
1501
|
return celula_consultas.derive(self.__ai_service, query, max_tkns=10)
|
1494
1502
|
if command == "EVALUAR_CONSULTA":
|
1495
1503
|
return celula_parafraseo.derive(self.__ai_service, self.special_knowledge, query, max_tkns=max_tkns)
|
1504
|
+
if command == "GENERAR_PREGUNTA":
|
1505
|
+
return celula_cuestionador.derive(self.__ai_service, query, max_tkns=max_tkns)
|
1506
|
+
if command == "INSTRUCCION":
|
1507
|
+
return celula_instruccion.derive(self.__ai_service, query, max_tkns=max_tkns)
|
1508
|
+
if command == "GENERAR_CASO":
|
1509
|
+
return celula_generar_caso.derive(self.__ai_service, self.definitions, self.rules, max_tkns=max_tkns)
|
1510
|
+
if command == "CONTINUAR_DIALOGO":
|
1511
|
+
return celula_simulador_ciudadano.derive(self.__ai_service, query, max_tkns=max_tkns)
|
1496
1512
|
return None
|
1497
1513
|
|
1498
1514
|
def parse_conversation(self) -> str:
|
@@ -1742,10 +1758,15 @@ class SpecialDispatch():
|
|
1742
1758
|
logging.info("=> No se seleccionó ningun agente")
|
1743
1759
|
|
1744
1760
|
major_id, response, score = self.retrieval(query)
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1761
|
+
if 'glosario' in major_id.lower():
|
1762
|
+
major_id = 'glosario'
|
1763
|
+
elif 'inicial' in major_id.lower():
|
1764
|
+
major_id = 'portal'
|
1765
|
+
else:
|
1766
|
+
major_id_split = major_id.split("_")
|
1767
|
+
major_id = major_id_split[0] if len(major_id_split) > 0 else major_id
|
1768
|
+
major_id_split = major_id.split("-")
|
1769
|
+
major_id = major_id_split[1] if len(major_id_split) > 0 else major_id
|
1749
1770
|
|
1750
1771
|
compare_llm = 0
|
1751
1772
|
compare_index = 0
|
@@ -1788,4 +1809,5 @@ class SpecialDispatch():
|
|
1788
1809
|
|
1789
1810
|
self.kusto_close()
|
1790
1811
|
self.__meta_work_memory = []
|
1812
|
+
self.major_id = None
|
1791
1813
|
return select_agent, response
|
@@ -74,11 +74,14 @@ pbesa/celulas/__init__.py
|
|
74
74
|
pbesa/celulas/celula_casos.py
|
75
75
|
pbesa/celulas/celula_consultas.py
|
76
76
|
pbesa/celulas/celula_conversador.py
|
77
|
+
pbesa/celulas/celula_cuestionador.py
|
77
78
|
pbesa/celulas/celula_datos_identificables.py
|
78
79
|
pbesa/celulas/celula_evaluador.py
|
79
80
|
pbesa/celulas/celula_expertos.py
|
80
81
|
pbesa/celulas/celula_extraccion.py
|
82
|
+
pbesa/celulas/celula_generar_caso.py
|
81
83
|
pbesa/celulas/celula_generar_documento.py
|
84
|
+
pbesa/celulas/celula_instruccion.py
|
82
85
|
pbesa/celulas/celula_parafraseo.py
|
83
86
|
pbesa/celulas/celula_pertinencia.py
|
84
87
|
pbesa/celulas/celula_preguntas.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.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/pbesa.cpython-36.pyc
RENAMED
File without changes
|
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/helloworld/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/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.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/admin.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/apps.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/models.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/django/helloworld/translate/__pycache__/urls.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/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.29 → pbesa-4.0.31}/examples/django/helloworld/translate/mas/worker/translatetask.py
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/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.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/counteragent.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/countertask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/examples/remote/mas/worker/__pycache__/translatetask.cpython-36.pyc
RENAMED
File without changes
|
{pbesa-4.0.29 → pbesa-4.0.31}/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
|