diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 58a452f..c6e22d3 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -251,7 +251,12 @@ export function getModelUsageSummary(data: CopilotUsageData[]): ModelUsageSummar } // Calculate excess cost - groupedSummary[key].excessCost = groupedSummary[key].exceedingRequests * groupedSummary[key].multiplier * EXCESS_REQUEST_COST; + // Free models (multiplier = 0) have no excess cost + if (groupedSummary[key].multiplier === 0) { + groupedSummary[key].excessCost = 0; + } else { + groupedSummary[key].excessCost = groupedSummary[key].exceedingRequests * EXCESS_REQUEST_COST; + } }); // Convert to array and sort by total requests (descending) @@ -396,7 +401,7 @@ export const MODEL_MULTIPLIERS: Record = { }; // Default models that should be grouped -export const DEFAULT_MODELS = ['GPT-4o', 'GPT-4.1', 'gpt-4o-2024-11-20', 'gpt-4.1-2025-04-14']; +export const DEFAULT_MODELS = ['GPT-4o', 'GPT-4.1', 'GPT-5 mini', 'gpt-4o-2024-11-20', 'gpt-4.1-2025-04-14']; function normalizeModelName(model: string): string { return model.replace(/^Auto:\s*/, '').trim(); @@ -952,13 +957,13 @@ export function getExpectedExcessCost(data: CopilotUsageData[], plan: string = C const numDays = datesForAverage.length; - // Project extra requests per model over remaining days and apply cost multiplier + // Project extra requests per model over remaining days Object.entries(modelTotals).forEach(([model, total]) => { const multiplier = getModelMultiplier(model); if (multiplier === 0) return; // Free models have no cost const dailyAvg = total / numDays; const projectedExtra = dailyAvg * remainingDays; - totalExpectedCost += projectedExtra * multiplier * EXCESS_REQUEST_COST; + totalExpectedCost += projectedExtra * EXCESS_REQUEST_COST; }); }); diff --git a/src/test/model-info-limits.test.ts b/src/test/model-info-limits.test.ts index a5cf9f7..3656811 100644 --- a/src/test/model-info-limits.test.ts +++ b/src/test/model-info-limits.test.ts @@ -98,14 +98,15 @@ describe('Model Info and Limits Feature', () => { expect(defaultGroup).toBeDefined(); if (defaultGroup) { - // 50 exceeding requests * 0x multiplier * $0.04 = $0.00 - expect(defaultGroup.excessCost).toBe(50 * 0 * EXCESS_REQUEST_COST); + // Default models are free (multiplier = 0), so excess cost is always $0.00 + // even if there are exceeding requests + expect(defaultGroup.excessCost).toBe(0); } - + const o3Model = result.find(item => item.model === 'o3-mini-2025-01-31'); if (o3Model) { - // 10 exceeding requests * 0.33x multiplier * $0.04 = $0.132 - expect(o3Model.excessCost).toBe(10 * 0.33 * EXCESS_REQUEST_COST); + // 10 exceeding requests * $0.04 = $0.40 + expect(o3Model.excessCost).toBe(10 * EXCESS_REQUEST_COST); } });