@drsamonline/prober 0.12.34 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +16 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drsamonline/prober",
3
- "version": "0.12.34",
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",
package/src/index.js CHANGED
@@ -202,11 +202,17 @@ export async function probeTarget(entry, opts = {}) {
202
202
  reasons,
203
203
  };
204
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
+
205
211
  levels.readiness = await timed(async () => {
206
212
  const res = await fetchImpl(`${base}/chat/completions`, {
207
213
  method: 'POST',
208
214
  headers,
209
- body: JSON.stringify({ model: probeModel(entry, discoveredModels), ...FIXTURES.readiness }),
215
+ body: JSON.stringify({ model: provenModel, ...FIXTURES.readiness }),
210
216
  signal: AbortSignal.timeout(timeoutMs),
211
217
  });
212
218
  if (!res.ok) {
@@ -225,15 +231,15 @@ export async function probeTarget(entry, opts = {}) {
225
231
  const capabilities = opts.capabilities ?? entry.capabilities ?? [];
226
232
  if (levels.readiness.ok) {
227
233
  if (capabilities.includes('streaming')) {
228
- levels.suitability.streaming = await probeStreaming({ fetchImpl, base, headers, entry, timeoutMs });
234
+ levels.suitability.streaming = await probeStreaming({ fetchImpl, base, headers, entry, timeoutMs, model: provenModel });
229
235
  if (!levels.suitability.streaming.ok) reasons.push(`streaming: ${levels.suitability.streaming.note}`);
230
236
  }
231
237
  if (capabilities.includes('json_schema')) {
232
- 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 });
233
239
  if (!levels.suitability.json_schema.ok) reasons.push(`json_schema: ${levels.suitability.json_schema.note}`);
234
240
  }
235
241
  if (capabilities.includes('tools')) {
236
- levels.suitability.tools = await probeTools({ fetchImpl, base, headers, entry, timeoutMs });
242
+ levels.suitability.tools = await probeTools({ fetchImpl, base, headers, entry, timeoutMs, model: provenModel });
237
243
  if (!levels.suitability.tools.ok) reasons.push(`tools: ${levels.suitability.tools.note}`);
238
244
  }
239
245
  }
@@ -260,12 +266,12 @@ export async function probeTarget(entry, opts = {}) {
260
266
  }
261
267
 
262
268
  /** Streaming must be a real event sequence, not one blob pretending to be SSE. */
263
- async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs }) {
269
+ async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs, model }) {
264
270
  return timed(async () => {
265
271
  const res = await fetchImpl(`${base}/chat/completions`, {
266
272
  method: 'POST',
267
273
  headers,
268
- body: JSON.stringify({ model: modelFor(entry), stream: true, ...FIXTURES.readiness }),
274
+ body: JSON.stringify({ model, stream: true, ...FIXTURES.readiness }),
269
275
  signal: AbortSignal.timeout(timeoutMs),
270
276
  });
271
277
  if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status}` };
@@ -322,12 +328,12 @@ async function probeStreaming({ fetchImpl, base, headers, entry, timeoutMs }) {
322
328
  }
323
329
 
324
330
  /** A JSON request has to come back as JSON, not as a promise to be JSON. */
325
- async function probeJson({ fetchImpl, base, headers, entry, timeoutMs }) {
331
+ async function probeJson({ fetchImpl, base, headers, entry, timeoutMs, model }) {
326
332
  return timed(async () => {
327
333
  const res = await fetchImpl(`${base}/chat/completions`, {
328
334
  method: 'POST',
329
335
  headers,
330
- body: JSON.stringify({ model: modelFor(entry), ...FIXTURES.jsonSchema }),
336
+ body: JSON.stringify({ model, ...FIXTURES.jsonSchema }),
331
337
  signal: AbortSignal.timeout(timeoutMs),
332
338
  });
333
339
  if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status}` };
@@ -349,12 +355,12 @@ async function probeJson({ fetchImpl, base, headers, entry, timeoutMs }) {
349
355
  * shape — not that the model chose to call the tool. Refusing to call a tool is a
350
356
  * legitimate answer; a 400 is not.
351
357
  */
352
- async function probeTools({ fetchImpl, base, headers, entry, timeoutMs }) {
358
+ async function probeTools({ fetchImpl, base, headers, entry, timeoutMs, model }) {
353
359
  return timed(async () => {
354
360
  const res = await fetchImpl(`${base}/chat/completions`, {
355
361
  method: 'POST',
356
362
  headers,
357
- body: JSON.stringify({ model: modelFor(entry), ...FIXTURES.tools }),
363
+ body: JSON.stringify({ model, ...FIXTURES.tools }),
358
364
  signal: AbortSignal.timeout(timeoutMs),
359
365
  });
360
366
  if (!res.ok) return { ok: false, status: res.status, note: `HTTP ${res.status} — tools rejected` };
@@ -385,10 +391,6 @@ function probeModel(entry, discovered = []) {
385
391
  return 'default';
386
392
  }
387
393
 
388
- function modelFor(entry) {
389
- return entry.probe_model ?? entry.model_family ?? 'default';
390
- }
391
-
392
394
  async function timed(fn) {
393
395
  const t0 = performance.now();
394
396
  try {