feat: rename fallback category "Autre" to "Divers"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
master
oabrivard 3 months ago
parent 102f6d3fe7
commit fb086a706f

@ -15,7 +15,7 @@ pub struct MockLlmProvider {
impl MockLlmProvider {
pub fn new() -> Self {
Self {
default_category: "Autre".to_string(),
default_category: "Divers".to_string(),
search_urls: Vec::new(),
}
}

@ -349,18 +349,18 @@ mod tests {
let (sys, user) = build_article_classify_prompt(
"GPT-5 Released",
"OpenAI released GPT-5 today",
&["AI News".into(), "Autre".into()],
&["AI News".into(), "Divers".into()],
3,
);
assert!(user.contains("GPT-5 Released"));
assert!(user.contains("AI News"));
assert!(user.contains("Autre"));
assert!(user.contains("Divers"));
assert!(sys.contains("classer"));
}
#[test]
fn article_classify_prompt_handles_empty_title() {
let (_, user) = build_article_classify_prompt("", "Some content", &["Tech".into(), "Autre".into()], 3);
let (_, user) = build_article_classify_prompt("", "Some content", &["Tech".into(), "Divers".into()], 3);
assert!(user.contains("(pas de titre)"));
}

@ -250,7 +250,7 @@ pub async fn run_generation_inner(
settings.categories.clone()
};
let mut classification_categories = user_categories.clone();
classification_categories.push("Autre".to_string());
classification_categories.push("Divers".to_string());
emit_progress(tx, "sources", "Chargement des sources...", 10);
let sources = db::sources::list_for_user(&state.pool, user_id).await?;
@ -882,7 +882,7 @@ pub async fn run_generation_inner(
}
if let Some(autre_items) = article_scraped.get("category_autre") {
if !autre_items.is_empty() {
final_sections.push(NewsSection { title: "Autre".to_string(), items: autre_items.clone() });
final_sections.push(NewsSection { title: "Divers".to_string(), items: autre_items.clone() });
}
}
@ -1108,10 +1108,10 @@ fn assign_category(
) -> Option<(String, String, String, String)> {
let llm_title = llm_response.get("title").and_then(|t| t.as_str()).unwrap_or(page_title).to_string();
let llm_summary = llm_response.get("summary").and_then(|s| s.as_str()).unwrap_or("").to_string();
let mut llm_category = llm_response.get("category").and_then(|c| c.as_str()).unwrap_or("Autre").to_string();
let mut llm_category = llm_response.get("category").and_then(|c| c.as_str()).unwrap_or("Divers").to_string();
if !classification_categories.iter().any(|c| c.to_lowercase() == llm_category.to_lowercase()) {
llm_category = "Autre".to_string();
llm_category = "Divers".to_string();
}
let cat_key = if llm_category.to_lowercase() == "autre" {
@ -1124,11 +1124,11 @@ fn assign_category(
let cat_filled = filled_counts.get(&llm_category).copied().unwrap_or(0);
if cat_filled >= max_items_per_category && llm_category.to_lowercase() != "autre" {
let autre_filled = filled_counts.get("Autre").copied().unwrap_or(0);
let autre_filled = filled_counts.get("Divers").copied().unwrap_or(0);
if autre_filled >= max_items_per_category {
return None;
}
Some(("category_autre".to_string(), "Autre".to_string(), llm_title, llm_summary))
Some(("category_autre".to_string(), "Divers".to_string(), llm_title, llm_summary))
} else {
Some((cat_key, llm_category, llm_title, llm_summary))
}

Loading…
Cancel
Save