mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
Gemini: fixed temperature range
This commit is contained in:
parent
12e79ce7e9
commit
a207b73082
2 changed files with 5 additions and 5 deletions
|
@ -642,7 +642,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
|
|||
sbGeminiTemperature.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
float temp = progress / 20f;
|
||||
float temp = progress / 10f;
|
||||
prefs.edit().putFloat("gemini_temperature", temp).apply();
|
||||
}
|
||||
|
||||
|
@ -806,7 +806,7 @@ public class FragmentOptionsIntegrations extends FragmentBase implements SharedP
|
|||
|
||||
temperature = prefs.getFloat("gemini_temperature", 0.5f);
|
||||
tvGeminiTemperature.setText(getString(R.string.title_advanced_openai_temperature, NF.format(temperature)));
|
||||
sbGeminiTemperature.setProgress(Math.round(temperature * 20));
|
||||
sbGeminiTemperature.setProgress(Math.round(temperature * 10));
|
||||
sbGeminiTemperature.setEnabled(swGemini.isChecked());
|
||||
|
||||
etGeminiSummarize.setText(prefs.getString("gemini_summarize", null));
|
||||
|
|
|
@ -62,6 +62,7 @@ public class Gemini {
|
|||
}
|
||||
|
||||
static Message[] generate(Context context, String model, Message[] messages, Float temperature, int n) throws JSONException, IOException {
|
||||
//https://ai.google.dev/api/rest/v1beta/models/generateContent
|
||||
JSONArray jcontents = new JSONArray();
|
||||
for (Message message : messages) {
|
||||
JSONArray jparts = new JSONArray();
|
||||
|
@ -78,13 +79,13 @@ public class Gemini {
|
|||
jcontents.put(jcontent);
|
||||
}
|
||||
|
||||
// https://ai.google.dev/api/python/google/ai/generativelanguage/GenerationConfig
|
||||
// https://ai.google.dev/api/rest/v1beta/GenerationConfig
|
||||
JSONObject jconfig = new JSONObject();
|
||||
if (temperature != null)
|
||||
jconfig.put("temperature", temperature);
|
||||
jconfig.put("candidate_count", n);
|
||||
|
||||
// https://ai.google.dev/api/python/google/ai/generativelanguage/SafetySetting
|
||||
// https://ai.google.dev/api/rest/v1beta/SafetySetting
|
||||
JSONArray jsafety = new JSONArray();
|
||||
|
||||
JSONObject jsex = new JSONObject();
|
||||
|
@ -107,7 +108,6 @@ public class Gemini {
|
|||
jdanger.put("threshold", "BLOCK_ONLY_HIGH");
|
||||
jsafety.put(jdanger);
|
||||
|
||||
// https://ai.google.dev/api/python/google/ai/generativelanguage/GenerateContentRequest
|
||||
JSONObject jrequest = new JSONObject();
|
||||
jrequest.put("contents", jcontents);
|
||||
jrequest.put("generationConfig", jconfig);
|
||||
|
|
Loading…
Reference in a new issue