mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Handle empty summaries
This commit is contained in:
parent
ef3ede5c90
commit
6beb28511d
2 changed files with 7 additions and 4 deletions
|
@ -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…
Reference in a new issue