pi-lilac-provider 1.6.0 → 1.6.1
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/index.ts +9 -4
- package/package.json +1 -1
- package/scripts/update-models.js +3 -1
package/index.ts
CHANGED
|
@@ -398,8 +398,10 @@ function transformApiModel(apiModel: any): JsonModel | null {
|
|
|
398
398
|
const hasImage = modalities.includes("image");
|
|
399
399
|
const pricing = apiModel.pricing || {};
|
|
400
400
|
|
|
401
|
-
// Lilac API returns per-token pricing (e.g. "0.0000007" = $0.70/M tokens)
|
|
402
|
-
|
|
401
|
+
// Lilac API returns per-token pricing (e.g. "0.0000007" = $0.70/M tokens).
|
|
402
|
+
// Convert to $/M then round to 6 decimals: normalizes float noise from the ×1e6
|
|
403
|
+
// multiply and preserves sub-cent cache prices like 0.003 ($/M).
|
|
404
|
+
const toPerM = (v: any) => Math.round((typeof v === "string" ? parseFloat(v) : (v || 0)) * 1_000_000 * 1e6) / 1e6;
|
|
403
405
|
|
|
404
406
|
const inputTypes: string[] = ["text"];
|
|
405
407
|
if (hasImage) inputTypes.push("image");
|
|
@@ -561,7 +563,9 @@ function applyDiscounts(models: JsonModel[], discounts: Map<string, JsonDiscount
|
|
|
561
563
|
// E.g. "0.75" means pay 75% of list price. For MiniMax with "1.00" there's no discount.
|
|
562
564
|
// discountPercent is informational (it equals (1 - creditMultiplier) * 100).
|
|
563
565
|
const factor = discount.creditMultiplier;
|
|
564
|
-
|
|
566
|
+
// Round to 6 decimals of $/M so a discounted sub-cent cache price
|
|
567
|
+
// (e.g. 0.003 × 0.75 = 0.00225) survives; 4-decimal rounding trimmed it to 0.0023.
|
|
568
|
+
const applyFactor = (n: number) => n > 0 ? Math.round(n * factor * 1e6) / 1e6 : n;
|
|
565
569
|
return {
|
|
566
570
|
...model,
|
|
567
571
|
cost: {
|
|
@@ -604,7 +608,8 @@ function applyDiscountInPlace(
|
|
|
604
608
|
// discount was removed since it was last priced.
|
|
605
609
|
const rawFactor = discounts?.get(model.id)?.creditMultiplier;
|
|
606
610
|
const factor = Number.isFinite(rawFactor) && rawFactor !== undefined ? rawFactor : 1;
|
|
607
|
-
|
|
611
|
+
// Round to 6 decimals of $/M so a discounted sub-cent cache price survives.
|
|
612
|
+
const applyFactor = (n: number) => n > 0 ? Math.round(n * factor * 1e6) / 1e6 : n;
|
|
608
613
|
model.cost.input = applyFactor(list.cost.input);
|
|
609
614
|
model.cost.output = applyFactor(list.cost.output);
|
|
610
615
|
model.cost.cacheRead = applyFactor(list.cost.cacheRead);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lilac-provider",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Lilac provider extension for pi - Access Kimi K2.6, GLM 5.1, and Gemma 4 models through Lilac's OpenAI-compatible API on idle GPUs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
package/scripts/update-models.js
CHANGED
|
@@ -55,7 +55,9 @@ function saveJson(filePath, data) {
|
|
|
55
55
|
// Convert per-token pricing from API to per-million-tokens
|
|
56
56
|
function toPerMillion(val) {
|
|
57
57
|
if (val === '' || val === null || val === undefined) return null;
|
|
58
|
-
|
|
58
|
+
// Round to 6 decimals of $/M: normalizes float noise from the ×1e6 multiply
|
|
59
|
+
// and preserves sub-cent cache prices like 0.003 ($/M).
|
|
60
|
+
return Math.round(parseFloat(val) * 1_000_000 * 1e6) / 1e6;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
// ─── API fetch ───────────────────────────────────────────────────────────────
|