Isaac Quarenta commited on
Commit ·
1e9d829
1
Parent(s): 04cd26a
feat(tokens/pdf): max token largo geral + pdf extra + formatacao rica prompt-only
Browse files- config.py:448 MAX_TOKENS 6000->8192 via AKIRA_MAX_TOKENS env (8000+), MODEL_PARAMETERS 7 modelos 6000->8192, MAX_RESPONSE_CHARS 25000->50000
- skills_library.py:1588 generate_document skill description(prompt-only): adiciona MAX_TOKENS LARGO ate 8192 geral/12000 PDF, instrucao para NAO cortar, e lista TODAS tecnicas formatacao markdown ricas: # H1, ## H2, ### H3, **negrito**, *italico*, codigo, - lista, 1. numerada, | tabela |, > citacao, --- separador, quebras duplas, listas aninhadas
- thinking_engine.py:750 SKILLS list generate_document atualizada com mesma instrucao formato maximo (prompt-only, sem logica)
Nenhuma logica de santetizacao criada — apenas configuracao literal + prompt
- modules/config.py +11 -9
- modules/skills_library.py +0 -0
- modules/thinking_engine.py +1 -1
modules/config.py
CHANGED
|
@@ -445,7 +445,9 @@ def get_nlp_analyzer() -> NLPAnalyzer:
|
|
| 445 |
# ============================================================
|
| 446 |
# PARÂMETROS GLOBAIS DE GERAÇÃO (Fallback/Padrão)
|
| 447 |
# ============================================================
|
| 448 |
-
|
|
|
|
|
|
|
| 449 |
TOP_P: float = 0.9
|
| 450 |
TOP_K: int = 50
|
| 451 |
TEMPERATURE: float = 0.85
|
|
@@ -454,7 +456,7 @@ FREQUENCY_PENALTY: float = 0.1
|
|
| 454 |
PRESENCE_PENALTY: float = 0.1
|
| 455 |
# ✅ FIX 2026-08-26: 45s → 15s fail-fast para não estourar BotCore 180s (CoT 63s + Mistral 45s = 180s)
|
| 456 |
API_TIMEOUT: int = int(os.getenv("AKIRA_API_TIMEOUT", "20"))
|
| 457 |
-
MAX_RESPONSE_CHARS: int =
|
| 458 |
|
| 459 |
# ============================================================
|
| 460 |
# THINKING ENGINE CONFIG
|
|
@@ -495,13 +497,13 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 495 |
"repetition_penalty": 1.05,
|
| 496 |
"presence_penalty": 0.1,
|
| 497 |
"frequency_penalty": 0.1,
|
| 498 |
-
"max_tokens":
|
| 499 |
},
|
| 500 |
|
| 501 |
"deepseek-ai/DeepSeek-V3": {
|
| 502 |
"temperature": 0.5,
|
| 503 |
"top_p": 0.95,
|
| 504 |
-
"max_tokens":
|
| 505 |
# Removidos penalty params para evitar Erro 400 em alguns routers HF
|
| 506 |
},
|
| 507 |
|
|
@@ -510,7 +512,7 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 510 |
"temperature": 0.6,
|
| 511 |
"top_p": 0.9,
|
| 512 |
"repetition_penalty": 1.1,
|
| 513 |
-
"max_tokens":
|
| 514 |
},
|
| 515 |
|
| 516 |
# MISTRAL LUANA 8x7B (Especialista PT-AO)
|
|
@@ -520,7 +522,7 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 520 |
"top_p": 0.95,
|
| 521 |
"top_k": 40,
|
| 522 |
"repetition_penalty": 1.15,
|
| 523 |
-
"max_tokens":
|
| 524 |
},
|
| 525 |
|
| 526 |
# LLAMA 3.1 8B LEXI UNCENSORED (Agilidade e Zero Filtro)
|
|
@@ -530,7 +532,7 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 530 |
"top_p": 0.85,
|
| 531 |
"top_k": 50,
|
| 532 |
"repetition_penalty": 1.12,
|
| 533 |
-
"max_tokens":
|
| 534 |
},
|
| 535 |
|
| 536 |
# QWEN 2.5 72B INSTRUCT (Multilingual Beast / Lógica)
|
|
@@ -539,7 +541,7 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 539 |
"top_p": 0.8,
|
| 540 |
"top_k": 40,
|
| 541 |
"repetition_penalty": 1.05,
|
| 542 |
-
"max_tokens":
|
| 543 |
},
|
| 544 |
|
| 545 |
# LLAMA 3.3 70B INSTRUCT (Fallback Final)
|
|
@@ -547,7 +549,7 @@ MODEL_PARAMETERS: Dict[str, Dict[str, Any]] = {
|
|
| 547 |
"temperature": 0.3,
|
| 548 |
"top_p": 0.9,
|
| 549 |
"repetition_penalty": 1.1,
|
| 550 |
-
"max_tokens":
|
| 551 |
}
|
| 552 |
}
|
| 553 |
|
|
|
|
| 445 |
# ============================================================
|
| 446 |
# PARÂMETROS GLOBAIS DE GERAÇÃO (Fallback/Padrão)
|
| 447 |
# ============================================================
|
| 448 |
+
# FIX 2026-09-03: max token largo geral — modelo já tem prompts para respostas curtas,
|
| 449 |
+
# então max_tokens não pode impedir respostas longas quando necessário (PDF etc)
|
| 450 |
+
MAX_TOKENS: int = int(os.getenv("AKIRA_MAX_TOKENS", "8192"))
|
| 451 |
TOP_P: float = 0.9
|
| 452 |
TOP_K: int = 50
|
| 453 |
TEMPERATURE: float = 0.85
|
|
|
|
| 456 |
PRESENCE_PENALTY: float = 0.1
|
| 457 |
# ✅ FIX 2026-08-26: 45s → 15s fail-fast para não estourar BotCore 180s (CoT 63s + Mistral 45s = 180s)
|
| 458 |
API_TIMEOUT: int = int(os.getenv("AKIRA_API_TIMEOUT", "20"))
|
| 459 |
+
MAX_RESPONSE_CHARS: int = int(os.getenv("AKIRA_MAX_RESPONSE_CHARS", "50000"))
|
| 460 |
|
| 461 |
# ============================================================
|
| 462 |
# THINKING ENGINE CONFIG
|
|
|
|
| 497 |
"repetition_penalty": 1.05,
|
| 498 |
"presence_penalty": 0.1,
|
| 499 |
"frequency_penalty": 0.1,
|
| 500 |
+
"max_tokens": 8192
|
| 501 |
},
|
| 502 |
|
| 503 |
"deepseek-ai/DeepSeek-V3": {
|
| 504 |
"temperature": 0.5,
|
| 505 |
"top_p": 0.95,
|
| 506 |
+
"max_tokens": 8192
|
| 507 |
# Removidos penalty params para evitar Erro 400 em alguns routers HF
|
| 508 |
},
|
| 509 |
|
|
|
|
| 512 |
"temperature": 0.6,
|
| 513 |
"top_p": 0.9,
|
| 514 |
"repetition_penalty": 1.1,
|
| 515 |
+
"max_tokens": 8192
|
| 516 |
},
|
| 517 |
|
| 518 |
# MISTRAL LUANA 8x7B (Especialista PT-AO)
|
|
|
|
| 522 |
"top_p": 0.95,
|
| 523 |
"top_k": 40,
|
| 524 |
"repetition_penalty": 1.15,
|
| 525 |
+
"max_tokens": 8192
|
| 526 |
},
|
| 527 |
|
| 528 |
# LLAMA 3.1 8B LEXI UNCENSORED (Agilidade e Zero Filtro)
|
|
|
|
| 532 |
"top_p": 0.85,
|
| 533 |
"top_k": 50,
|
| 534 |
"repetition_penalty": 1.12,
|
| 535 |
+
"max_tokens": 8192
|
| 536 |
},
|
| 537 |
|
| 538 |
# QWEN 2.5 72B INSTRUCT (Multilingual Beast / Lógica)
|
|
|
|
| 541 |
"top_p": 0.8,
|
| 542 |
"top_k": 40,
|
| 543 |
"repetition_penalty": 1.05,
|
| 544 |
+
"max_tokens": 8192
|
| 545 |
},
|
| 546 |
|
| 547 |
# LLAMA 3.3 70B INSTRUCT (Fallback Final)
|
|
|
|
| 549 |
"temperature": 0.3,
|
| 550 |
"top_p": 0.9,
|
| 551 |
"repetition_penalty": 1.1,
|
| 552 |
+
"max_tokens": 8192
|
| 553 |
}
|
| 554 |
}
|
| 555 |
|
modules/skills_library.py
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modules/thinking_engine.py
CHANGED
|
@@ -749,7 +749,7 @@ class ThinkingEngine:
|
|
| 749 |
# ================================================================
|
| 750 |
sys_prompt += (
|
| 751 |
"\n<SKILLS> Tens 70+ skills. Principais:\n"
|
| 752 |
-
"- generate_document: Gera PDFs
|
| 753 |
"- web_search: Pesquisa informação externa. USA SEMPRE que precisas de factos atualizados, preços, notícias, definições. PALAVRAS RESERVADAS: 'clima/tempura/chuva/previsão'→clima, 'notícia/morreu/eleição/guerra/resultado'→notícias, 'quem é/o que é/biografia/wikipedia'→wikipedia, 'imagem/foto/vídeo/mapa'→imagens, resto→geral (multi-fonte DDGS+SerpAPI). Usa PALAVRAS EXATAS do utilizador na query. Inclui 'Angola' se for sobre algo angolano.\n"
|
| 754 |
"- generate_image: Gera imagens quando pedem ilustrações ou imagens.\n"
|
| 755 |
"- calculate_math: Cálculos matemáticos precisos.\n"
|
|
|
|
| 749 |
# ================================================================
|
| 750 |
sys_prompt += (
|
| 751 |
"\n<SKILLS> Tens 70+ skills. Principais:\n"
|
| 752 |
+
"- generate_document: Gera PDFs profissionais RICOS (fallback fpdf2). USE quando pedem 'gera um pdf/relatório/carta'. MAX_TOKENS LARGO: até 8192 geral / 12000 PDF — NÃO corte conteúdo. FORMATAÇÃO MÁXIMA OBRIGATÓRIA: # Título H1, ## H2, ### H3, **negrito**, *itálico*, `código`, - lista, 1. numerada, | tabela |, > citação, --- separador, quebras \\n\\n entre seções, listas aninhadas. NUNCA texto corrido simples — ESTRUTURE com todas técnicas.\n"
|
| 753 |
"- web_search: Pesquisa informação externa. USA SEMPRE que precisas de factos atualizados, preços, notícias, definições. PALAVRAS RESERVADAS: 'clima/tempura/chuva/previsão'→clima, 'notícia/morreu/eleição/guerra/resultado'→notícias, 'quem é/o que é/biografia/wikipedia'→wikipedia, 'imagem/foto/vídeo/mapa'→imagens, resto→geral (multi-fonte DDGS+SerpAPI). Usa PALAVRAS EXATAS do utilizador na query. Inclui 'Angola' se for sobre algo angolano.\n"
|
| 754 |
"- generate_image: Gera imagens quando pedem ilustrações ou imagens.\n"
|
| 755 |
"- calculate_math: Cálculos matemáticos precisos.\n"
|