From a864366c80e61a3f9f3cccf62ca088c4077d431b Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sat, 12 Jul 2025 07:28:13 -0400 Subject: [PATCH] add hardcoded context windows for Groq models --- src/models.js | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/models.js b/src/models.js index 45a4245..8190c0d 100644 --- a/src/models.js +++ b/src/models.js @@ -84,13 +84,40 @@ export async function fetchModelsFromEndpoints() { const models = jsonResponse.data || []; console.log(`✅ Fetched ${models.length} models from ${endpoint.url}:`, models.map(m => m.id)); // Map each model to include its endpoint ID, unique ID, and model name - return models.map((model) => ({ - ...model, - modelName: model.id, // Explicitly store model name - endpointId: endpoint.id, - uniqueId: `${endpoint.id}-${model.id}`, // Unique ID with endpoint ID first - maxTokens: model.max_tokens || model.context_length || model.max_context_length || model.max_model_len || 8192, // Capture max tokens - })); + return models.map((model) => { + // Get context window size from API or use known values for Groq models + let maxTokens = model.max_tokens || model.context_length || model.max_context_length || model.max_model_len; + + // Hardcoded context windows for known Groq models (since API doesn't return them) + if (endpoint.id.includes('groq.com')) { + const groqContextWindows = { + 'llama-3.1-8b-instant': 131072, + 'llama-3.3-70b-versatile': 131072, + 'llama-3.1-70b-versatile': 131072, + 'llama3-8b-8192': 8192, + 'llama3-70b-8192': 8192, + 'mixtral-8x7b-32768': 32768, + 'gemma2-9b-it': 8192, + 'meta-llama/llama-4-scout-17b-16e-instruct': 131072, + 'meta-llama/llama-4-maverick-17b-128e-instruct': 131072, + 'deepseek-r1-distill-llama-70b': 131072, + 'qwen/qwen3-32b': 131072, + 'mistral-saba-24b': 32768, + 'compound-beta': 131072, + 'compound-beta-mini': 131072, + }; + maxTokens = groqContextWindows[model.id] || 8192; + console.log(`Using hardcoded context window for Groq model ${model.id}: ${maxTokens} tokens`); + } + + return { + ...model, + modelName: model.id, + endpointId: endpoint.id, + uniqueId: `${endpoint.id}-${model.id}`, + maxTokens: maxTokens || 8192, + }; + }); } catch (error) { console.error(`Error fetching models from ${endpoint.url}:`, error); return [];