42 lines
2.1 KiB
JavaScript
42 lines
2.1 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
|
|
function read(relativePath) {
|
|
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
|
}
|
|
|
|
test('clinical assistant starter prompts are Redis or indexed-source backed', () => {
|
|
const route = read('src/routes/clinicalAssistant.js');
|
|
const pool = read('src/utils/clinicalPromptPool.js');
|
|
assert.doesNotMatch(route, /EXAMPLE_CANDIDATES|TOPIC_SUGGESTIONS|topic_suggestions|buildSuggestionAnswer/);
|
|
assert.match(route, /createClinicalPromptPool\(\{[\s\S]*redisCache: redisCache/);
|
|
assert.match(pool, /clinical-assistant:prompt-pool:v2/);
|
|
assert.match(pool, /redisBaseKey \+ ':all'/);
|
|
assert.match(pool, /redisBaseKey \+ ':category:' \+ category/);
|
|
assert.match(pool, /redisBaseKey \+ ':age:' \+ ageBand/);
|
|
assert.match(pool, /redisBaseKey \+ ':intent:' \+ intent/);
|
|
assert.match(pool, /CLINICAL_ASSISTANT_PROMPT_POOL_TARGET, 1000/);
|
|
assert.match(pool, /PEDIATRIC_TAXONOMY/);
|
|
assert.match(pool, /taxonomyWithQuotas\(target\)/);
|
|
assert.match(pool, /age_band: ageBand/);
|
|
assert.match(pool, /function hasPediatricSignal\(prompt, item\)/);
|
|
assert.match(pool, /var examples = await fallbackIndexedExamples\(\)/);
|
|
});
|
|
|
|
test('clinical assistant prompt forbids relabeling other sources as named sources', () => {
|
|
const answer = read('src/utils/clinicalAnswer.js');
|
|
assert.match(answer, /If the user names a specific source, textbook, guideline, or table/);
|
|
assert.match(answer, /do not claim that another source is from the named source/);
|
|
assert.match(answer, /If the named source is absent from the retrieved sources, say that explicitly/);
|
|
});
|
|
|
|
test('clinical assistant prompt requires bracketed citations in table source columns', () => {
|
|
const answer = read('src/utils/clinicalAnswer.js');
|
|
assert.match(answer, /Source, Source\(s\), Citation, or Citation\(s\) column/);
|
|
assert.match(answer, /must use bracketed citation tokens like \[1\] or \[1, 3\]/);
|
|
assert.match(answer, /never bare numbers like 1 or 1, 3/);
|
|
});
|