sqlite_graphrag/i18n/validation/
messages_enrich_skip.rs1use crate::i18n::{current, Language};
12
13pub fn body_is_empty() -> String {
15 match current() {
16 Language::English => "body is empty".to_string(),
17 Language::Portuguese => "corpo vazio".to_string(),
18 }
19}
20
21pub fn chunk_text_is_empty() -> String {
23 match current() {
24 Language::English => "chunk text is empty".to_string(),
25 Language::Portuguese => "texto do chunk vazio".to_string(),
26 }
27}
28
29pub fn embedding_backend_returned_empty_vector() -> String {
34 match current() {
35 Language::English => {
36 "embedding backend returned an empty vector (chain resolved to none)".to_string()
37 }
38 Language::Portuguese => {
39 "backend de embedding devolveu vetor vazio (a cadeia resolveu para nenhum)".to_string()
40 }
41 }
42}
43
44pub fn reembed_batch_no_outcome() -> String {
46 match current() {
47 Language::English => "re-embed batch produced no outcome for this key".to_string(),
48 Language::Portuguese => {
49 "o lote de re-embed não produziu resultado para esta chave".to_string()
50 }
51 }
52}
53
54pub fn reembed_served_by_batch_path() -> String {
56 match current() {
57 Language::English => "re-embed is served by the batched claim path".to_string(),
58 Language::Portuguese => "o re-embed é atendido pelo caminho de claim em lote".to_string(),
59 }
60}
61
62pub fn pair_already_seen() -> String {
64 match current() {
65 Language::English => "pair already in entity_connect_seen".to_string(),
66 Language::Portuguese => "par já registrado em entity_connect_seen".to_string(),
67 }
68}
69
70pub fn pair_already_related() -> String {
72 match current() {
73 Language::English => "pair already related".to_string(),
74 Language::Portuguese => "par já relacionado".to_string(),
75 }
76}
77
78pub fn llm_found_no_relationship() -> String {
80 match current() {
81 Language::English => "LLM determined no relationship".to_string(),
82 Language::Portuguese => "o LLM determinou que não há relação".to_string(),
83 }
84}
85
86pub fn entity_type_no_evidence(corpus_chars: usize, min_corpus_chars: usize) -> String {
96 match current() {
97 Language::English => format!(
98 "insufficient_evidence: entity has no description and only {corpus_chars} chars of \
99 linked corpus, minimum is {min_corpus_chars} (bind it to a memory or describe it \
100 before asking for its type)"
101 ),
102 Language::Portuguese => format!(
103 "insufficient_evidence: a entidade não tem descrição e tem só {corpus_chars} \
104 caracteres de corpus ligado, o mínimo é {min_corpus_chars} (ligue-a a uma memória \
105 ou descreva-a antes de pedir o tipo)"
106 ),
107 }
108}
109
110pub fn entity_type_model_abstained(corpus_chars: usize) -> String {
112 match current() {
113 Language::English => format!(
114 "insufficient_evidence: model declined to judge the type from {corpus_chars} chars \
115 of evidence"
116 ),
117 Language::Portuguese => format!(
118 "insufficient_evidence: o modelo recusou julgar o tipo a partir de {corpus_chars} \
119 caracteres de evidência"
120 ),
121 }
122}
123
124pub fn entity_type_suggestion_unusable(suggested: &str) -> String {
130 match current() {
131 Language::English => {
132 format!("unusable_suggestion: `{suggested}` failed shape normalisation; type kept")
133 }
134 Language::Portuguese => {
135 format!(
136 "unusable_suggestion: `{suggested}` falhou na normalização de forma; tipo mantido"
137 )
138 }
139 }
140}
141
142pub fn entity_type_confirmed(current_type: &str) -> String {
144 match current() {
145 Language::English => format!("confirmed: `{current_type}` is already correct"),
146 Language::Portuguese => format!("confirmado: `{current_type}` já está correto"),
147 }
148}
149
150pub fn description_returned_null() -> String {
156 match current() {
157 Language::English => "insufficient_evidence: model returned a null description".to_string(),
158 Language::Portuguese => {
159 "insufficient_evidence: o modelo devolveu descrição nula".to_string()
160 }
161 }
162}
163
164pub fn description_returned_empty() -> String {
169 match current() {
170 Language::English => {
171 "insufficient_evidence: model returned an empty description".to_string()
172 }
173 Language::Portuguese => {
174 "insufficient_evidence: o modelo devolveu descrição vazia".to_string()
175 }
176 }
177}
178
179pub fn sqlite_busy_exhausted_on_dequeue() -> String {
185 match current() {
186 Language::English => {
187 "SQLITE_BUSY exhausted bounded retries while dequeuing (parallel worker)".to_string()
188 }
189 Language::Portuguese => {
190 "SQLITE_BUSY esgotou as tentativas limitadas ao retirar da fila (worker paralelo)"
191 .to_string()
192 }
193 }
194}
195
196pub fn sqlite_busy_exhausted_on_reembed_claim() -> String {
198 match current() {
199 Language::English => {
200 "SQLITE_BUSY exhausted bounded retries while claiming a re-embed batch".to_string()
201 }
202 Language::Portuguese => {
203 "SQLITE_BUSY esgotou as tentativas limitadas ao reservar um lote de re-embed"
204 .to_string()
205 }
206 }
207}
208
209pub fn chat_client_not_initialised() -> String {
215 match current() {
216 Language::English => {
217 "OpenRouter chat client not initialised before dispatch (internal error)".to_string()
218 }
219 Language::Portuguese => {
220 "cliente de chat da OpenRouter não inicializado antes do despacho (erro interno)"
221 .to_string()
222 }
223 }
224}
225
226#[cfg(test)]
227mod tests {
228 use super::*;
229
230 #[test]
236 fn the_abstention_reason_carries_the_measurement() {
237 let msg = entity_type_no_evidence(12, 40);
238 assert!(
239 msg.contains("12"),
240 "reason must carry the measured size: {msg}"
241 );
242 assert!(msg.contains("40"), "reason must carry the threshold: {msg}");
243 }
244
245 #[test]
253 fn no_reason_is_empty() {
254 assert!(!body_is_empty().is_empty());
255 assert!(!chunk_text_is_empty().is_empty());
256 assert!(!embedding_backend_returned_empty_vector().is_empty());
257 assert!(!reembed_batch_no_outcome().is_empty());
258 assert!(!reembed_served_by_batch_path().is_empty());
259 assert!(!pair_already_seen().is_empty());
260 assert!(!pair_already_related().is_empty());
261 assert!(!llm_found_no_relationship().is_empty());
262 assert!(!entity_type_no_evidence(1, 2).is_empty());
263 assert!(!entity_type_model_abstained(1).is_empty());
264 assert!(!entity_type_suggestion_unusable("x").is_empty());
265 assert!(!entity_type_confirmed("concept").is_empty());
266 }
267
268 #[test]
273 fn the_abstention_reasons_carry_their_marker() {
274 assert!(entity_type_no_evidence(0, 40).starts_with("insufficient_evidence:"));
275 assert!(entity_type_model_abstained(0).starts_with("insufficient_evidence:"));
276 assert!(entity_type_suggestion_unusable("x").starts_with("unusable_suggestion:"));
277 }
278}