Revert "Added OpenAI Uri option"

This reverts commit ca9001dcf5.
This commit is contained in:
M66B 2023-05-29 17:48:38 +02:00
parent ca9001dcf5
commit 30af9cebcf
3 changed files with 4 additions and 48 deletions

View File

@ -161,7 +161,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private ImageButton ibSend;
private SwitchCompat swOpenAi;
private TextView tvOpenAiPrivacy;
private EditText etOpenAi;
private TextInputLayout tilOpenAi;
private EditText etOpenAiModel;
private TextView tvOpenAiTemperature;
@ -281,7 +280,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"deepl_enabled",
"vt_enabled", "vt_apikey",
"send_enabled", "send_host", "send_dlimit", "send_tlimit",
"openai_enabled", "openai_uri", "openai_apikey", "openai_model", "openai_temperature", "openai_moderation",
"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",
@ -407,7 +406,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ibSend = view.findViewById(R.id.ibSend);
swOpenAi = view.findViewById(R.id.swOpenAi);
tvOpenAiPrivacy = view.findViewById(R.id.tvOpenAiPrivacy);
etOpenAi = view.findViewById(R.id.etOpenAi);
tilOpenAi = view.findViewById(R.id.tilOpenAi);
etOpenAiModel = view.findViewById(R.id.etOpenAiModel);
tvOpenAiTemperature = view.findViewById(R.id.tvOpenAiTemperature);
@ -1049,28 +1047,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
etOpenAi.setHint(BuildConfig.OPENAI_ENDPOINT);
etOpenAi.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
}
@Override
public void afterTextChanged(Editable s) {
String apikey = s.toString().trim();
if (TextUtils.isEmpty(apikey))
prefs.edit().remove("openai_uri").apply();
else
prefs.edit().putString("openai_uri", apikey).apply();
}
});
tilOpenAi.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -2262,7 +2238,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"lt_key".equals(key) ||
"vt_apikey".equals(key) ||
"send_host".equals(key) ||
"openai_uri".equals(key) ||
"openai_apikey".equals(key) ||
"openai_model".equals(key))
return;
@ -2455,7 +2430,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swSend.setChecked(prefs.getBoolean("send_enabled", false));
etSend.setText(prefs.getString("send_host", null));
swOpenAi.setChecked(prefs.getBoolean("openai_enabled", false));
etOpenAi.setText(prefs.getString("openai_uri", null));
tilOpenAi.getEditText().setText(prefs.getString("openai_apikey", null));
etOpenAiModel.setText(prefs.getString("openai_model", null));

View File

@ -154,17 +154,12 @@ public class OpenAI {
return choices;
}
private static String getUri(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getString("openai_uri", BuildConfig.OPENAI_ENDPOINT);
}
private static JSONObject call(Context context, String method, String path, JSONObject args) throws JSONException, IOException {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String apikey = prefs.getString("openai_apikey", null);
// https://platform.openai.com/docs/api-reference/introduction
Uri uri = Uri.parse(getUri(context)).buildUpon().appendEncodedPath(path).build();
Uri uri = Uri.parse(BuildConfig.OPENAI_ENDPOINT).buildUpon().appendEncodedPath(path).build();
Log.i("OpenAI uri=" + uri);
long start = new Date().getTime();

View File

@ -967,19 +967,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenAiHint" />
<EditText
android:id="@+id/etOpenAi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:hint="https://api.openai.com/"
android:inputType="textUri"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenAiPrivacy" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilOpenAi"
android:layout_width="0dp"
@ -989,7 +976,7 @@
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etOpenAi">
app:layout_constraintTop_toBottomOf="@+id/tvOpenAiPrivacy">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
@ -1088,7 +1075,7 @@
android:id="@+id/grpOpenAi"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="swOpenAi,tvOpenAiHint,tvOpenAiPrivacy,etOpenAi,tilOpenAi,ibOpenAi,etOpenAiModel,tvOpenAiTemperature,sbOpenAiTemperature" />
app:constraint_referenced_ids="swOpenAi,tvOpenAiHint,tvOpenAiPrivacy,tilOpenAi,ibOpenAi,etOpenAiModel,tvOpenAiTemperature,sbOpenAiTemperature" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>