fix(pi-devin): parse Devin CLI 1M cost_summary correctly
Devin catalog emits '$4 / 1M Input · $0.2 / 1M Cached input · $20 / 1M Output' but the vendored parseCost only matched '/MTok In/Out', leaving output and cached prices at 0 so session cost totals for devin models were wrong. Accept 1M Input/Output/Cached input labels and use the real cached-input price for cacheRead instead of the 10% input heuristic.
This commit is contained in:
+7
-3
@@ -30,14 +30,18 @@ const THINKING_ORDER = ["off", "minimal", "low", "medium", "high", "xhigh", "max
|
|||||||
function parseCost(summary?: string): ProviderModelConfig["cost"] {
|
function parseCost(summary?: string): ProviderModelConfig["cost"] {
|
||||||
const empty = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
const empty = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||||
if (!summary) return empty;
|
if (!summary) return empty;
|
||||||
const input = summary.match(/\$([0-9.]+)\s*\/\s*MTok In/i);
|
// Devin CLI emits e.g. "$10 / 1M Input · $0.25 / 1M Cached input · $50 / 1M Output";
|
||||||
const output = summary.match(/\$([0-9.]+)\s*\/\s*MTok Out/i);
|
// older catalogs used "/MTok In" style labels. Match the unit token loosely.
|
||||||
|
const input = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+In(?:put)?/i);
|
||||||
|
const output = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+Out(?:put)?/i);
|
||||||
|
const cached = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+Cached\s+in(?:put)?/i);
|
||||||
const inCost = input ? Number(input[1]) : 0;
|
const inCost = input ? Number(input[1]) : 0;
|
||||||
const outCost = output ? Number(output[1]) : 0;
|
const outCost = output ? Number(output[1]) : 0;
|
||||||
|
const cacheRead = cached ? Number(cached[1]) : Number((inCost * 0.1).toFixed(4));
|
||||||
return {
|
return {
|
||||||
input: inCost,
|
input: inCost,
|
||||||
output: outCost,
|
output: outCost,
|
||||||
cacheRead: Number((inCost * 0.1).toFixed(4)),
|
cacheRead,
|
||||||
cacheWrite: Number((inCost * 1.25).toFixed(4)),
|
cacheWrite: Number((inCost * 1.25).toFixed(4)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user