feat: add fallback

This commit is contained in:
eric
2026-02-23 15:16:15 +01:00
parent a4650c14ae
commit e26d665bdf
4 changed files with 134 additions and 51 deletions

View File

@@ -13,6 +13,7 @@ interface BotConfig {
openRouterApiKey: string;
model: string;
classificationModel: string;
classificationFallbackModels: string[];
maxTokens: number;
temperature: number;
};
@@ -75,6 +76,18 @@ function getBooleanEnvOrDefault(key: string, defaultValue: boolean): boolean {
return normalized === "1" || normalized === "true" || normalized === "yes";
}
function getCsvEnvOrDefault(key: string, defaultValues: string[]): string[] {
const raw = Bun.env[key];
if (!raw) {
return defaultValues;
}
return raw
.split(",")
.map((value) => value.trim())
.filter((value) => value.length > 0);
}
export const config: BotConfig = {
discord: {
token: getEnvOrThrow("DISCORD_TOKEN"),
@@ -91,6 +104,10 @@ export const config: BotConfig = {
"AI_CLASSIFICATION_MODEL",
"google/gemma-3-12b-it:free"
),
classificationFallbackModels: getCsvEnvOrDefault("AI_CLASSIFICATION_FALLBACK_MODELS", [
"qwen/qwen-2.5-7b-instruct:free",
"mistralai/mistral-7b-instruct:free",
]),
maxTokens: parseInt(getEnvOrDefault("AI_MAX_TOKENS", "500")),
temperature: parseFloat(getEnvOrDefault("AI_TEMPERATURE", "1.2")),
},