Commit 87f866e5 by PLN (Algolia)

tests: sélection des modèles et champs anti-raisonnement du payload

parent c4387bce
...@@ -17,10 +17,17 @@ const CLI = fileURLToPath(new URL('../bin/buvard.js', import.meta.url)); ...@@ -17,10 +17,17 @@ const CLI = fileURLToPath(new URL('../bin/buvard.js', import.meta.url));
const SLOPPY = 'Soyons honnêtes : le montage cassait. Il est essentiel de noter que le débit tombait à 5 Go/s.'; const SLOPPY = 'Soyons honnêtes : le montage cassait. Il est essentiel de noter que le débit tombait à 5 Go/s.';
/** Un faux LM Studio : POST unique, réponse JSON, port éphémère sur 127.0.0.1. */ /** Un faux LM Studio : POST unique, réponse JSON, port éphémère sur 127.0.0.1.
function mockServer(handler) { * GET /v1/models répond la liste `models` (un seul modèle par défaut : il
* passe quoi qu'il en soit — cf. la sélection dans lib/fix.mjs). */
function mockServer(handler, models) {
return new Promise((resolve) => { return new Promise((resolve) => {
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {
if (req.method === 'GET') {
res.setHeader('content-type', 'application/json');
res.end(JSON.stringify({ data: models ?? [{ id: 'local-model' }] }));
return;
}
let raw = ''; let raw = '';
req.on('data', (c) => (raw += c)); req.on('data', (c) => (raw += c));
req.on('end', () => handler(JSON.parse(raw), res)); req.on('end', () => handler(JSON.parse(raw), res));
...@@ -197,3 +204,38 @@ test('the CLI --json reports the whole structured result', async () => { ...@@ -197,3 +204,38 @@ test('the CLI --json reports the whole structured result', async () => {
assert.equal(parsed.fix.rounds[0].suggestions[0].status, 'appliquée'); assert.equal(parsed.fix.rounds[0].suggestions[0].status, 'appliquée');
assert.match(parsed.fix.diff, /^-/m); assert.match(parsed.fix.diff, /^-/m);
}); });
test('model listing honored: the first non-reasoning id wins', async () => {
const { server, url } = await mockServer(
(body, res) => reply(res, jsonOf([{ excerpt: 'Soyons honnêtes : ', suggestion: '', rule: 'ouverture-vide', why: 'x' }])),
[{ id: 'deepseek-r1-32b' }, { id: 'qwen2.5-7b-instruct' }],
);
const r = await fixText(SLOPPY, { url, maxRounds: 1 });
server.close();
assert.equal(r.model, 'qwen2.5-7b-instruct');
});
test('an all-reasoning listing fails clean, pointing at BUVARD_FIX_MODEL', async () => {
const { server, url } = await mockServer(() => {}, [{ id: 'deepseek-r1' }, { id: 'qwq-32b' }]);
await assert.rejects(
() => fixText(SLOPPY, { url, maxRounds: 1 }),
(e) => {
assert.ok(e instanceof FixError);
assert.match(e.message, /BUVARD_FIX_MODEL/);
return true;
},
);
server.close();
});
test('the payload always carries the reasoning-off fields, explicit model included', async () => {
let payload = null;
const { server, url } = await mockServer((body, res) => {
payload = body;
reply(res, jsonOf([{ excerpt: 'Soyons honnêtes : ', suggestion: '', rule: 'ouverture-vide', why: 'x' }]));
});
await fixText(SLOPPY, { url, maxRounds: 1, model: 'deepseek-r1-32b' });
server.close();
assert.equal(payload.reasoning_effort, 'low');
assert.deepEqual(payload.chat_template_kwargs, { enable_thinking: false });
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment