From 72813cd8743e8d8c4f6da25d5ea92d5e76c03c53 Mon Sep 17 00:00:00 2001 From: Studio Date: Thu, 16 Oct 2025 10:12:41 +0200 Subject: [PATCH] Add AI Stupid Level integration with 6 auto-routing models --- app/api/generate-ai-code-stream/route.ts | 16 +++++++++++++--- config/app.config.ts | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/api/generate-ai-code-stream/route.ts b/app/api/generate-ai-code-stream/route.ts index 6a8f6aac..9929d9b7 100644 --- a/app/api/generate-ai-code-stream/route.ts +++ b/app/api/generate-ai-code-stream/route.ts @@ -44,6 +44,11 @@ const openai = createOpenAI({ baseURL: isUsingAIGateway ? aiGatewayBaseURL : process.env.OPENAI_BASE_URL, }); +const aiStupidLevel = createOpenAI({ + apiKey: process.env.AI_STUPID_LEVEL_API_KEY, + baseURL: 'https://aistupidlevel.info/v1', +}); + // Helper function to analyze user preferences from conversation history function analyzeUserPreferences(messages: ConversationMessage[]): { commonPatterns: string[]; @@ -1216,11 +1221,13 @@ MORPH FAST APPLY MODE (EDIT-ONLY): const isAnthropic = model.startsWith('anthropic/'); const isGoogle = model.startsWith('google/'); const isOpenAI = model.startsWith('openai/'); + const isAIStupidLevel = model.startsWith('aistupidlevel/'); const isKimiGroq = model === 'moonshotai/kimi-k2-instruct-0905'; const modelProvider = isAnthropic ? anthropic : (isOpenAI ? openai : (isGoogle ? googleGenerativeAI : - (isKimiGroq ? groq : groq))); + (isAIStupidLevel ? aiStupidLevel : + (isKimiGroq ? groq : groq)))); // Fix model name transformation for different providers let actualModel: string; @@ -1228,6 +1235,9 @@ MORPH FAST APPLY MODE (EDIT-ONLY): actualModel = model.replace('anthropic/', ''); } else if (isOpenAI) { actualModel = model.replace('openai/', ''); + } else if (isAIStupidLevel) { + // AI Stupid Level uses the full model string + actualModel = model.replace('aistupidlevel/', ''); } else if (isKimiGroq) { // Kimi on Groq - use full model string actualModel = 'moonshotai/kimi-k2-instruct-0905'; @@ -1238,7 +1248,7 @@ MORPH FAST APPLY MODE (EDIT-ONLY): actualModel = model; } - console.log(`[generate-ai-code-stream] Using provider: ${isAnthropic ? 'Anthropic' : isGoogle ? 'Google' : isOpenAI ? 'OpenAI' : 'Groq'}, model: ${actualModel}`); + console.log(`[generate-ai-code-stream] Using provider: ${isAnthropic ? 'Anthropic' : isGoogle ? 'Google' : isOpenAI ? 'OpenAI' : isAIStupidLevel ? 'AI Stupid Level' : 'Groq'}, model: ${actualModel}`); console.log(`[generate-ai-code-stream] AI Gateway enabled: ${isUsingAIGateway}`); console.log(`[generate-ai-code-stream] Model string: ${model}`); @@ -1893,4 +1903,4 @@ Provide the complete file content without any truncation. Include all necessary error: (error as Error).message }, { status: 500 }); } -} \ No newline at end of file +} diff --git a/config/app.config.ts b/config/app.config.ts index 16ba7d27..3a1ef20a 100644 --- a/config/app.config.ts +++ b/config/app.config.ts @@ -58,7 +58,13 @@ export const appConfig = { 'openai/gpt-5', 'moonshotai/kimi-k2-instruct-0905', 'anthropic/claude-sonnet-4-20250514', - 'google/gemini-2.0-flash-exp' + 'google/gemini-2.0-flash-exp', + 'aistupidlevel/auto', + 'aistupidlevel/auto-coding', + 'aistupidlevel/auto-reasoning', + 'aistupidlevel/auto-creative', + 'aistupidlevel/auto-fastest', + 'aistupidlevel/auto-cheapest' ], // Model display names @@ -66,7 +72,13 @@ export const appConfig = { 'openai/gpt-5': 'GPT-5', 'moonshotai/kimi-k2-instruct-0905': 'Kimi K2 (Groq)', 'anthropic/claude-sonnet-4-20250514': 'Sonnet 4', - 'google/gemini-2.0-flash-exp': 'Gemini 2.0 Flash (Experimental)' + 'google/gemini-2.0-flash-exp': 'Gemini 2.0 Flash (Experimental)', + 'aistupidlevel/auto': 'AI Stupid Level (Auto)', + 'aistupidlevel/auto-coding': 'AI Stupid Level (Coding)', + 'aistupidlevel/auto-reasoning': 'AI Stupid Level (Reasoning)', + 'aistupidlevel/auto-creative': 'AI Stupid Level (Creative)', + 'aistupidlevel/auto-fastest': 'AI Stupid Level (Fastest)', + 'aistupidlevel/auto-cheapest': 'AI Stupid Level (Cheapest)' } as Record, // Model API configuration @@ -193,4 +205,4 @@ export function getConfigValue(path: string): any { return path.split('.').reduce((obj, key) => obj?.[key], appConfig as any); } -export default appConfig; \ No newline at end of file +export default appConfig;