OpenAI: refactoring

This commit is contained in:
M66B
2023-03-10 08:45:44 +01:00
parent 1bbafc8b7d
commit 93b1187032
2 changed files with 5 additions and 5 deletions

View File

@@ -112,13 +112,8 @@ public class OpenAI {
static Message[] completeChat(Context context, String model, Message[] messages, Float temperature, int n) throws JSONException, IOException {
// https://platform.openai.com/docs/guides/chat/introduction
// https://platform.openai.com/docs/api-reference/chat/create
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean openai_moderation = prefs.getBoolean("openai_moderation", false);
JSONArray jmessages = new JSONArray();
for (Message message : messages) {
if (openai_moderation)
checkModeration(context, message.content);
JSONObject jmessage = new JSONObject();
jmessage.put("role", message.role);
jmessage.put("content", message.content);