Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/api/generate-ai-code-stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -1216,18 +1221,23 @@ 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;
if (isAnthropic) {
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';
Expand All @@ -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}`);

Expand Down Expand Up @@ -1893,4 +1903,4 @@ Provide the complete file content without any truncation. Include all necessary
error: (error as Error).message
}, { status: 500 });
}
}
}
18 changes: 15 additions & 3 deletions config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,27 @@ 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
modelDisplayNames: {
'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<string, string>,

// Model API configuration
Expand Down Expand Up @@ -193,4 +205,4 @@ export function getConfigValue(path: string): any {
return path.split('.').reduce((obj, key) => obj?.[key], appConfig as any);
}

export default appConfig;
export default appConfig;