feeef 0.9.7 → 0.10.0
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/build/index.js
CHANGED
|
@@ -4677,6 +4677,18 @@ var AI_BILLING = getLegacyAiBillingFlat(FALLBACK_AI_EXCHANGE_RATE);
|
|
|
4677
4677
|
function findModel(models, modelId, fallbackId) {
|
|
4678
4678
|
return models.find((m) => m.id === modelId) || models.find((m) => m.id === fallbackId) || models[0];
|
|
4679
4679
|
}
|
|
4680
|
+
function pickCatalogTokenPricingPerM(catalog, modelId) {
|
|
4681
|
+
if (!catalog?.data?.length) return null;
|
|
4682
|
+
const row = catalog.data.find((r) => r?.id === modelId);
|
|
4683
|
+
const p = row?.pricing;
|
|
4684
|
+
const promptPerToken = Number(p?.prompt);
|
|
4685
|
+
const completionPerToken = Number(p?.completion);
|
|
4686
|
+
if (!Number.isFinite(promptPerToken) && !Number.isFinite(completionPerToken)) return null;
|
|
4687
|
+
const inTok = Number.isFinite(promptPerToken) ? promptPerToken : 0;
|
|
4688
|
+
const outTok = Number.isFinite(completionPerToken) ? completionPerToken : 0;
|
|
4689
|
+
if (inTok <= 0 && outTok <= 0) return null;
|
|
4690
|
+
return { input: inTok * 1e6, output: outTok * 1e6 };
|
|
4691
|
+
}
|
|
4680
4692
|
function modelHasVoiceCapability(model) {
|
|
4681
4693
|
const caps = model?.capabilities;
|
|
4682
4694
|
if (!Array.isArray(caps)) return false;
|
|
@@ -4749,6 +4761,7 @@ var AiCalculator = class {
|
|
|
4749
4761
|
MEDIA_RESOLUTION_HIGH: 10
|
|
4750
4762
|
},
|
|
4751
4763
|
models: config.models ?? [],
|
|
4764
|
+
modelsCatalog: config.modelsCatalog,
|
|
4752
4765
|
billing
|
|
4753
4766
|
};
|
|
4754
4767
|
}
|
|
@@ -4873,7 +4886,8 @@ var AiCalculator = class {
|
|
|
4873
4886
|
const { exchangeRate } = this.config;
|
|
4874
4887
|
const model = findModel(this.config.models, modelId, "gemini-3-flash-preview");
|
|
4875
4888
|
const tokenPricing = model?.pricing?.find((p) => p.unit === "tokens");
|
|
4876
|
-
|
|
4889
|
+
const catalogPricing = tokenPricing ? null : pickCatalogTokenPricingPerM(this.config.modelsCatalog, modelId);
|
|
4890
|
+
if (!tokenPricing && !catalogPricing || totalTokens < tg.freeTierMaxPromptTokens) {
|
|
4877
4891
|
return {
|
|
4878
4892
|
providerCostUsd: 0,
|
|
4879
4893
|
providerCostDzd: 0,
|
|
@@ -4888,8 +4902,8 @@ var AiCalculator = class {
|
|
|
4888
4902
|
}
|
|
4889
4903
|
};
|
|
4890
4904
|
}
|
|
4891
|
-
const inputPrice = tokenPricing
|
|
4892
|
-
const outputPrice = tokenPricing
|
|
4905
|
+
const inputPrice = tokenPricing?.input ?? catalogPricing?.input ?? 0;
|
|
4906
|
+
const outputPrice = tokenPricing?.output ?? catalogPricing?.output ?? 0;
|
|
4893
4907
|
const providerCostUsd = estimatedPromptTokens / 1e6 * inputPrice + estimatedOutputTokens / 1e6 * outputPrice;
|
|
4894
4908
|
const providerCostDzd = providerCostUsd * exchangeRate;
|
|
4895
4909
|
const userCostDzd = roundMoney(providerCostDzd * mult);
|