Added OpenAI Uri option

This commit is contained in:
M66B
2023-05-29 15:19:22 +02:00
parent 83d8a298c3
commit ca9001dcf5
3 changed files with 48 additions and 4 deletions

View File

@@ -154,12 +154,17 @@ 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(BuildConfig.OPENAI_ENDPOINT).buildUpon().appendEncodedPath(path).build();
Uri uri = Uri.parse(getUri(context)).buildUpon().appendEncodedPath(path).build();
Log.i("OpenAI uri=" + uri);
long start = new Date().getTime();