mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-13 15:54:34 +00:00
fix: bound uncached remainder by prompt-max(cached,write) and forward compact prompt_cache_key
This commit is contained in:
@@ -294,9 +294,10 @@ func calculateTextQuotaSummary(ctx *gin.Context, relayInfo *relaycommon.RelayInf
|
||||
}
|
||||
}
|
||||
|
||||
// OpenAI cache-write usage can report cached_tokens + cache_write_tokens
|
||||
// exceeding prompt_tokens; the uncached remainder must clamp at zero so
|
||||
// billing never subtracts more than the reported input.
|
||||
// OpenAI cache-write usage reports unadjusted prefix counts, so
|
||||
// cached_tokens + cache_write_tokens can exceed prompt_tokens and the
|
||||
// remainder can go negative. Clamp at zero so overlap never turns into
|
||||
// a negative base charge.
|
||||
if baseTokens.IsNegative() {
|
||||
baseTokens = decimal.Zero
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user