diff --git a/apps/notes/src/main.rs b/apps/notes/src/main.rs index e95220c..e5d066b 100644 --- a/apps/notes/src/main.rs +++ b/apps/notes/src/main.rs @@ -427,8 +427,8 @@ async fn process_recording(s: AppState, id: i64) { ); } - // LLM:生成会议纪要 - let summary = match call_llm_summary(&s, &transcript).await { + // LLM:生成会议纪要 + 标题 + let raw = match call_llm_summary(&s, &transcript).await { Ok(t) => t, Err(e) => { tracing::error!(%id, error = %e, "LLM failed"); @@ -436,14 +436,50 @@ async fn process_recording(s: AppState, id: i64) { return; } }; + let (new_title, summary_body) = parse_title_from_summary(&raw); { let conn = s.db.lock().unwrap(); - let _ = conn.execute( - "UPDATE recordings SET summary = ?1, status = 'done', error = NULL WHERE id = ?2", - params![&summary, id], - ); + if let Some(t) = new_title.as_deref() { + let _ = conn.execute( + "UPDATE recordings SET title = ?1, summary = ?2, status = 'done', error = NULL WHERE id = ?3", + params![t, &summary_body, id], + ); + } else { + let _ = conn.execute( + "UPDATE recordings SET summary = ?1, status = 'done', error = NULL WHERE id = ?2", + params![&summary_body, id], + ); + } } - tracing::info!(%id, "done"); + tracing::info!(%id, title = ?new_title, "done"); +} + +/// 从 LLM 输出剥离 `TITLE: ...\n---\n` 头部。 +/// 返回 (Option