Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -396,7 +401,7 @@ export const MODEL_MULTIPLIERS: Record<string, number> = {
};

// 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();
Expand Down Expand Up @@ -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;
});
});

Expand Down
11 changes: 6 additions & 5 deletions src/test/model-info-limits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down
Loading