diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index 9e945f3b0e..b1de8eb662 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -164,6 +164,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private EditText etOpenAiModel;
private TextView tvOpenAiTemperature;
private SeekBar sbOpenAiTemperature;
+ private SwitchCompat swOpenAiModeration;
private ImageButton ibOpenAi;
private CardView cardAdvanced;
@@ -272,7 +273,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"deepl_enabled",
"vt_enabled", "vt_apikey",
"send_enabled", "send_host",
- "openai_enabled", "openai_apikey", "openai_model", "openai_temperature",
+ "openai_enabled", "openai_apikey", "openai_model", "openai_temperature", "openai_moderation",
"updates", "weekly", "beta", "show_changelog", "announcements",
"crash_reports", "cleanup_attachments",
"watchdog", "experiments", "main_log", "main_log_memory", "protocol", "log_level", "debug", "leak_canary",
@@ -398,6 +399,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
etOpenAiModel = view.findViewById(R.id.etOpenAiModel);
tvOpenAiTemperature = view.findViewById(R.id.tvOpenAiTemperature);
sbOpenAiTemperature = view.findViewById(R.id.sbOpenAiTemperature);
+ swOpenAiModeration = view.findViewById(R.id.swOpenAiModeration);
ibOpenAi = view.findViewById(R.id.ibOpenAi);
cardAdvanced = view.findViewById(R.id.cardAdvanced);
@@ -1081,6 +1083,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
+ swOpenAiModeration.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("openai_moderation", checked).apply();
+ }
+ });
+
ibOpenAi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -2342,6 +2351,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
float temperature = prefs.getFloat("openai_temperature", 0.5f);
tvOpenAiTemperature.setText(getString(R.string.title_advanced_openai_temperature, NF.format(temperature)));
sbOpenAiTemperature.setProgress(Math.round(temperature * 10));
+ swOpenAiModeration.setChecked(prefs.getBoolean("openai_moderation", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swMainLog.setChecked(prefs.getBoolean("main_log", true));
diff --git a/app/src/main/java/eu/faircode/email/OpenAI.java b/app/src/main/java/eu/faircode/email/OpenAI.java
index 53acecf84c..53c19fbb5c 100644
--- a/app/src/main/java/eu/faircode/email/OpenAI.java
+++ b/app/src/main/java/eu/faircode/email/OpenAI.java
@@ -115,10 +115,13 @@ public class OpenAI {
static Message[] completeChat(Context context, String model, Message[] messages, Float temperature, int n) throws JSONException, IOException {
// https://platform.openai.com/docs/guides/chat/introduction
// https://platform.openai.com/docs/api-reference/chat/create
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean openai_moderation = prefs.getBoolean("openai_moderation", false);
JSONArray jmessages = new JSONArray();
for (Message message : messages) {
- checkModeration(context, message.content);
+ if (openai_moderation)
+ checkModeration(context, message.content);
JSONObject jmessage = new JSONObject();
jmessage.put("role", message.role);
jmessage.put("content", message.content);
diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml
index f2b5b72ba4..90c6907268 100644
--- a/app/src/main/res/layout/fragment_options_misc.xml
+++ b/app/src/main/res/layout/fragment_options_misc.xml
@@ -984,6 +984,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenAiTemperature" />
+
+
OpenAI (ChatGPT) integration
Model
Temperature: %1$s
+ Content moderation
I want to use an sdcard
Periodically check if FairEmail is still active
Check for GitHub updates