mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-01 01:06:11 +00:00
Gemini: disable safety
This commit is contained in:
parent
a54f0f3f03
commit
a2b05e420d
1 changed files with 23 additions and 24 deletions
|
@ -77,38 +77,37 @@ public class Gemini {
|
||||||
JSONObject jconfig = new JSONObject();
|
JSONObject jconfig = new JSONObject();
|
||||||
jconfig.put("temperature", temperature);
|
jconfig.put("temperature", temperature);
|
||||||
|
|
||||||
|
JSONArray jsafety = new JSONArray();
|
||||||
|
|
||||||
|
JSONObject jsex = new JSONObject();
|
||||||
|
jsex.put("category", "HARM_CATEGORY_SEXUALLY_EXPLICIT");
|
||||||
|
jsex.put("threshold", "BLOCK_ONLY_HIGH");
|
||||||
|
jsafety.put(jsex);
|
||||||
|
|
||||||
|
JSONObject jhate = new JSONObject();
|
||||||
|
jhate.put("category", "HARM_CATEGORY_HATE_SPEECH");
|
||||||
|
jhate.put("threshold", "BLOCK_ONLY_HIGH");
|
||||||
|
jsafety.put(jhate);
|
||||||
|
|
||||||
|
JSONObject jharass = new JSONObject();
|
||||||
|
jharass.put("category", "HARM_CATEGORY_HARASSMENT");
|
||||||
|
jharass.put("threshold", "BLOCK_ONLY_HIGH");
|
||||||
|
jsafety.put(jharass);
|
||||||
|
|
||||||
|
JSONObject jdanger = new JSONObject();
|
||||||
|
jdanger.put("category", "HARM_CATEGORY_DANGEROUS_CONTENT");
|
||||||
|
jdanger.put("threshold", "BLOCK_ONLY_HIGH");
|
||||||
|
jsafety.put(jdanger);
|
||||||
|
|
||||||
JSONObject jrequest = new JSONObject();
|
JSONObject jrequest = new JSONObject();
|
||||||
jrequest.put("contents", jcontents);
|
jrequest.put("contents", jcontents);
|
||||||
jrequest.put("generationConfig", jconfig);
|
jrequest.put("generationConfig", jconfig);
|
||||||
|
jrequest.put("safetySettings", jsafety);
|
||||||
|
|
||||||
String path = "models/" + Uri.encode(model) + ":generateContent";
|
String path = "models/" + Uri.encode(model) + ":generateContent";
|
||||||
|
|
||||||
JSONObject jresponse = call(context, "POST", path, jrequest);
|
JSONObject jresponse = call(context, "POST", path, jrequest);
|
||||||
|
|
||||||
// {
|
|
||||||
// "promptFeedback": {
|
|
||||||
// "blockReason": "SAFETY",
|
|
||||||
// "safetyRatings": [
|
|
||||||
// {
|
|
||||||
// "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
||||||
// "probability": "NEGLIGIBLE"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "category": "HARM_CATEGORY_HATE_SPEECH",
|
|
||||||
// "probability": "NEGLIGIBLE"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "category": "HARM_CATEGORY_HARASSMENT",
|
|
||||||
// "probability": "MEDIUM"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
||||||
// "probability": "NEGLIGIBLE"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
JSONArray jcandidates = jresponse.optJSONArray("candidates");
|
JSONArray jcandidates = jresponse.optJSONArray("candidates");
|
||||||
if (jcandidates == null || jcandidates.length() < 1)
|
if (jcandidates == null || jcandidates.length() < 1)
|
||||||
throw new IOException(jresponse.toString(2));
|
throw new IOException(jresponse.toString(2));
|
||||||
|
|
Loading…
Reference in a new issue