Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
67 lines
3.9 KiB
JavaScript
67 lines
3.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdtempSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { createVisionProbe, effectiveVision, modelReadsPictures } from '../server/vision-probe.mjs';
|
|
import { createModelProviders } from '../server/model-providers.mjs';
|
|
|
|
const answer = (routes, seen = []) => async (url, init) => {
|
|
const path = new URL(url).pathname;
|
|
seen.push(path);
|
|
const body = routes[path];
|
|
return body === undefined ? { ok: false, status: 404, json: async () => ({}) } : { ok: true, status: 200, json: async () => body };
|
|
};
|
|
|
|
test('a model list row says whether the model reads pictures in every common shape', () => {
|
|
assert.equal(modelReadsPictures({ architecture: { input_modalities: ['text', 'image'] } }), true);
|
|
assert.equal(modelReadsPictures({ architecture: { input_modalities: ['text'] } }), false);
|
|
assert.equal(modelReadsPictures({ modalities: { input: ['text', 'image'] } }), true);
|
|
assert.equal(modelReadsPictures({ capabilities: ['completion', 'vision'] }), true);
|
|
assert.equal(modelReadsPictures({ capabilities: { vision: false } }), false);
|
|
assert.equal(modelReadsPictures({ id: 'x' }), null);
|
|
assert.equal(modelReadsPictures(null), null);
|
|
});
|
|
|
|
test('what the person ticked wins over what the server said', () => {
|
|
assert.equal(effectiveVision({ vision: true }, false), true);
|
|
assert.equal(effectiveVision({ vision: false }, true), false);
|
|
assert.equal(effectiveVision({ vision: null }, true), true);
|
|
assert.equal(effectiveVision({}, undefined), undefined);
|
|
});
|
|
|
|
test('a llama-server started with --mmproj says so in /props, next to /v1, and the answer is cached', async () => {
|
|
const seen = [];
|
|
const probe = createVisionProbe({ fetcher: answer({ '/v1/models': { data: [{ id: 'smol' }] }, '/props': { modalities: { vision: true } } }, seen) });
|
|
const conn = { id: 'c1', baseUrl: 'http://127.0.0.1:8080/v1' };
|
|
assert.equal(probe.known(conn, 'smol'), undefined);
|
|
assert.equal(await probe.check(conn, 'smol'), true);
|
|
assert.equal(await probe.check(conn, 'smol'), true);
|
|
assert.equal(probe.known(conn, 'smol'), true);
|
|
assert.deepEqual(seen, ['/v1/models', '/props']);
|
|
});
|
|
|
|
test('a text-only server counts as not reading pictures; an unreachable one is unknown (pictures stay on by default)', async () => {
|
|
const text = createVisionProbe({ fetcher: answer({ '/v1/models': { data: [{ id: 'm' }] }, '/props': { modalities: { vision: false } } }) });
|
|
assert.equal(await text.check({ id: 'c', baseUrl: 'http://h/v1' }, 'm'), false);
|
|
const down = createVisionProbe({ fetcher: async () => { throw new Error('refused'); } });
|
|
assert.equal(await down.check({ id: 'c', baseUrl: 'http://h/v1' }, 'm'), null);
|
|
});
|
|
|
|
test('a provider list that names image input is believed without asking /props', async () => {
|
|
const seen = [];
|
|
const probe = createVisionProbe({ fetcher: answer({ '/v1/models': { data: [{ id: 'gpt', architecture: { input_modalities: ['text', 'image'] } }] } }, seen) });
|
|
assert.equal(await probe.check({ id: 'c', baseUrl: 'https://api.example.com/v1' }, 'gpt'), true);
|
|
assert.deepEqual(seen, ['/v1/models']);
|
|
});
|
|
|
|
test('the tick "This model reads pictures" is saved with the model and survives a reload', t => {
|
|
const directory = mkdtempSync(join(tmpdir(), 'strata-vision-'));
|
|
t.after(() => rmSync(directory, { recursive: true, force: true }));
|
|
const service = createModelProviders({ directory });
|
|
const saved = service.save({ kind: 'custom', name: 'Other PC', baseUrl: 'http://192.168.1.20:8080/v1', protocol: 'openai-chat', apiKey: '', models: [{ id: 'smol', name: 'SmolVLM', vision: true }, { id: 'text', name: 'Text only' }] }).connections[0];
|
|
assert.deepEqual(saved.models.map(m => m.vision), [true, null]);
|
|
const again = createModelProviders({ directory }).list().connections[0];
|
|
assert.deepEqual(again.models.map(m => m.vision), [true, null]);
|
|
});
|