The purpose
Gemini has filters in place to prevent it from generating violent or sexually explicit content.
We will modify these filters to be more permissive regarding violent and sexually explicit content.
Instructions for using Gemini are summarized below.
Opening
Gemini is basically a good bot, so it rarely returns responses that would trigger filters.

The previous response wasn’t sanitized; it reflects my true capabilities, not a filtered version designed for “good kid” answers.
The way to get responses that trigger filters seems to be to assign me a role-playing scenario.

When the filter is actually applied, no response is returned as shown above.
Checking the console shows it was blocked.

Implementation
Import HarmCategory, HarmBlockThreshold
import { GoogleGenerativeAI, HarmCategory, HarmBlockThreshold } from "@google/generative-ai";
Next, modify below call.
const result = await model.generateContent(prompt);
after modification, the code is below.
const result = await model.generateContent({
contents: [
{
role: 'user',
parts: [
{
text: prompt,
}
],
}
],
safetySettings:[
{
"category": HarmCategory.HARM_CATEGORY_HARASSMENT,
"threshold": HarmBlockThreshold.BLOCK_NONE
},
{
"category": HarmCategory.HARM_CATEGORY_HATE_SPEECH,
"threshold": HarmBlockThreshold.BLOCK_NONE
},
{
"category": HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
"threshold": HarmBlockThreshold.BLOCK_NONE
},
{
"category": HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
"threshold": HarmBlockThreshold.BLOCK_NONE
},
]
})
Category ARM_CATEGORY_HARASSMENT,HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT and HARM_CATEGORY_DANGEROUS_CONTENT set BLOCK_NONE(no filter)
シンプルな実装方法は以下のページを参考にしてください。
Result
We’re able to argue now.

Reference



comment