Refactoring

pull/215/head
M66B 8 months ago
parent 3f06073664
commit ae25f0017c

@ -61,9 +61,9 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
int message_zoom = prefs.getInt("message_zoom", 100);
String prompt;
if (OpenAI.isAvailable(context))
prompt = prefs.getString("openai_summarize", OpenAI.SUMMARY_PROMPT);
prompt = prefs.getString("openai_summarize", OpenAI.DEFAULT_SUMMARY_PROMPT);
else if (Gemini.isAvailable(context))
prompt = prefs.getString("gemini_summarize", Gemini.SUMMARY_PROMPT);
prompt = prefs.getString("gemini_summarize", Gemini.DEFAULT_SUMMARY_PROMPT);
else
prompt = getString(R.string.title_summarize);
@ -111,7 +111,7 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
if (OpenAI.isAvailable(context)) {
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);
String prompt = prefs.getString("openai_summarize", OpenAI.DEFAULT_SUMMARY_PROMPT);
List<OpenAI.Message> result = new ArrayList<>();
result.add(new OpenAI.Message(OpenAI.ASSISTANT,
@ -132,7 +132,7 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
} else if (Gemini.isAvailable(context)) {
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);
String prompt = prefs.getString("gemini_summarize", Gemini.DEFAULT_SUMMARY_PROMPT);
Gemini.Message message = new Gemini.Message(Gemini.USER, new String[]{prompt, text});

@ -517,7 +517,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
}
});
etOpenAiSummarize.setHint(OpenAI.SUMMARY_PROMPT);
etOpenAiSummarize.setHint(OpenAI.DEFAULT_SUMMARY_PROMPT);
etOpenAiSummarize.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -649,7 +649,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
}
});
etGeminiSummarize.setHint(Gemini.SUMMARY_PROMPT);
etGeminiSummarize.setHint(Gemini.DEFAULT_SUMMARY_PROMPT);
etGeminiSummarize.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@ -44,9 +44,10 @@ 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 DEFAULT_SUMMARY_PROMPT = "Summarize the following text:";
static final String MODEL = "model";
static final String USER = "user";
static final String SUMMARY_PROMPT = "Summarize the following text:";
private static final int MAX_GEMINI_LEN = 4000; // characters
private static final int TIMEOUT = 30; // seconds

@ -44,9 +44,10 @@ import java.util.Objects;
public class OpenAI {
static final String DEFAULT_MODEL = "gpt-4o";
static final float DEFAULT_TEMPERATURE = 0.5f;
static final String DEFAULT_SUMMARY_PROMPT = "Summarize the following text:";
static final String ASSISTANT = "assistant";
static final String USER = "user";
static final String SUMMARY_PROMPT = "Summarize the following text:";
// https://cookbook.openai.com/examples/gpt4o/introduction_to_gpt4o
static final String CONTENT_TEXT = "text";

Loading…
Cancel
Save