@ -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 > 0 L ) {
DB db = DB . getInstance ( context ) ;
@ -212,17 +216,13 @@ public class AI {
new OpenAI . Content [ ] { new OpenAI . Content ( OpenAI . CONTENT_TEXT ,
templatePrompt = = null ? defaultPrompt : templatePrompt ) } ) ) ;
if ( ! TextUtils . isEmpty ( message . subject ) )
input . add ( new OpenAI . Message ( OpenAI . USER ,
new OpenAI . Content [ ] { new OpenAI . Content ( OpenAI . CONTENT_TEXT , message . subject ) } ) ) ;
if ( multimodal ) {
SpannableStringBuilder ssb = HtmlHelper . fromDocument ( context , d , null , null ) ;
input . add ( new OpenAI . Message ( OpenAI . USER ,
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 ) ;
@ -239,12 +239,8 @@ 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 ( message . subject ) )
texts . add ( message . subject ) ;
if ( ! TextUtils . isEmpty ( body ) )
texts . add ( body ) ;
Gemini . Message content = new Gemini . Message ( Gemini . USER , texts . toArray ( new String [ 0 ] ) ) ;