Isaac Quarenta commited on
Commit ·
7dcda01
1
Parent(s): eb6ddb6
fix(jev): boost de continuidade — follow-up encadeia tópico em curso (eleva depth +1.5 e recalcula consciousness)
Browse files- modules/api.py +17 -8
modules/api.py
CHANGED
|
@@ -8464,6 +8464,20 @@ class AkiraAPI:
|
|
| 8464 |
if float(jev_hostility.data.get('p_true') or 0) >= 0.6:
|
| 8465 |
self.logger.info(f"⚡ [JEV] Hostilidade: p={jev_hostility.data.get('p_true'):.2f}")
|
| 8466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8467 |
# Armazena análise JEV no thinking_analysis para uso no prompt
|
| 8468 |
if thinking_analysis is None:
|
| 8469 |
thinking_analysis = {}
|
|
@@ -8473,18 +8487,13 @@ class AkiraAPI:
|
|
| 8473 |
self.logger.warning(f"⚡ [JEV PRE-CLASS] Erro (non-blocking): {e}")
|
| 8474 |
|
| 8475 |
# 🧠 SYSTEM 1 vs SYSTEM 2 — Gate de Consciência 1-10
|
| 8476 |
-
# 1-3: reflexo rápido (CoT skip, minimal_history=4)
|
| 8477 |
-
# 4-6: equilibrado (CoT condicional, minimal_history=8)
|
| 8478 |
-
# 7-10: profunda e totalmente consciente (CoT forçado, minimal_history=12, System-2 deliberativo)
|
| 8479 |
jev_depth_data = jev_analysis.get('depth', {}) if jev_analysis else {}
|
| 8480 |
consciousness_10 = int(jev_analysis.get('consciousness_10', 5) or 5)
|
| 8481 |
-
# Garante que depth_score sempre exista com fallback seguro
|
| 8482 |
depth_score = float(jev_depth_data.get('depth_score') or 1)
|
| 8483 |
system_type = jev_depth_data.get('system_type', 'System 1')
|
| 8484 |
-
|
| 8485 |
-
|
| 8486 |
-
|
| 8487 |
-
# classifica baixo, mas a resposta DEVE encadear com o tópico anterior.
|
| 8488 |
try:
|
| 8489 |
_hist_active = len(context_history or []) >= 2
|
| 8490 |
_msg_words = len((original_message or '').split())
|
|
|
|
| 8464 |
if float(jev_hostility.data.get('p_true') or 0) >= 0.6:
|
| 8465 |
self.logger.info(f"⚡ [JEV] Hostilidade: p={jev_hostility.data.get('p_true'):.2f}")
|
| 8466 |
|
| 8467 |
+
# 🧠 BOOST DE CONTINUIDADE: follow-up curto em conversa com histórico em curso
|
| 8468 |
+
# Herdar fio da conversa quando JEV classifica baixo isoladamente
|
| 8469 |
+
if jev_depth and jev_depth.success:
|
| 8470 |
+
raw_depth_val = float(jev_depth.data.get('depth_score') or 2)
|
| 8471 |
+
# Se mensagem vaga ("oque mais deu errado?") mas há thinking_analysis com posição travada
|
| 8472 |
+
# e thread reply_to_bot=True → sobe consciência para encadear
|
| 8473 |
+
has_thread = unified_context is not None and len(getattr(unified_context, 'messages', []) or []) >= 2
|
| 8474 |
+
has_akira_position = bool((thinking_analysis or {}).get('jev_analysis', {})) or bool(thinking_analysis and thinking_analysis.get('stance'))
|
| 8475 |
+
if raw_depth_val <= 2.5 and has_thread and has_akira_position:
|
| 8476 |
+
boosted = min(5.0, raw_depth_val + 1.5)
|
| 8477 |
+
jev_depth.data['depth_score'] = boosted
|
| 8478 |
+
raw_depth_val = boosted
|
| 8479 |
+
logger.info(f"🧠 [JEV BOOST] profundidade {raw_depth_val - 1.5:.2f} → {boosted:.2f} (continuidade de tópico)")
|
| 8480 |
+
|
| 8481 |
# Armazena análise JEV no thinking_analysis para uso no prompt
|
| 8482 |
if thinking_analysis is None:
|
| 8483 |
thinking_analysis = {}
|
|
|
|
| 8487 |
self.logger.warning(f"⚡ [JEV PRE-CLASS] Erro (non-blocking): {e}")
|
| 8488 |
|
| 8489 |
# 🧠 SYSTEM 1 vs SYSTEM 2 — Gate de Consciência 1-10
|
|
|
|
|
|
|
|
|
|
| 8490 |
jev_depth_data = jev_analysis.get('depth', {}) if jev_analysis else {}
|
| 8491 |
consciousness_10 = int(jev_analysis.get('consciousness_10', 5) or 5)
|
|
|
|
| 8492 |
depth_score = float(jev_depth_data.get('depth_score') or 1)
|
| 8493 |
system_type = jev_depth_data.get('system_type', 'System 1')
|
| 8494 |
+
# Recalcula se houve boost no bloco JEV (consciousness_10 precisa refletir raw atualizado)
|
| 8495 |
+
raw_for_gate = float(jev_depth_data.get('depth_score', depth_score))
|
| 8496 |
+
consciousness_10 = max(1, min(10, round(raw_for_gate * 2)))
|
|
|
|
| 8497 |
try:
|
| 8498 |
_hist_active = len(context_history or []) >= 2
|
| 8499 |
_msg_words = len((original_message or '').split())
|