Skip to content

Commit

Permalink
Auxiliary role is only asserted without LLM_ZERO_SHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Jun 27, 2024
1 parent ebed153 commit 231f260
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions query-llm.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,30 +575,32 @@ const evaluate = async (filename) => {
LLM_DEBUG_FAIL_EXIT && process.exit(-1);
}
}
} else if (role === 'Pipeline.Reason.Keyphrases' || role === 'Pipeline.Reason.Topic') {
const expected = content;
const last = history.slice(-1).pop();
if (!last) {
console.error('There is no answer yet!');
process.exit(-1);
} else {
const { keyphrases, topic, stages } = last;
const target = (role === 'Pipeline.Reason.Keyphrases') ? keyphrases : topic;
const regexes = regexify(expected);
const matches = match(target, regexes);
if (matches.length === regexes.length) {
console.log(`${GRAY} ${ARROW} ${role}:`, highlight(target, matches, GREEN));
} else if (!LLM_ZERO_SHOT) {
if (role === 'Pipeline.Reason.Keyphrases' || role === 'Pipeline.Reason.Topic') {
const expected = content;
const last = history.slice(-1).pop();
if (!last) {
console.error('There is no answer yet!');
process.exit(-1);
} else {
++failures;
console.error(`${RED}Expected ${role} to contain: ${CYAN}${regexes.join(',')}${NORMAL}`);
console.error(`${RED}Actual ${role}: ${MAGENTA}${target}${NORMAL}`);
review(simplify(stages));
LLM_DEBUG_FAIL_EXIT && process.exit(-1);
const { keyphrases, topic, stages } = last;
const target = (role === 'Pipeline.Reason.Keyphrases') ? keyphrases : topic;
const regexes = regexify(expected);
const matches = match(target, regexes);
if (matches.length === regexes.length) {
console.log(`${GRAY} ${ARROW} ${role}:`, highlight(target, matches, GREEN));
} else {
++failures;
console.error(`${RED}Expected ${role} to contain: ${CYAN}${regexes.join(',')}${NORMAL}`);
console.error(`${RED}Actual ${role}: ${MAGENTA}${target}${NORMAL}`);
review(simplify(stages));
LLM_DEBUG_FAIL_EXIT && process.exit(-1);
}
}
} else {
console.error(`Unknown role: ${role}!`);
handle.exit(-1);
}
} else {
console.error(`Unknown role: ${role}!`);
handle.exit(-1);
}
}
};
Expand Down

0 comments on commit 231f260

Please sign in to comment.