World's first open-source enterprise world model.
Rust agent-memorybitemporalgraphragknowledge-baseknowledge-graphllmontologypgvectorpostgresqlragrustself-hostedsemantic-searchtemporal-knowledge-graphworld-model
Write extraction failure diagnostics in English (#1112)
Nash Aschenbath46e2f3dcdcc7
diff --git a/crates/utopia-llm/src/lib.rs b/crates/utopia-llm/src/lib.rsindex d14dc5ba..ca2134fe 100644--- a/crates/utopia-llm/src/lib.rs+++ b/crates/utopia-llm/src/lib.rs@@ -114,19 +114,19 @@ pub fn rate_limited(err: &anyhow::Error) -> Option<&RateLimited> {/// 实测一篇 32 块的文档在一小时里两类都撞上:502 四次、连接没送到两次。pub fn transient(err: &anyhow::Error) -> Option<(&'static str, Option<Duration>)> {if let Some(hit) = rate_limited(err) {- return Some(("端点限流", hit.retry_after));+ return Some(("LLM endpoint is rate limiting", hit.retry_after));}if let Some(hit) = unavailable(err) {- return Some(("端点不可用", hit.retry_after));+ return Some(("LLM endpoint is unavailable", hit.retry_after));}if err.chain().any(|e| e.is::<Interrupted>()) {- return Some(("流断在半路", None));+ return Some(("LLM response stream was interrupted", None));}let sending = err.chain().find_map(|e| e.downcast_ref::<Unreachable>()).filter(|u| !u.0.is_timeout());- sending.map(|_| ("请求没送到", None))+ sending.map(|_| ("LLM request could not be sent", None))}/// 端点开口了又半路没了:流断在一句话中间,既没有 `[DONE]` 也没有 `finish_reason`。@@ -2122,7 +2122,7 @@ data: {\"choices\":[{\"delta\":{\"content\":\"tail\"},\"finish_reason\":\"stop\"server.await.unwrap();assert_eq!(crate::transient(&err).map(|(w, _)| w),- Some("流断在半路"),+ Some("LLM response stream was interrupted"),"{err:#}");@@ -2422,7 +2422,7 @@ data: [DONE]assert!(crate::is_unreachable(&err), "{err:#}");assert_eq!(crate::transient(&err).map(|(w, _)| w),- Some("请求没送到"),+ Some("LLM request could not be sent"),"{err:#}");diff --git a/crates/utopia-server/src/extraction.rs b/crates/utopia-server/src/extraction.rsindex fcd23498..7894eb6d 100644--- a/crates/utopia-server/src/extraction.rs+++ b/crates/utopia-server/src/extraction.rs@@ -74,7 +74,7 @@ pub(crate) async fn chat_retrying_rate_limits_at(return Err(err);};if attempt == RATE_LIMIT_TRIES {- return Err(err.context(format!("{what}退避 {RATE_LIMIT_TRIES} 次仍未通过")));+ return Err(err.context(format!("{what} after {RATE_LIMIT_TRIES} attempts")));}let delay = jitter(retry_after.unwrap_or(backoff).min(RATE_LIMIT_CAP));tracing::warn!(@@ -159,14 +159,15 @@ pub(crate) fn incomplete_reason(unextracted: &[(i32, String)], attempted: usize).collect();let more = unextracted.len().saturating_sub(sample.len());let tail = if more > 0 {- format!(";另有 {more} 个")+ format!("; {more} more")} else {String::new()};Some(format!(- "本轮 {attempted} 个分块里 {} 个没能抽取:{}{tail}",+ "{} of {attempted} {} could not be extracted in this attempt: {}{tail}",unextracted.len(),- sample.join(";")+ if attempted == 1 { "chunk" } else { "chunks" },+ sample.join("; ")))}@@ -419,7 +420,7 @@ mod tests {#[test]fn a_document_with_a_skipped_chunk_is_not_complete() {assert_eq!(incomplete_reason(&[], 23), None, "全抽完才算完成");- let one = [(7, "调用失败:timeout".to_string())];+ let one = [(7, "request failed: timeout".to_string())];let msg = incomplete_reason(&one, 23).expect("有块没抽成就不该算完成");assert!(msg.contains("23"), "分母要说出来:{msg}");assert!(msg.contains("#7"), "得指得出是哪一块:{msg}");@@ -429,11 +430,11 @@ mod tests {/// 但**剩下多少必须说**——否则读的人会以为只坏了三块。#[test]fn many_failures_are_summarised_without_hiding_the_count() {- let many: Vec<(i32, String)> = (1..=20).map(|i| (i, "调用失败".into())).collect();+ let many: Vec<(i32, String)> = (1..=20).map(|i| (i, "request failed".into())).collect();let msg = incomplete_reason(&many, 60).unwrap();assert!(msg.contains("20"), "总数要在:{msg}");- assert!(msg.contains("另有 17 个"), "省略掉的数量要说出来:{msg}");- assert_eq!(msg.matches("调用失败").count(), 3, "只举三个");+ assert!(msg.contains("; 17 more"), "省略掉的数量要说出来:{msg}");+ assert_eq!(msg.matches("request failed").count(), 3, "只举三个");}/// 重试时 `chunks_for_extraction` 只取还没抽的块,所以分母是**本轮**的数,@@ -441,7 +442,10 @@ mod tests {#[test]fn the_denominator_is_this_rounds_chunks_not_the_document() {let msg = incomplete_reason(&[(2, "x".into())], 3).unwrap();- assert!(msg.starts_with("本轮 3 个分块"), "{msg}");+ assert!(+ msg.starts_with("1 of 3 chunks could not be extracted in this attempt:"),+ "{msg}"+ );}#[tokio::test]diff --git a/crates/utopia-server/src/extraction_open.rs b/crates/utopia-server/src/extraction_open.rsindex 565b0929..adf877e2 100644--- a/crates/utopia-server/src/extraction_open.rs+++ b/crates/utopia-server/src/extraction_open.rs@@ -95,11 +95,11 @@ async fn call_and_parse_one_chunk(kb_id,document_id,reason::CHUNK_UNEXTRACTED,- "调用失败,这一块没有进图",- Some(&format!("#{}:{e}", chunk.seq)),+ "request failed; this chunk did not enter the graph",+ Some(&format!("#{}: {e}", chunk.seq)),).await;- unextracted.push((chunk.seq, format!("调用失败:{e}")));+ unextracted.push((chunk.seq, format!("request failed: {e}")));return Ok(None);}};@@ -117,13 +117,13 @@ async fn call_and_parse_one_chunk(// 别的解析失败是「回复不合结构」。两种都写成同一句话就分不开了let (why, detail) = if cut_by_ceiling {(- "回复撞上 token 上限被截断,剩下的解析不了,这一块没有进图",- format!("#{}:hit the token ceiling;{e}", chunk.seq),+ "response hit the token ceiling and could not be parsed; this chunk did not enter the graph",+ format!("#{}: hit the token ceiling; {e}", chunk.seq),)} else {(- "回复解析不了,这一块没有进图",- format!("#{}:{e}", chunk.seq),+ "response could not be parsed; this chunk did not enter the graph",+ format!("#{}: {e}", chunk.seq),)};drop_signal(@@ -135,7 +135,7 @@ async fn call_and_parse_one_chunk(Some(&detail),).await;- unextracted.push((chunk.seq, format!("回复解析失败:{e}")));+ unextracted.push((chunk.seq, format!("response parsing failed: {e}")));return Ok(None);}};diff --git a/docs/pipeline.md b/docs/pipeline.mdindex 42ccef3a..f56da32c 100644--- a/docs/pipeline.md+++ b/docs/pipeline.md@@ -78,6 +78,11 @@ flowchart TB### Where this stage drops things+**Failure diagnostics are stored in English.** The extraction worker writes its+chunk-failure labels, the exhausted-retry reason and the per-attempt summary into+`documents.graph_error`, and Library shows that text as stored. Provider and parser+messages are kept verbatim.+Eleven reason codes, all recorded in `extraction_drops` and visible in the UI (one is a trace, not a drop):| Reason | When |