llmist 14.0.0 → 15.1.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/dist/index.cjs +37 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1549,12 +1549,46 @@ var init_rate_limit = __esm({
|
|
|
1549
1549
|
const now = Date.now();
|
|
1550
1550
|
this.pruneOldEntries(now);
|
|
1551
1551
|
this.checkDailyReset();
|
|
1552
|
+
const currentRpm = this.requestTimestamps.length;
|
|
1553
|
+
const currentTpm = this.tokenUsage.reduce((sum, entry) => sum + entry.tokens, 0);
|
|
1554
|
+
const triggeredBy = {};
|
|
1555
|
+
if (this.config.requestsPerMinute !== void 0) {
|
|
1556
|
+
const effectiveLimit = this.config.requestsPerMinute * this.config.safetyMargin;
|
|
1557
|
+
if (currentRpm >= effectiveLimit) {
|
|
1558
|
+
triggeredBy.rpm = {
|
|
1559
|
+
current: currentRpm,
|
|
1560
|
+
limit: this.config.requestsPerMinute,
|
|
1561
|
+
effectiveLimit
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
if (this.config.tokensPerMinute !== void 0) {
|
|
1566
|
+
const effectiveLimit = this.config.tokensPerMinute * this.config.safetyMargin;
|
|
1567
|
+
if (currentTpm >= effectiveLimit) {
|
|
1568
|
+
triggeredBy.tpm = {
|
|
1569
|
+
current: currentTpm,
|
|
1570
|
+
limit: this.config.tokensPerMinute,
|
|
1571
|
+
effectiveLimit
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (this.config.tokensPerDay !== void 0) {
|
|
1576
|
+
const effectiveLimit = this.config.tokensPerDay * this.config.safetyMargin;
|
|
1577
|
+
if (this.dailyTokens >= effectiveLimit) {
|
|
1578
|
+
triggeredBy.daily = {
|
|
1579
|
+
current: this.dailyTokens,
|
|
1580
|
+
limit: this.config.tokensPerDay,
|
|
1581
|
+
effectiveLimit
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1552
1585
|
return {
|
|
1553
|
-
rpm:
|
|
1554
|
-
tpm:
|
|
1586
|
+
rpm: currentRpm,
|
|
1587
|
+
tpm: currentTpm,
|
|
1555
1588
|
dailyTokens: this.dailyTokens,
|
|
1556
1589
|
isApproachingLimit: this.isApproachingLimit(),
|
|
1557
|
-
requiredDelayMs: this.getRequiredDelayMs()
|
|
1590
|
+
requiredDelayMs: this.getRequiredDelayMs(),
|
|
1591
|
+
triggeredBy: Object.keys(triggeredBy).length > 0 ? triggeredBy : void 0
|
|
1558
1592
|
};
|
|
1559
1593
|
}
|
|
1560
1594
|
/**
|