bugfix: ignore empty summary

This commit is contained in:
zhu327 2024-08-26 13:43:20 +08:00
parent 5c0b147c64
commit d8f918f8fd

View File

@ -166,7 +166,7 @@ async fn generate_and_update_entry(
let messages = vec![ let messages = vec![
Message { Message {
role: "system".to_string(), role: "system".to_string(),
content: "Please summarize the content of the article under 100 words in Chinese. Do not add any additional Character、markdown language to the result text. 请用不超过100个汉字概括文章内容。结果文本中不要添加任何额外的字符、Markdown语言。".to_string(), content: "Please summarize the content of the article under 150 words in Chinese. Do not add any additional Character、markdown language to the result text. 请用不超过150个汉字概括文章内容。结果文本中不要添加任何额外的字符、Markdown语言。".to_string(),
}, },
Message { Message {
role: "user".to_string(), role: "user".to_string(),
@ -186,20 +186,22 @@ async fn generate_and_update_entry(
) )
.await .await
{ {
let updated_content = format!( if !summary.trim().is_empty() {
"<pre style=\"white-space: pre-wrap;\"><code>\n💡AI 摘要:\n{}</code></pre><hr><br />{}", let updated_content = format!(
summary, content "<pre style=\"white-space: pre-wrap;\"><code>\n💡AI 摘要:\n{}</code></pre><hr><br />{}",
); summary, content
);
// Update the entry // Update the entry
update_entry( update_entry(
&config.miniflux.url, &config.miniflux.url,
&config.miniflux.username, &config.miniflux.username,
&config.miniflux.password, &config.miniflux.password,
entry.id, entry.id,
&updated_content, &updated_content,
) )
.await?; .await?;
}
} }
Ok(()) Ok(())