Skip to content

Commit 5a0ec54

Browse files
authored
Write LLM verification results to file (#162)
1 parent aaa0a69 commit 5a0ec54

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

post-processing/detect-cookie-popups.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,12 @@ async function main() {
264264
await fs.promises.writeFile(otherButtonTextsFile, Array.from(otherButtonTexts).join('\n'));
265265

266266
console.log('Verifying button texts...');
267-
await verifyButtonTexts({
267+
const verificationResults = await verifyButtonTexts({
268268
openai,
269269
rejectButtonTextsFile,
270270
otherButtonTextsFile,
271271
});
272+
await fs.promises.writeFile(path.join(crawlDir, '..', 'verification-results.json'), JSON.stringify(verificationResults, null, 2));
272273

273274
console.log('Done');
274275
console.log(

post-processing/generate-autoconsent-rules/verification.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fs = require('fs');
99
* rejectButtonTextsFile: string,
1010
* otherButtonTextsFile: string,
1111
* }} params
12+
* @returns {Promise<{ falsePositive: { potentiallyIncorrectRejectButtons?: string[] }, falseNegative: { potentiallyMissedRejectButtons?: string[] } }>}
1213
*/
1314
async function verifyButtonTexts({ openai, rejectButtonTextsFile, otherButtonTextsFile }) {
1415
const FalsePositiveSuggestions = z.object({
@@ -17,6 +18,10 @@ async function verifyButtonTexts({ openai, rejectButtonTextsFile, otherButtonTex
1718
const FalseNegativeSuggestions = z.object({
1819
potentiallyMissedRejectButtons: z.array(z.string()),
1920
});
21+
const results = {
22+
falsePositive: {},
23+
falseNegative: {},
24+
};
2025

2126
const systemPromptFalsePositive = `
2227
You are a helpful assistant that reviews the results of button text classification.
@@ -47,6 +52,7 @@ async function verifyButtonTexts({ openai, rejectButtonTextsFile, otherButtonTex
4752
});
4853
const resultFalsePositive = completionFalsePositive.choices[0].message.parsed;
4954
console.log(resultFalsePositive);
55+
results.falsePositive = resultFalsePositive;
5056
} catch (error) {
5157
console.error('Error classifying false positives:', error);
5258
}
@@ -66,9 +72,11 @@ async function verifyButtonTexts({ openai, rejectButtonTextsFile, otherButtonTex
6672
});
6773
const resultFalseNegative = completionFalseNegative.choices[0].message.parsed;
6874
console.log(resultFalseNegative);
75+
results.falseNegative = resultFalseNegative;
6976
} catch (error) {
7077
console.error('Error classifying false negatives:', error);
7178
}
79+
return results;
7280
}
7381

7482
module.exports = {

0 commit comments

Comments
 (0)