Handle empty summaries

pull/215/head
M66B 6 months ago
parent ef3ede5c90
commit 6beb28511d

@ -190,6 +190,10 @@ public class AI {
HtmlHelper.truncate(d, MAX_SUMMARIZE_TEXT_SIZE);
String body = d.body().text().trim();
if (TextUtils.isEmpty(body))
return null;
String templatePrompt = null;
if (template > 0L) {
DB db = DB.getInstance(context);
@ -218,7 +222,7 @@ public class AI {
OpenAI.Content.get(ssb, message.id, context)));
} else
input.add(new OpenAI.Message(OpenAI.USER, new OpenAI.Content[]{
new OpenAI.Content(OpenAI.CONTENT_TEXT, d.text())}));
new OpenAI.Content(OpenAI.CONTENT_TEXT, body)}));
OpenAI.Message[] completions =
OpenAI.completeChat(context, model, input.toArray(new OpenAI.Message[0]), temperature, 1);
@ -235,8 +239,6 @@ public class AI {
float temperature = prefs.getFloat("gemini_temperature", Gemini.DEFAULT_TEMPERATURE);
String defaultPrompt = prefs.getString("gemini_summarize", Gemini.DEFAULT_SUMMARY_PROMPT);
String body = d.text();
List<String> texts = new ArrayList<>();
texts.add(templatePrompt == null ? defaultPrompt : templatePrompt);
if (!TextUtils.isEmpty(body))

@ -1584,7 +1584,8 @@ public class EntityRule {
try {
Spanned summary = AI.getSummaryText(context, message, -1L);
message.preview = (summary == null ? null : summary.toString().trim());
if (summary != null)
message.preview = summary.toString().trim();
} catch (Throwable ex) {
message.error = Log.formatThrowable(ex);
db.message().setMessageError(message.id, message.error);

Loading…
Cancel
Save