feat: IA profiles, server context and a workable token ceiling
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.marcospaulo.canalhandia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much work to do per question.
|
||||||
|
*
|
||||||
|
* <p>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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -252,7 +252,7 @@ final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int aiMaxTokens() {
|
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() {
|
double aiTemperature() {
|
||||||
@@ -297,6 +297,31 @@ final class Settings {
|
|||||||
set("ia.publico", value);
|
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 ------------------------------------------------------------
|
// --- content ------------------------------------------------------------
|
||||||
|
|
||||||
boolean categoryEnabled(Category category) {
|
boolean categoryEnabled(Category category) {
|
||||||
|
|||||||
@@ -129,7 +129,9 @@ ia:
|
|||||||
modelo: "MiniMax-M2.7"
|
modelo: "MiniMax-M2.7"
|
||||||
|
|
||||||
# Tamanho da resposta pedida ao modelo, e o corte final no chat.
|
# 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
|
max-caracteres: 500
|
||||||
|
|
||||||
# Tamanho máximo da pergunta, em caracteres.
|
# Tamanho máximo da pergunta, em caracteres.
|
||||||
@@ -161,3 +163,22 @@ ia:
|
|||||||
terminal nem de Minecraft. Escreva em texto puro: nada de markdown,
|
terminal nem de Minecraft. Escreva em texto puro: nada de markdown,
|
||||||
asteriscos, crases ou emoji, porque o chat do Minecraft não formata nada
|
asteriscos, crases ou emoji, porque o chat do Minecraft não formata nada
|
||||||
disso.
|
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 <nome>.
|
||||||
|
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."
|
||||||
|
|||||||
Reference in New Issue
Block a user