@aria-framework/ai 0.8.0 → 0.8.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/health.js +14 -7
- package/package.json +1 -1
package/health.js
CHANGED
|
@@ -200,8 +200,12 @@ function createHealthChecker(opts = {}) {
|
|
|
200
200
|
// generation speed — separating those would need time-to-first-token, which no adapter
|
|
201
201
|
// reports — but it is what the caller actually experienced, which is the number worth planning
|
|
202
202
|
// against. Only completions count; a health probe generates no tokens and would drag it to 0.
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
// Guarded on TOKENS, not on duration. Requiring ms > 0 here silently dropped any call that
|
|
204
|
+
// completed inside a millisecond — which a fast local model or a stub genuinely does, so the
|
|
205
|
+
// sample count became timing-dependent. The division is where zero actually matters, so that
|
|
206
|
+
// is where it is handled.
|
|
207
|
+
if (ok && info.tokens > 0) {
|
|
208
|
+
e.samples.push({ tokens: info.tokens, ms: Math.max(0, Number(info.ms) || 0) });
|
|
205
209
|
if (e.samples.length > WINDOW) e.samples.shift();
|
|
206
210
|
}
|
|
207
211
|
if (ok) {
|
|
@@ -303,11 +307,14 @@ function createHealthChecker(opts = {}) {
|
|
|
303
307
|
modelPresent: e.modelPresent,
|
|
304
308
|
// NULL until something has actually generated tokens. Reporting 0 tok/s for a provider
|
|
305
309
|
// nobody has used yet reads as "it is slow" rather than "we do not know".
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
// Null rather than Infinity when every sample was too fast to measure: "we cannot tell"
|
|
311
|
+
// is the honest answer, and a card showing Infinity tok/s is worse than showing nothing.
|
|
312
|
+
tokensPerSec: (() => {
|
|
313
|
+
if (!e.samples.length) return null;
|
|
314
|
+
const ms = e.samples.reduce((n, x) => n + x.ms, 0);
|
|
315
|
+
if (ms <= 0) return null;
|
|
316
|
+
return Math.round(e.samples.reduce((n, x) => n + x.tokens, 0) / (ms / 1000));
|
|
317
|
+
})(),
|
|
311
318
|
samples: e.samples.length,
|
|
312
319
|
cooldownRemainingMs: down ? e.downUntil - now() : 0
|
|
313
320
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aria-framework/ai",
|
|
3
3
|
"description": "Aria App Framework — AI module. A dependency-injected model seam (createAiClient) over several providers (LM Studio / OpenAI-compatible / Anthropic), with a fact-preservation guard, generic Polish and Generate writing engines, and a browser polish widget. Prompts and config stay in the consuming app.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"publishConfig": {
|