OpenAI: optional multi modal

This commit is contained in:
M66B 2024-05-14 17:08:23 +02:00
parent 08d845887c
commit f86b572eae
1 changed files with 11 additions and 9 deletions

View File

@ -116,17 +116,19 @@ public class OpenAI {
JSONObject jmessage = new JSONObject(); JSONObject jmessage = new JSONObject();
jmessage.put("role", message.role); jmessage.put("role", message.role);
JSONArray jcontents = new JSONArray(); if (message.content.length == 1 && CONTENT_TEXT.equals(message.content[0].type))
jmessage.put("content", message.content[0].content);
for (Content content : message.content) { else {
JSONObject jcontent = new JSONObject(); JSONArray jcontents = new JSONArray();
jcontent.put("type", content.type); for (Content content : message.content) {
jcontent.put(content.type, content.content); JSONObject jcontent = new JSONObject();
jcontents.put(jcontent); jcontent.put("type", content.type);
jcontent.put(content.type, content.content);
jcontents.put(jcontent);
}
jmessage.put("content", jcontents);
} }
jmessage.put("content", jcontents);
jmessages.put(jmessage); jmessages.put(jmessage);
} }