This commit is contained in:
2026-01-29 12:26:13 +01:00
parent ba0f116bc2
commit 6dbcadcaee
79 changed files with 2795 additions and 657 deletions

59
src/core/config.ts Normal file
View File

@@ -0,0 +1,59 @@
/**
* Application configuration
* Centralizes all environment variables and configuration settings
*/
interface BotConfig {
discord: {
token: string;
};
ai: {
replicateApiToken: string;
model: string;
maxTokens: number;
temperature: number;
};
bot: {
/** Chance of Joel responding without being mentioned (0-1) */
freeWillChance: number;
/** Chance of using memories for responses (0-1) */
memoryChance: number;
/** Minimum time between random user mentions (ms) */
mentionCooldown: number;
/** Chance of mentioning a random user (0-1) */
mentionProbability: number;
};
}
function getEnvOrThrow(key: string): string {
const value = Bun.env[key];
if (!value) {
throw new Error(`Missing required environment variable: ${key}`);
}
return value;
}
function getEnvOrDefault(key: string, defaultValue: string): string {
return Bun.env[key] ?? defaultValue;
}
export const config: BotConfig = {
discord: {
token: getEnvOrThrow("DISCORD_TOKEN"),
},
ai: {
replicateApiToken: getEnvOrThrow("REPLICATE_API_TOKEN"),
model: getEnvOrDefault(
"AI_MODEL",
"lucataco/dolphin-2.9-llama3-8b:ee173688d3b8d9e05a5b910f10fb9bab1e9348963ab224579bb90d9fce3fb00b"
),
maxTokens: parseInt(getEnvOrDefault("AI_MAX_TOKENS", "500")),
temperature: parseFloat(getEnvOrDefault("AI_TEMPERATURE", "1.2")),
},
bot: {
freeWillChance: 0.02,
memoryChance: 0.3,
mentionCooldown: 24 * 60 * 60 * 1000, // 24 hours
mentionProbability: 0.001,
},
};