fix(review): treat 0 tiered rate as valid, warn on cache-only unknown models
- calculateTieredCost: use `== null` instead of `!` so a 0 tiered rate is not treated as missing - calculateMessageCost: include cacheReadTokens and cacheCreationTokens in the unknown-model warning condition Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ca3fc9008
commit
419913543c
1 changed files with 2 additions and 2 deletions
|
|
@ -61,7 +61,7 @@ export function getPricing(modelName: string): LiteLLMPricing | null {
|
||||||
|
|
||||||
export function calculateTieredCost(tokens: number, baseRate: number, tieredRate?: number): number {
|
export function calculateTieredCost(tokens: number, baseRate: number, tieredRate?: number): number {
|
||||||
if (tokens <= 0) return 0;
|
if (tokens <= 0) return 0;
|
||||||
if (!tieredRate || tokens <= TIER_THRESHOLD) {
|
if (tieredRate == null || tokens <= TIER_THRESHOLD) {
|
||||||
return tokens * baseRate;
|
return tokens * baseRate;
|
||||||
}
|
}
|
||||||
const costBelow = TIER_THRESHOLD * baseRate;
|
const costBelow = TIER_THRESHOLD * baseRate;
|
||||||
|
|
@ -78,7 +78,7 @@ export function calculateMessageCost(
|
||||||
): number {
|
): number {
|
||||||
const pricing = getPricing(modelName);
|
const pricing = getPricing(modelName);
|
||||||
if (!pricing) {
|
if (!pricing) {
|
||||||
if (inputTokens > 0 || outputTokens > 0) {
|
if (inputTokens > 0 || outputTokens > 0 || cacheReadTokens > 0 || cacheCreationTokens > 0) {
|
||||||
console.warn(`[pricing] No pricing data for model "${modelName}", cost will be $0`);
|
console.warn(`[pricing] No pricing data for model "${modelName}", cost will be $0`);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue