@drsamonline/prober 0.12.33 → 0.12.35
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/package.json +3 -2
- package/src/index.js +22 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drsamonline/prober",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.35",
|
|
4
4
|
"description": "Canary prober: liveness, readiness and suitability checks that decide what may be routed to.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drsamonline/catalog": "^0.12.0"
|
|
27
|
+
"@drsamonline/catalog": "^0.12.0",
|
|
28
|
+
"@drsamonline/core": "^0.12.0"
|
|
28
29
|
},
|
|
29
30
|
"engines": {
|
|
30
31
|
"node": ">=20"
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { poolKey } from '@drsamonline/catalog';
|
|
21
|
+
import { pickChatModel } from '@drsamonline/core';
|
|
21
22
|
|
|
22
23
|
/** Bump when a fixture changes, so probe history stays comparable. */
|
|
23
24
|
/**
|
|
@@ -201,11 +202,17 @@ export async function probeTarget(entry, opts = {}) {
|
|
|
201
202
|
reasons,
|
|
202
203
|
};
|
|
203
204
|
}
|
|
205
|
+
// The model that answered readiness is the model every later check must use. The
|
|
206
|
+
// suitability probes used to ask for `modelFor(entry)` — a family name like
|
|
207
|
+
// "openai-compatible" — so Groq answered readiness and then 404'd all three,
|
|
208
|
+
// and a working provider was recorded as unsuitable.
|
|
209
|
+
const provenModel = probeModel(entry, discoveredModels);
|
|
210
|
+
|
|
204
211
|
levels.readiness = await timed(async () => {
|
|
205
212
|
const res = await fetchImpl(`${base}/chat/completions`, {
|
|
206
213
|
method: 'POST',
|
|
207
214
|
headers,
|
|
208
|
-
body: JSON.stringify({ model:
|
|
215
|
+
body: JSON.stringify({ model: provenModel, ...FIXTURES.readiness }),
|
|
209
216
|
signal: AbortSignal.timeout(timeoutMs),
|
|
210
217
|
});
|
|
211
218
|
if (!res.ok) {
|
|
@@ -224,15 +231,15 @@ export async function probeTarget(entry, opts = {}) {
|
|
|
224
231
|
const capabilities = opts.capabilities ?? entry.capabilities ?? [];
|
|
225
232
|
if (levels.readiness.ok) {
|
|
226
233
|
if (capabilities.includes('streaming')) {
|
|
227
|
-
levels.suitability.streaming = await probeStreaming({ fetchImpl, base, headers, entry, timeoutMs });
|
|
234
|
+
levels.suitability.streaming = await probeStreaming({ fetchImpl, base, headers, entry, timeoutMs, model: provenModel });
|
|
228
235
|
if (!levels.suitability.streaming.ok) reasons.push(`streaming: ${levels.suitability.streaming.note}`);
|
|
229
236
|
}
|
|
230
237
|
if (capabilities.includes('json_schema')) {
|
|
231
|
-
levels.suitability.json_schema = await probeJson({ fetchImpl, base, headers, entry, timeoutMs });
|
|
238
|
+
levels.suitability.json_schema = await probeJson({ fetchImpl, base, headers, entry, timeoutMs, model: provenModel });
|
|
232
239
|
if (!levels.suitability.json_schema.ok) reasons.push(`json_schema: ${levels.suitability.json_schema.note}`);
|
|
233
240
|
}
|
|
234
241
|
if (capabilities.includes('tools')) {
|
|
235
|
-
levels.suitability.tools = await probeTools({ fetchImpl, base, headers, entry, timeoutMs });
|
|
242
|
+
levels.suitability.tools = await probeTools({ fetchImpl, base, headers, entry, timeoutMs, model: provenModel });
|
|
236
243
|
if (!levels.suitability.tools.ok) reasons.push(`tools: ${levels.suitability.tools.note}`);
|
|
237
244
|
}
|
|
238
245
|
}
|
|
@@ -259,12 +266,12 @@ export async function probeTarget(entry, opts = {}) {
|
|
|
259
266
|
}
|
|
260
267
|
|
|
261
268
|
/** Streaming must be a real event sequence, not one blob pretending to be SSE. */
|
|
262
|
-
async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
269
|
+
async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs, model }) {
|
|
263
270
|
return timed(async () => {
|
|
264
271
|
const res = await fetchImpl(`${base}/chat/completions`, {
|
|
265
272
|
method: 'POST',
|
|
266
273
|
headers,
|
|
267
|
-
body: JSON.stringify({ model
|
|
274
|
+
body: JSON.stringify({ model, stream: true, ...FIXTURES.readiness }),
|
|
268
275
|
signal: AbortSignal.timeout(timeoutMs),
|
|
269
276
|
});
|
|
270
277
|
if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status}` };
|
|
@@ -321,12 +328,12 @@ async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
|
321
328
|
}
|
|
322
329
|
|
|
323
330
|
/** A JSON request has to come back as JSON, not as a promise to be JSON. */
|
|
324
|
-
async function probeJson({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
331
|
+
async function probeJson({ fetchImpl, base, headers, entry, timeoutMs, model }) {
|
|
325
332
|
return timed(async () => {
|
|
326
333
|
const res = await fetchImpl(`${base}/chat/completions`, {
|
|
327
334
|
method: 'POST',
|
|
328
335
|
headers,
|
|
329
|
-
body: JSON.stringify({ model
|
|
336
|
+
body: JSON.stringify({ model, ...FIXTURES.jsonSchema }),
|
|
330
337
|
signal: AbortSignal.timeout(timeoutMs),
|
|
331
338
|
});
|
|
332
339
|
if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status}` };
|
|
@@ -348,12 +355,12 @@ async function probeJson({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
|
348
355
|
* shape — not that the model chose to call the tool. Refusing to call a tool is a
|
|
349
356
|
* legitimate answer; a 400 is not.
|
|
350
357
|
*/
|
|
351
|
-
async function probeTools({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
358
|
+
async function probeTools({ fetchImpl, base, headers, entry, timeoutMs, model }) {
|
|
352
359
|
return timed(async () => {
|
|
353
360
|
const res = await fetchImpl(`${base}/chat/completions`, {
|
|
354
361
|
method: 'POST',
|
|
355
362
|
headers,
|
|
356
|
-
body: JSON.stringify({ model
|
|
363
|
+
body: JSON.stringify({ model, ...FIXTURES.tools }),
|
|
357
364
|
signal: AbortSignal.timeout(timeoutMs),
|
|
358
365
|
});
|
|
359
366
|
if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status} — tools rejected` };
|
|
@@ -374,16 +381,16 @@ async function probeTools({ fetchImpl, base, headers, entry, timeoutMs }) {
|
|
|
374
381
|
*/
|
|
375
382
|
function probeModel(entry, discovered = []) {
|
|
376
383
|
if (entry.probe_model) return entry.probe_model;
|
|
377
|
-
if (discovered.length)
|
|
384
|
+
if (discovered.length) {
|
|
385
|
+
// a provider's /models lists TTS, embedding and guard models too: taking the
|
|
386
|
+
// first id put Groq's Arabic TTS voice in front of a chat probe
|
|
387
|
+
return pickChatModel(discovered) ?? discovered[0];
|
|
388
|
+
}
|
|
378
389
|
const family = entry.model_family;
|
|
379
390
|
if (family && !/compatible|mixed|unknown/i.test(family)) return family;
|
|
380
391
|
return 'default';
|
|
381
392
|
}
|
|
382
393
|
|
|
383
|
-
function modelFor(entry) {
|
|
384
|
-
return entry.probe_model ?? entry.model_family ?? 'default';
|
|
385
|
-
}
|
|
386
|
-
|
|
387
394
|
async function timed(fn) {
|
|
388
395
|
const t0 = performance.now();
|
|
389
396
|
try {
|