Refactoring

pull/215/head
M66B 1 year ago
parent 73097569f5
commit 63e8bd160c

@ -2678,7 +2678,7 @@ public class FragmentCompose extends FragmentBase {
OpenAI.Message message;
if (body instanceof Spannable)
message = new OpenAI.Message(OpenAI.USER, OpenAI.getContent((Spannable) body, id, context));
message = new OpenAI.Message(OpenAI.USER, OpenAI.Content.get((Spannable) body, id, context));
else
message = new OpenAI.Message(OpenAI.USER, new OpenAI.Content[]{
new OpenAI.Content(OpenAI.CONTENT_TEXT, body.toString())});

@ -117,7 +117,7 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
new OpenAI.Content[]{new OpenAI.Content(OpenAI.CONTENT_TEXT, prompt)}));
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, d, null, null);
input.add(new OpenAI.Message(OpenAI.USER, OpenAI.getContent(ssb, id, context)));
input.add(new OpenAI.Message(OpenAI.USER, OpenAI.Content.get(ssb, id, context)));
OpenAI.Message[] result =
OpenAI.completeChat(context, model, input.toArray(new OpenAI.Message[0]), temperature, 1);

@ -247,7 +247,24 @@ public class OpenAI {
}
}
static Content[] getContent(Spannable ssb, long id, Context context) {
static class Content {
private String type;
private String content;
public Content(String type, String content) {
this.type = type;
this.content = content;
}
public String getType() {
return this.type;
}
public String getContent() {
return this.content;
}
static Content[] get(Spannable ssb, long id, Context context) {
DB db = DB.getInstance(context);
List<OpenAI.Content> contents = new ArrayList<>();
int start = 0;
@ -289,23 +306,6 @@ public class OpenAI {
return contents.toArray(new OpenAI.Content[0]);
}
static class Content {
private String type;
private String content;
public Content(String type, String content) {
this.type = type;
this.content = content;
}
public String getType() {
return this.type;
}
public String getContent() {
return this.content;
}
}
static class Message {

Loading…
Cancel
Save