From 91d0d2d297cb38fe0dfdfd7f73df355e2f51096a Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Tue, 21 Apr 2026 21:53:16 +0200 Subject: [PATCH] fix: update response format for phishing analysis and improve JSON parsing comment --- apps/api/src/services/SecurityService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/SecurityService.ts b/apps/api/src/services/SecurityService.ts index 227b358..f4b6e9d 100644 --- a/apps/api/src/services/SecurityService.ts +++ b/apps/api/src/services/SecurityService.ts @@ -754,7 +754,7 @@ export class SecurityService { messages: [ { role: 'system', - content: `You are a security expert analyzing emails for phishing, scams, and dangerous content. Analyze the email subject and body and respond ONLY with a JSON object in this exact format: + content: `You are a security expert analyzing emails for phishing, scams, and dangerous content. Analyze the email subject and body and respond with a JSON object in this exact format: { "is_phishing": true/false, "confidence": 0-100, @@ -781,6 +781,7 @@ Set confidence to 100 only if you are absolutely certain it's phishing.`, ], temperature: 0.1, max_tokens: 200, + response_format: {type: 'json_object'}, }), }); @@ -799,7 +800,7 @@ Set confidence to 100 only if you are absolutely certain it's phishing.`, return safeResponse; } - // Parse the JSON response + // Parse the JSON response (response_format ensures clean JSON) const result = JSON.parse(content) as { is_phishing: boolean; confidence: number;