@aexol/spectral 0.3.4 → 0.3.5
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/server/pi-bridge.js +6 -3
- package/package.json +1 -1
package/dist/server/pi-bridge.js
CHANGED
|
@@ -192,7 +192,10 @@ function supportsReasoning(modelId) {
|
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
194
|
* Calculate credits from token usage using per-model credit rates.
|
|
195
|
-
*
|
|
195
|
+
*
|
|
196
|
+
* NOTE: We intentionally keep higher precision here (no 2-decimal rounding)
|
|
197
|
+
* so small turns don't collapse to 0.00 in live UI aggregation. Rendering
|
|
198
|
+
* layers decide final display precision.
|
|
196
199
|
*/
|
|
197
200
|
function calculateCredits(inputTokens, outputTokens, cacheReadTokens = 0, cacheWriteTokens = 0, creditInputPer1M, creditOutputPer1M, creditCachedInputPer1M, creditCacheReadPer1M, creditCacheWritePer1M) {
|
|
198
201
|
const inputRate = creditInputPer1M ?? 0;
|
|
@@ -206,11 +209,11 @@ function calculateCredits(inputTokens, outputTokens, cacheReadTokens = 0, cacheW
|
|
|
206
209
|
(cacheWriteTokens / 1_000_000) * cacheWriteRate;
|
|
207
210
|
if (inputRate === 0 && outputRate === 0 && cacheReadRate === 0 && cacheWriteRate === 0) {
|
|
208
211
|
if (cachedInputRate > 0) {
|
|
209
|
-
return
|
|
212
|
+
return ((inputTokens + cacheReadTokens + cacheWriteTokens) / 1_000_000) * cachedInputRate;
|
|
210
213
|
}
|
|
211
214
|
return 0;
|
|
212
215
|
}
|
|
213
|
-
return
|
|
216
|
+
return credits;
|
|
214
217
|
}
|
|
215
218
|
/**
|
|
216
219
|
* Parse the newline-delimited JSON of wire events persisted alongside an
|