diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 8a9b2709fe..bb633adad7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -2702,8 +2702,8 @@ public class FragmentCompose extends FragmentBase { return null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - String model = prefs.getString("openai_model", "gpt-3.5-turbo"); - float temperature = prefs.getFloat("openai_temperature", 0.5f); + String model = prefs.getString("openai_model", OpenAI.DEFAULT_MODEL); + float temperature = prefs.getFloat("openai_temperature", OpenAI.DEFAULT_TEMPERATURE); boolean moderation = prefs.getBoolean("openai_moderation", false); if (moderation) @@ -2800,8 +2800,8 @@ public class FragmentCompose extends FragmentBase { boolean selection = args.getBoolean("selection"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - String model = prefs.getString("gemini_model", "gemini-pro"); - float temperature = prefs.getFloat("gemini_temperature", 0.9f); + String model = prefs.getString("gemini_model", Gemini.DEFAULT_MODEL); + float temperature = prefs.getFloat("gemini_temperature", Gemini.DEFAULT_TEMPERATURE); Gemini.Message message = new Gemini.Message(Gemini.USER, new String[]{Gemini.truncateParagraphs(body)}); diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java b/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java index 59ae2e0615..8b790856aa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java @@ -109,8 +109,8 @@ public class FragmentDialogSummarize extends FragmentDialogBase { return null; if (OpenAI.isAvailable(context)) { - String model = prefs.getString("openai_model", "gpt-3.5-turbo"); - float temperature = prefs.getFloat("openai_temperature", 0.5f); + String model = prefs.getString("openai_model", OpenAI.DEFAULT_MODEL); + float temperature = prefs.getFloat("openai_temperature", OpenAI.DEFAULT_TEMPERATURE); String prompt = prefs.getString("openai_summarize", OpenAI.SUMMARY_PROMPT); List result = new ArrayList<>(); @@ -130,8 +130,8 @@ public class FragmentDialogSummarize extends FragmentDialogBase { } return sb.toString(); } else if (Gemini.isAvailable(context)) { - String model = prefs.getString("gemini_model", "gemini-pro"); - float temperature = prefs.getFloat("gemini_temperature", 0.9f); + String model = prefs.getString("gemini_model", Gemini.DEFAULT_MODEL); + float temperature = prefs.getFloat("gemini_temperature", Gemini.DEFAULT_TEMPERATURE); String prompt = prefs.getString("gemini_summarize", Gemini.SUMMARY_PROMPT); Gemini.Message message = new Gemini.Message(Gemini.USER, new String[]{prompt, text}); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsIntegrations.java b/app/src/main/java/eu/faircode/email/FragmentOptionsIntegrations.java index 8da3a6d4fe..bd201b7777 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsIntegrations.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsIntegrations.java @@ -480,6 +480,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP } }); + etOpenAiModel.setHint(OpenAI.DEFAULT_MODEL); etOpenAiModel.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -618,6 +619,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP } }); + etGeminiModel.setHint(Gemini.DEFAULT_MODEL); etGeminiModel.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -787,7 +789,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP etOpenAiModel.setText(prefs.getString("openai_model", null)); etOpenAiModel.setEnabled(swOpenAi.isChecked()); - float temperature = prefs.getFloat("openai_temperature", 0.5f); + float temperature = prefs.getFloat("openai_temperature", OpenAI.DEFAULT_TEMPERATURE); tvOpenAiTemperature.setText(getString(R.string.title_advanced_openai_temperature, NF.format(temperature))); sbOpenAiTemperature.setProgress(Math.round(temperature * 10)); sbOpenAiTemperature.setEnabled(swOpenAi.isChecked()); @@ -804,7 +806,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP etGeminiModel.setText(prefs.getString("gemini_model", null)); etGeminiModel.setEnabled(swGemini.isChecked()); - temperature = prefs.getFloat("gemini_temperature", 0.9f); + temperature = prefs.getFloat("gemini_temperature", Gemini.DEFAULT_TEMPERATURE); tvGeminiTemperature.setText(getString(R.string.title_advanced_openai_temperature, NF.format(temperature))); sbGeminiTemperature.setProgress(Math.round(temperature * 10)); sbGeminiTemperature.setEnabled(swGemini.isChecked()); diff --git a/app/src/main/java/eu/faircode/email/Gemini.java b/app/src/main/java/eu/faircode/email/Gemini.java index cd5523424c..9f4b139dfa 100644 --- a/app/src/main/java/eu/faircode/email/Gemini.java +++ b/app/src/main/java/eu/faircode/email/Gemini.java @@ -42,6 +42,8 @@ import java.util.Objects; public class Gemini { // https://ai.google.dev/models/gemini + static final String DEFAULT_MODEL = "gemini-pro"; + static final float DEFAULT_TEMPERATURE = 0.9f; static final String MODEL = "model"; static final String USER = "user"; static final String SUMMARY_PROMPT = "Summarize the following text:"; diff --git a/app/src/main/java/eu/faircode/email/OpenAI.java b/app/src/main/java/eu/faircode/email/OpenAI.java index 724a564dd8..9048ee198b 100644 --- a/app/src/main/java/eu/faircode/email/OpenAI.java +++ b/app/src/main/java/eu/faircode/email/OpenAI.java @@ -42,6 +42,8 @@ import java.util.List; import java.util.Objects; public class OpenAI { + static final String DEFAULT_MODEL = "gpt-4o"; + static final float DEFAULT_TEMPERATURE = 0.5f; static final String ASSISTANT = "assistant"; static final String USER = "user"; static final String SUMMARY_PROMPT = "Summarize the following text:"; diff --git a/app/src/main/res/layout/fragment_options_integrations.xml b/app/src/main/res/layout/fragment_options_integrations.xml index 402d8669ed..95ed418c83 100644 --- a/app/src/main/res/layout/fragment_options_integrations.xml +++ b/app/src/main/res/layout/fragment_options_integrations.xml @@ -558,7 +558,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="12dp" - android:hint="gpt-3.5-turbo" android:inputType="text" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintEnd_toEndOf="parent" @@ -743,7 +742,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="12dp" - android:hint="gemini-pro" android:inputType="text" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintEnd_toEndOf="parent"