Skip to content

Commit bc2919f

Browse files
RHSplinterClauderajbos
authored
Update cost calculations (#152)
* Fix cost calculations by removing duplicate multiplier application The CSV data already includes model multipliers in requestsUsed values. Fixed excessCost calculation in getModelUsageSummary and getExpectedExcessCost to not multiply by the multiplier again. Updated tests to reflect correct behavior. The multiplier is still displayed in the UI for informational purposes. Agent-Logs-Url: https://github.com/RHSplinter/github-copilot-premium-reqs-usage/sessions/7777403e-d7c3-4c8b-8f8e-ff51db24c81e Co-authored-by: RHSplinter <60773832+RHSplinter@users.noreply.github.com> * Remove notes * Ensure excess costs for default models are always 0 Default models (with multiplier = 0) are free and should never incur excess costs, even when exceeding quota. Added check to ensure excessCost is 0 for models with multiplier = 0. Updated test to reflect this correct behavior. Agent-Logs-Url: https://github.com/RHSplinter/github-copilot-premium-reqs-usage/sessions/4b7fec75-998c-4d97-980b-8190a0d0b13c Co-authored-by: RHSplinter <60773832+RHSplinter@users.noreply.github.com> * Remove notes * Added GPT-5 mini to default models --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: Rob Bos <rajbos@users.noreply.github.com>
1 parent de88459 commit bc2919f

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/lib/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ export function getModelUsageSummary(data: CopilotUsageData[]): ModelUsageSummar
251251
}
252252

253253
// Calculate excess cost
254-
groupedSummary[key].excessCost = groupedSummary[key].exceedingRequests * groupedSummary[key].multiplier * EXCESS_REQUEST_COST;
254+
// Free models (multiplier = 0) have no excess cost
255+
if (groupedSummary[key].multiplier === 0) {
256+
groupedSummary[key].excessCost = 0;
257+
} else {
258+
groupedSummary[key].excessCost = groupedSummary[key].exceedingRequests * EXCESS_REQUEST_COST;
259+
}
255260
});
256261

257262
// Convert to array and sort by total requests (descending)
@@ -396,7 +401,7 @@ export const MODEL_MULTIPLIERS: Record<string, number> = {
396401
};
397402

398403
// Default models that should be grouped
399-
export const DEFAULT_MODELS = ['GPT-4o', 'GPT-4.1', 'gpt-4o-2024-11-20', 'gpt-4.1-2025-04-14'];
404+
export const DEFAULT_MODELS = ['GPT-4o', 'GPT-4.1', 'GPT-5 mini', 'gpt-4o-2024-11-20', 'gpt-4.1-2025-04-14'];
400405

401406
function normalizeModelName(model: string): string {
402407
return model.replace(/^Auto:\s*/, '').trim();
@@ -952,13 +957,13 @@ export function getExpectedExcessCost(data: CopilotUsageData[], plan: string = C
952957

953958
const numDays = datesForAverage.length;
954959

955-
// Project extra requests per model over remaining days and apply cost multiplier
960+
// Project extra requests per model over remaining days
956961
Object.entries(modelTotals).forEach(([model, total]) => {
957962
const multiplier = getModelMultiplier(model);
958963
if (multiplier === 0) return; // Free models have no cost
959964
const dailyAvg = total / numDays;
960965
const projectedExtra = dailyAvg * remainingDays;
961-
totalExpectedCost += projectedExtra * multiplier * EXCESS_REQUEST_COST;
966+
totalExpectedCost += projectedExtra * EXCESS_REQUEST_COST;
962967
});
963968
});
964969

src/test/model-info-limits.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ describe('Model Info and Limits Feature', () => {
9898
expect(defaultGroup).toBeDefined();
9999

100100
if (defaultGroup) {
101-
// 50 exceeding requests * 0x multiplier * $0.04 = $0.00
102-
expect(defaultGroup.excessCost).toBe(50 * 0 * EXCESS_REQUEST_COST);
101+
// Default models are free (multiplier = 0), so excess cost is always $0.00
102+
// even if there are exceeding requests
103+
expect(defaultGroup.excessCost).toBe(0);
103104
}
104-
105+
105106
const o3Model = result.find(item => item.model === 'o3-mini-2025-01-31');
106107
if (o3Model) {
107-
// 10 exceeding requests * 0.33x multiplier * $0.04 = $0.132
108-
expect(o3Model.excessCost).toBe(10 * 0.33 * EXCESS_REQUEST_COST);
108+
// 10 exceeding requests * $0.04 = $0.40
109+
expect(o3Model.excessCost).toBe(10 * EXCESS_REQUEST_COST);
109110
}
110111
});
111112

0 commit comments

Comments
 (0)