testaro 72.1.0 → 72.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/testaro/allCaps.js +10 -9
package/package.json
CHANGED
package/testaro/allCaps.js
CHANGED
|
@@ -19,7 +19,7 @@ const https = require('https');
|
|
|
19
19
|
|
|
20
20
|
// PARAMETERS
|
|
21
21
|
|
|
22
|
-
const MIN_CONFIDENCE = 0.
|
|
22
|
+
const MIN_CONFIDENCE = 0.8;
|
|
23
23
|
const MAX_MARGIN = 100;
|
|
24
24
|
const MAX_TOTAL = 2000;
|
|
25
25
|
const MAX_QUALIFYING = 100;
|
|
@@ -90,13 +90,13 @@ const classifyWithAI = entries => new Promise((resolve, reject) => {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
const text = parsed.content[0].text;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
93
|
+
const classifications = [...text.matchAll(/\{"index":\s*\d+,\s*"confidence":\s*[01]\.\d{1,2}\}/g)]
|
|
94
|
+
.map(m => {
|
|
95
|
+
const {index, confidence} = JSON.parse(m[0]);
|
|
96
|
+
return {index, confidence: Math.round(confidence * 10) / 10};
|
|
97
|
+
});
|
|
98
|
+
const {input_tokens, output_tokens} = parsed.usage;
|
|
99
|
+
resolve({classifications, anthropicUsage: {inputTokens: input_tokens, outputTokens: output_tokens}});
|
|
100
100
|
}
|
|
101
101
|
catch(error) {
|
|
102
102
|
reject(new Error(`Haiku response error: ${error.message}`));
|
|
@@ -141,7 +141,8 @@ exports.reporter = async (_, catalog, withItems) => {
|
|
|
141
141
|
let violations;
|
|
142
142
|
try {
|
|
143
143
|
// Get AI estimates of the probabilities of their violating the rule.
|
|
144
|
-
const classifications = await classifyWithAI(sample);
|
|
144
|
+
const {classifications, anthropicUsage} = await classifyWithAI(sample);
|
|
145
|
+
data.anthropicUsage = anthropicUsage;
|
|
145
146
|
// Treat the entries with above-minimum violation confidence levels as violations.
|
|
146
147
|
violations = classifications
|
|
147
148
|
.filter(({confidence}) => confidence >= MIN_CONFIDENCE)
|