Skip to content

Commit 744c73a

Browse files
Update gemini.mjs
1 parent 1414f1d commit 744c73a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/llm/gemini.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ export class GeminiProvider extends LLMProvider {
2121
body: JSON.stringify({
2222
systemInstruction: { parts: [{ text: systemPrompt }] },
2323
contents: [{ parts: [{ text: userMessage }] }],
24+
// --- TRAVA DE SEGURANÇA DESATIVADA PARA OSINT ---
25+
safetySettings: [
26+
{ category: "HARM_CATEGORY_HARASSMENT", threshold: "BLOCK_NONE" },
27+
{ category: "HARM_CATEGORY_HATE_SPEECH", threshold: "BLOCK_NONE" },
28+
{ category: "HARM_CATEGORY_SEXUALLY_EXPLICIT", threshold: "BLOCK_NONE" },
29+
{ category: "HARM_CATEGORY_DANGEROUS_CONTENT", threshold: "BLOCK_NONE" }
30+
],
31+
// ------------------------------------------------
2432
generationConfig: {
2533
maxOutputTokens: opts.maxTokens || 4096,
2634
// Trava estrutural para garantir o JSON nativo
@@ -53,8 +61,21 @@ export class GeminiProvider extends LLMProvider {
5361
}
5462

5563
const data = await res.json();
64+
65+
// Fallback de segurança caso a API bloqueie em um nível superior (independente do BLOCK_NONE)
66+
if (data.candidates?.[0]?.finishReason === 'SAFETY') {
67+
console.warn('[LLM] Alerta de Censura: O modelo recusou a análise do feed por violação de segurança.');
68+
}
69+
5670
const text = data.candidates?.[0]?.content?.parts?.[0]?.text || '';
5771

72+
// --- INJEÇÃO DE DEBUG ---
73+
if (!text || text.length < 10) {
74+
console.log("\n[DEBUG CRÍTICO] A IA não retornou texto válido. Resposta bruta da API:");
75+
console.log(JSON.stringify(data, null, 2));
76+
}
77+
// ------------------------
78+
5879
return {
5980
text,
6081
usage: {

0 commit comments

Comments
 (0)