mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
OpenAI: refactoring
This commit is contained in:
@@ -229,6 +229,18 @@ public class OpenAI {
|
||||
}
|
||||
}
|
||||
|
||||
static String truncateParagraphs(@NonNull String text, int maxlen) {
|
||||
String[] paragraphs = text.split("[\\r\\n]+");
|
||||
|
||||
int i = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (i < paragraphs.length &&
|
||||
sb.length() + paragraphs[i].length() + 1 < maxlen)
|
||||
sb.append(paragraphs[i++]).append('\n');
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static class Message {
|
||||
private final String role; // // system, user, assistant
|
||||
private final String content;
|
||||
|
||||
Reference in New Issue
Block a user