@blockrun/clawrouter 0.8.9 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +16 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -443,12 +443,16 @@ function selectModel(tier, confidence, method, reasoning, tierConfigs, modelPric
|
|
|
443
443
|
const tierConfig = tierConfigs[tier];
|
|
444
444
|
const model = tierConfig.primary;
|
|
445
445
|
const pricing = modelPricing.get(model);
|
|
446
|
-
const
|
|
447
|
-
const
|
|
446
|
+
const inputPrice = pricing?.inputPrice ?? 0;
|
|
447
|
+
const outputPrice = pricing?.outputPrice ?? 0;
|
|
448
|
+
const inputCost = estimatedInputTokens / 1e6 * inputPrice;
|
|
449
|
+
const outputCost = maxOutputTokens / 1e6 * outputPrice;
|
|
448
450
|
const costEstimate = inputCost + outputCost;
|
|
449
451
|
const opusPricing = modelPricing.get("anthropic/claude-opus-4");
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
+
const opusInputPrice = opusPricing?.inputPrice ?? 0;
|
|
453
|
+
const opusOutputPrice = opusPricing?.outputPrice ?? 0;
|
|
454
|
+
const baselineInput = estimatedInputTokens / 1e6 * opusInputPrice;
|
|
455
|
+
const baselineOutput = maxOutputTokens / 1e6 * opusOutputPrice;
|
|
452
456
|
const baselineCost = baselineInput + baselineOutput;
|
|
453
457
|
const savings = baselineCost > 0 ? Math.max(0, (baselineCost - costEstimate) / baselineCost) : 0;
|
|
454
458
|
return {
|
|
@@ -468,12 +472,16 @@ function getFallbackChain(tier, tierConfigs) {
|
|
|
468
472
|
}
|
|
469
473
|
function calculateModelCost(model, modelPricing, estimatedInputTokens, maxOutputTokens) {
|
|
470
474
|
const pricing = modelPricing.get(model);
|
|
471
|
-
const
|
|
472
|
-
const
|
|
475
|
+
const inputPrice = pricing?.inputPrice ?? 0;
|
|
476
|
+
const outputPrice = pricing?.outputPrice ?? 0;
|
|
477
|
+
const inputCost = estimatedInputTokens / 1e6 * inputPrice;
|
|
478
|
+
const outputCost = maxOutputTokens / 1e6 * outputPrice;
|
|
473
479
|
const costEstimate = inputCost + outputCost;
|
|
474
480
|
const opusPricing = modelPricing.get("anthropic/claude-opus-4");
|
|
475
|
-
const
|
|
476
|
-
const
|
|
481
|
+
const opusInputPrice = opusPricing?.inputPrice ?? 0;
|
|
482
|
+
const opusOutputPrice = opusPricing?.outputPrice ?? 0;
|
|
483
|
+
const baselineInput = estimatedInputTokens / 1e6 * opusInputPrice;
|
|
484
|
+
const baselineOutput = maxOutputTokens / 1e6 * opusOutputPrice;
|
|
477
485
|
const baselineCost = baselineInput + baselineOutput;
|
|
478
486
|
const savings = baselineCost > 0 ? Math.max(0, (baselineCost - costEstimate) / baselineCost) : 0;
|
|
479
487
|
return { costEstimate, baselineCost, savings };
|