joel bot
This commit is contained in:
59
src/core/config.ts
Normal file
59
src/core/config.ts
Normal 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,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user