From aee991bb7bd5a62fca7781d0bb290c53d8c2966f Mon Sep 17 00:00:00 2001 From: marcos Date: Thu, 6 Aug 2026 03:03:53 +0000 Subject: [PATCH] feat: IA profiles, server context and a workable token ceiling Co-Authored-By: Claude --- .../marcospaulo/canalhandia/AiProfile.java | 25 +++++++++++++++++ .../dev/marcospaulo/canalhandia/Settings.java | 27 ++++++++++++++++++- src/main/resources/config.yml | 23 +++++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/main/java/dev/marcospaulo/canalhandia/AiProfile.java diff --git a/src/main/java/dev/marcospaulo/canalhandia/AiProfile.java b/src/main/java/dev/marcospaulo/canalhandia/AiProfile.java new file mode 100644 index 0000000..4ff3906 --- /dev/null +++ b/src/main/java/dev/marcospaulo/canalhandia/AiProfile.java @@ -0,0 +1,25 @@ +package dev.marcospaulo.canalhandia; + +/** + * How much work to do per question. + * + *

This trades latency, not money: the plan's token allowance is far beyond + * what a small server can spend, but every added context token makes chat feel + * slower. + */ +enum AiProfile { + + /** Skip the wiki round trip. Fast, ungrounded. */ + ECONOMICO, + /** Consult the wiki. Slower, accurate. */ + PRECISO; + + static AiProfile byKey(String key) { + for (AiProfile profile : values()) { + if (profile.name().equalsIgnoreCase(key)) { + return profile; + } + } + return PRECISO; + } +} \ No newline at end of file diff --git a/src/main/java/dev/marcospaulo/canalhandia/Settings.java b/src/main/java/dev/marcospaulo/canalhandia/Settings.java index 3fbd227..78b5811 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/Settings.java +++ b/src/main/java/dev/marcospaulo/canalhandia/Settings.java @@ -252,7 +252,7 @@ final class Settings { } int aiMaxTokens() { - return Math.max(32, plugin.getConfig().getInt("ia.max-tokens", 300)); + return Math.max(32, plugin.getConfig().getInt("ia.max-tokens", 1200)); } double aiTemperature() { @@ -297,6 +297,31 @@ final class Settings { set("ia.publico", value); } + AiProfile aiProfile() { + return AiProfile.byKey(plugin.getConfig().getString("ia.perfil", "PRECISO")); + } + + void aiProfile(AiProfile profile) { + set("ia.perfil", profile.name()); + } + + /** How much article text to send. Lead paragraphs alone were not enough. */ + int aiWikiChars() { + return Math.max(500, plugin.getConfig().getInt("ia.wiki-caracteres", 7000)); + } + + int aiMemoryExchanges() { + return Math.max(0, plugin.getConfig().getInt("ia.memoria-perguntas", 3)); + } + + int aiMemoryMinutes() { + return Math.max(1, plugin.getConfig().getInt("ia.memoria-minutos", 10)); + } + + String aiServerContext() { + return String.join(" ", plugin.getConfig().getStringList("ia.contexto")); + } + // --- content ------------------------------------------------------------ boolean categoryEnabled(Category category) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5eb80a7..a012eb7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -129,7 +129,9 @@ ia: modelo: "MiniMax-M2.7" # Tamanho da resposta pedida ao modelo, e o corte final no chat. - max-tokens: 300 + # 1200, não 300: o raciocínio oculto do M3 consome o orçamento e a resposta + # chega vazia quando o teto é baixo. + max-tokens: 1200 max-caracteres: 500 # Tamanho máximo da pergunta, em caracteres. @@ -161,3 +163,22 @@ ia: terminal nem de Minecraft. Escreva em texto puro: nada de markdown, asteriscos, crases ou emoji, porque o chat do Minecraft não formata nada disso. + + # ECONOMICO pula a consulta à wiki (resposta rápida, sem fonte). + # PRECISO consulta a wiki (mais lento, mais correto). Troque em jogo com + # /ia perfil . + perfil: PRECISO + + # Quantos caracteres do artigo da wiki enviar. Só a introdução não basta: + # a receita e os detalhes ficam mais abaixo na página. + wiki-caracteres: 7000 + + # Memória curta por jogador, para perguntas de seguimento ("e no nether?"). + memoria-perguntas: 3 + memoria-minutos: 10 + + # Fatos do servidor que a IA nunca teria como saber. Uma linha por fato. + contexto: + - "O servidor se chama Canalhandia e roda Minecraft 26.2 (Paper)." + - "Jogadores de Bedrock entram pelo Geyser e o nome deles começa com ponto." + - "O servidor tem BlueMap, voice chat e Distant Horizons."