feat: IA profiles, server context and a workable token ceiling

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
marcos
2026-08-06 03:03:53 +00:00
parent e0d7c289a8
commit aee991bb7b
3 changed files with 73 additions and 2 deletions
@@ -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() {
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) {