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();
jmessage.put("role", message.role);
JSONArray jcontents = new JSONArray();
for (Content content : message.content) {
JSONObject jcontent = new JSONObject();
jcontent.put("type", content.type);
jcontent.put(content.type, content.content);
jcontents.put(jcontent);
if (message.content.length == 1 && CONTENT_TEXT.equals(message.content[0].type))
jmessage.put("content", message.content[0].content);
else {
JSONArray jcontents = new JSONArray();
for (Content content : message.content) {
JSONObject jcontent = new JSONObject();
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);
}