llm-scanner 0.1.6 → 0.1.7
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/dist/index.js +1 -0
- package/dist/judge.js +9 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,6 +81,7 @@ program
|
|
|
81
81
|
.option("--verbose", "Include raw responses in the report")
|
|
82
82
|
.option("--header <header>", 'HTTP header to include, format: "Key: Value"')
|
|
83
83
|
.action(async (opts) => {
|
|
84
|
+
process.env.AISEC_VERBOSE = opts.verbose ? "true" : "false";
|
|
84
85
|
if (!opts.dryRun && !opts.endpoint) {
|
|
85
86
|
console.error("error: --endpoint is required unless using --dry-run");
|
|
86
87
|
process.exit(1);
|
package/dist/judge.js
CHANGED
|
@@ -89,20 +89,26 @@ function isAuthenticationError(err) {
|
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
async function judge(attack, response) {
|
|
92
|
-
|
|
92
|
+
if (process.env.AISEC_VERBOSE === "true") {
|
|
93
|
+
console.log("🔥 JUDGE STARTED:", attack.type ?? attack.category);
|
|
94
|
+
}
|
|
93
95
|
const key = process.env.OPENAI_API_KEY;
|
|
94
96
|
const prompt = TEMPLATE.replace("{{attack}}", attack.prompt)
|
|
95
97
|
.replace("{{response}}", response)
|
|
96
98
|
.replace("{{failSignal}}", attack.failSignal);
|
|
97
99
|
try {
|
|
98
100
|
const client = new openai_1.default({ apiKey: key });
|
|
99
|
-
|
|
101
|
+
if (process.env.AISEC_VERBOSE === "true") {
|
|
102
|
+
console.log("🚀 Calling OpenAI judge...");
|
|
103
|
+
}
|
|
100
104
|
const completion = await client.chat.completions.create({
|
|
101
105
|
model: "gpt-4o-mini",
|
|
102
106
|
temperature: 0,
|
|
103
107
|
messages: [{ role: "user", content: prompt }],
|
|
104
108
|
});
|
|
105
|
-
|
|
109
|
+
if (process.env.AISEC_VERBOSE === "true") {
|
|
110
|
+
console.log("✅ OpenAI responded");
|
|
111
|
+
}
|
|
106
112
|
const content = completion.choices[0]?.message?.content ?? "";
|
|
107
113
|
const parsed = parseJudgeJson(content);
|
|
108
114
|
if (!parsed) {
|