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
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ OPENAI_API_KEY=your_openai_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here

# Get yours at https://console.groq.com
GROQ_API_KEY=your_groq_api_key_here
GROQ_API_KEY=your_groq_api_key_here

# OPTIONAL - For local models via Ollama
# Set this to your Ollama server URL
OLLAMA_BASE_URL=http://localhost:11434
28 changes: 24 additions & 4 deletions app/api/generate-ai-code-stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createGroq } from '@ai-sdk/groq';
import { createAnthropic } from '@ai-sdk/anthropic';
import { createOpenAI } from '@ai-sdk/openai';
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { createOllama } from 'ollama-ai-provider';
import { streamText } from 'ai';
import type { SandboxState } from '@/types/sandbox';
import { selectFilesForEdit, getFileContents, formatFilesForAI } from '@/lib/context-selector';
Expand All @@ -28,6 +29,10 @@ const openai = createOpenAI({
apiKey: process.env.OPENAI_API_KEY,
});

const ollama = createOllama({
baseURL: process.env.OLLAMA_BASE_URL || 'http://localhost:11434/api',
});

// Helper function to analyze user preferences from conversation history
function analyzeUserPreferences(messages: ConversationMessage[]): {
commonPatterns: string[];
Expand Down Expand Up @@ -1155,10 +1160,25 @@ CRITICAL: When files are provided in the context:
const isAnthropic = model.startsWith('anthropic/');
const isGoogle = model.startsWith('google/');
const isOpenAI = model.startsWith('openai/gpt-5');
const modelProvider = isAnthropic ? anthropic : (isOpenAI ? openai : (isGoogle ? googleGenerativeAI : groq));
const actualModel = isAnthropic ? model.replace('anthropic/', '') :
(model === 'openai/gpt-5') ? 'gpt-5' :
(isGoogle ? model.replace('google/', '') : model);
const isOllama = model.startsWith('ollama/');
const modelProvider = isAnthropic
? anthropic
: isOpenAI
? openai
: isGoogle
? googleGenerativeAI
: isOllama
? ollama
: groq;
const actualModel = isAnthropic
? model.replace('anthropic/', '')
: model === 'openai/gpt-5'
? 'gpt-5'
: isGoogle
? model.replace('google/', '')
: isOllama
? model.replace('ollama/', '')
: model;

// Make streaming API call with appropriate provider
const streamOptions: any = {
Expand Down
8 changes: 6 additions & 2 deletions config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ export const appConfig = {
'openai/gpt-5',
'moonshotai/kimi-k2-instruct',
'anthropic/claude-sonnet-4-20250514',
'google/gemini-2.5-pro'
'google/gemini-2.5-pro',
'ollama/llama3',
'ollama/phi3'
],

// Model display names
modelDisplayNames: {
'openai/gpt-5': 'GPT-5',
'moonshotai/kimi-k2-instruct': 'Kimi K2 Instruct',
'anthropic/claude-sonnet-4-20250514': 'Sonnet 4',
'google/gemini-2.5-pro': 'Gemini 2.5 Pro'
'google/gemini-2.5-pro': 'Gemini 2.5 Pro',
'ollama/llama3': 'Llama 3 (Ollama)',
'ollama/phi3': 'Phi 3 (Ollama)'
},

// Temperature settings for non-reasoning models
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"framer-motion": "^12.23.12",
"groq-sdk": "^0.29.0",
"lucide-react": "^0.532.0",
"ollama-ai-provider": "^0.4.0",
"next": "15.4.3",
"react": "19.1.0",
"react-dom": "19.1.0",
Expand Down
Loading