pediatric-ai-scribe-v3/test/assistant-image-intent.test.js
Daniel 7833018695
All checks were successful
Forgejo Android APK / Build signed APK (push) Successful in 1m47s
Sanitize citations from clinical image prompts
2026-09-02 01:47:32 +02:00

27 lines
1.2 KiB
JavaScript

const { test } = require('node:test');
const assert = require('node:assert/strict');
const path = require('node:path');
const { pathToFileURL } = require('node:url');
async function imagesModule() {
return import(pathToFileURL(path.join(__dirname, '..', 'public/js/assistant/images.js')).href);
}
test('assistant image intent does not intercept table retrieval requests', async () => {
const { isImageRequest } = await imagesModule();
assert.equal(isImageRequest('can you show me the table?'), false);
assert.equal(isImageRequest('show me Table 13.1'), false);
});
test('clinical image prompts strip normal, escaped, and footnote citations', async () => {
const { buildContextualImagePrompt } = await imagesModule();
const prompt = buildContextualImagePrompt('Create a teaching visual', 'Claim [1], escaped \\[2, 3\\], and footnote [^4].');
assert.doesNotMatch(prompt, /\[1\]|\\\[2, 3\\\]|\[\^4\]/);
assert.match(prompt, /Do not include citations/);
});
test('assistant image intent still handles explicit visual requests', async () => {
const { isImageRequest } = await imagesModule();
assert.equal(isImageRequest('show me the diagram'), true);
assert.equal(isImageRequest('create an infographic for asthma'), true);
});