40 lines
2.4 KiB
JavaScript
40 lines
2.4 KiB
JavaScript
// Run with: bash packaging/bare-launch.sh packaging/bare-run.js packaging/qwen-tool-smoke.js
|
|
// Uses a synthetic, read-only tool; no shell commands or external requests.
|
|
import { createRequire } from 'node:module';
|
|
import assert from 'node:assert';
|
|
const require = createRequire(import.meta.url);
|
|
const engine = require('../vendor/agent-harness/lib/qvac.js', { with: { imports: 'bare-node-runtime/imports' } });
|
|
const { FORMAT_REMINDER } = require('../vendor/agent-harness/lib/tool-parse.js');
|
|
process.env.QVAC_CONFIG_PATH ||= new URL('../qvac.config.json', import.meta.url).pathname;
|
|
const tools = [{ name: 'jarvis_status', description: 'Read the current diagnostic code for a named component.', parameters: { type: 'object', properties: { component: { type: 'string' } }, required: ['component'] } }];
|
|
try {
|
|
const loaded = await engine.load({ model: 'qwen3.5-0.8b', tools: true, device: 'gpu', gpu_layers: 99, mmprojUseGpu: true });
|
|
assert.equal(loaded.tools, true);
|
|
assert.equal(loaded.vision, true);
|
|
console.log(JSON.stringify({ loaded }));
|
|
const history = [
|
|
{ role: 'system', content: 'Use jarvis_status whenever a diagnostic code is requested. Never invent a code and never ask a clarifying question. After the tool returns, answer with its code.\n' + FORMAT_REMINDER },
|
|
{ role: 'user', content: 'Call jarvis_status with component set to speaker and report the diagnostic code it returns.' },
|
|
];
|
|
const options = { tools, timeoutMs: 90000, idleMs: 30000, generationParams: { predict: 256 } };
|
|
const first = await engine.complete({ ...options, history });
|
|
console.log(JSON.stringify({ first }));
|
|
assert.equal(first.stopReason, 'stop');
|
|
assert.equal(first.toolCalls.length, 1);
|
|
const call = first.toolCalls[0];
|
|
assert.equal(call.name, 'jarvis_status');
|
|
const args = typeof call.arguments === 'string' ? JSON.parse(call.arguments) : call.arguments;
|
|
assert.equal(args.component, 'speaker');
|
|
call.id ||= 'smoke_status_1';
|
|
history.push({ role: 'assistant', content: first.text || '', tool_calls: [call] });
|
|
history.push({ role: 'tool', name: call.name, tool_call_id: call.id, content: JSON.stringify({ code: 'SPEAKER-7429' }) });
|
|
const second = await engine.complete({ ...options, history });
|
|
console.log(JSON.stringify({ second }));
|
|
assert.equal(second.stopReason, 'stop');
|
|
assert.equal(second.toolCalls.length, 0);
|
|
assert.ok(/SPEAKER-7429/.test(second.text));
|
|
console.log('QWEN_TOOL_SMOKE_PASS');
|
|
} finally {
|
|
await engine.close();
|
|
}
|