use crate::i18n::{current, Language};
pub fn body_is_empty() -> String {
match current() {
Language::English => "body is empty".to_string(),
Language::Portuguese => "corpo vazio".to_string(),
}
}
pub fn chunk_text_is_empty() -> String {
match current() {
Language::English => "chunk text is empty".to_string(),
Language::Portuguese => "texto do chunk vazio".to_string(),
}
}
pub fn embedding_backend_returned_empty_vector() -> String {
match current() {
Language::English => {
"embedding backend returned an empty vector (chain resolved to none)".to_string()
}
Language::Portuguese => {
"backend de embedding devolveu vetor vazio (a cadeia resolveu para nenhum)".to_string()
}
}
}
pub fn reembed_batch_no_outcome() -> String {
match current() {
Language::English => "re-embed batch produced no outcome for this key".to_string(),
Language::Portuguese => {
"o lote de re-embed não produziu resultado para esta chave".to_string()
}
}
}
pub fn reembed_served_by_batch_path() -> String {
match current() {
Language::English => "re-embed is served by the batched claim path".to_string(),
Language::Portuguese => "o re-embed é atendido pelo caminho de claim em lote".to_string(),
}
}
pub fn pair_already_seen() -> String {
match current() {
Language::English => "pair already in entity_connect_seen".to_string(),
Language::Portuguese => "par já registrado em entity_connect_seen".to_string(),
}
}
pub fn pair_already_related() -> String {
match current() {
Language::English => "pair already related".to_string(),
Language::Portuguese => "par já relacionado".to_string(),
}
}
pub fn llm_found_no_relationship() -> String {
match current() {
Language::English => "LLM determined no relationship".to_string(),
Language::Portuguese => "o LLM determinou que não há relação".to_string(),
}
}
pub fn entity_type_no_evidence(corpus_chars: usize, min_corpus_chars: usize) -> String {
match current() {
Language::English => format!(
"insufficient_evidence: entity has no description and only {corpus_chars} chars of \
linked corpus, minimum is {min_corpus_chars} (bind it to a memory or describe it \
before asking for its type)"
),
Language::Portuguese => format!(
"insufficient_evidence: a entidade não tem descrição e tem só {corpus_chars} \
caracteres de corpus ligado, o mínimo é {min_corpus_chars} (ligue-a a uma memória \
ou descreva-a antes de pedir o tipo)"
),
}
}
pub fn entity_type_model_abstained(corpus_chars: usize) -> String {
match current() {
Language::English => format!(
"insufficient_evidence: model declined to judge the type from {corpus_chars} chars \
of evidence"
),
Language::Portuguese => format!(
"insufficient_evidence: o modelo recusou julgar o tipo a partir de {corpus_chars} \
caracteres de evidência"
),
}
}
pub fn entity_type_suggestion_unusable(suggested: &str) -> String {
match current() {
Language::English => {
format!("unusable_suggestion: `{suggested}` failed shape normalisation; type kept")
}
Language::Portuguese => {
format!(
"unusable_suggestion: `{suggested}` falhou na normalização de forma; tipo mantido"
)
}
}
}
pub fn entity_type_confirmed(current_type: &str) -> String {
match current() {
Language::English => format!("confirmed: `{current_type}` is already correct"),
Language::Portuguese => format!("confirmado: `{current_type}` já está correto"),
}
}
pub fn description_returned_null() -> String {
match current() {
Language::English => "insufficient_evidence: model returned a null description".to_string(),
Language::Portuguese => {
"insufficient_evidence: o modelo devolveu descrição nula".to_string()
}
}
}
pub fn description_returned_empty() -> String {
match current() {
Language::English => {
"insufficient_evidence: model returned an empty description".to_string()
}
Language::Portuguese => {
"insufficient_evidence: o modelo devolveu descrição vazia".to_string()
}
}
}
pub fn sqlite_busy_exhausted_on_dequeue() -> String {
match current() {
Language::English => {
"SQLITE_BUSY exhausted bounded retries while dequeuing (parallel worker)".to_string()
}
Language::Portuguese => {
"SQLITE_BUSY esgotou as tentativas limitadas ao retirar da fila (worker paralelo)"
.to_string()
}
}
}
pub fn sqlite_busy_exhausted_on_reembed_claim() -> String {
match current() {
Language::English => {
"SQLITE_BUSY exhausted bounded retries while claiming a re-embed batch".to_string()
}
Language::Portuguese => {
"SQLITE_BUSY esgotou as tentativas limitadas ao reservar um lote de re-embed"
.to_string()
}
}
}
pub fn chat_client_not_initialised() -> String {
match current() {
Language::English => {
"OpenRouter chat client not initialised before dispatch (internal error)".to_string()
}
Language::Portuguese => {
"cliente de chat da OpenRouter não inicializado antes do despacho (erro interno)"
.to_string()
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_abstention_reason_carries_the_measurement() {
let msg = entity_type_no_evidence(12, 40);
assert!(
msg.contains("12"),
"reason must carry the measured size: {msg}"
);
assert!(msg.contains("40"), "reason must carry the threshold: {msg}");
}
#[test]
fn no_reason_is_empty() {
assert!(!body_is_empty().is_empty());
assert!(!chunk_text_is_empty().is_empty());
assert!(!embedding_backend_returned_empty_vector().is_empty());
assert!(!reembed_batch_no_outcome().is_empty());
assert!(!reembed_served_by_batch_path().is_empty());
assert!(!pair_already_seen().is_empty());
assert!(!pair_already_related().is_empty());
assert!(!llm_found_no_relationship().is_empty());
assert!(!entity_type_no_evidence(1, 2).is_empty());
assert!(!entity_type_model_abstained(1).is_empty());
assert!(!entity_type_suggestion_unusable("x").is_empty());
assert!(!entity_type_confirmed("concept").is_empty());
}
#[test]
fn the_abstention_reasons_carry_their_marker() {
assert!(entity_type_no_evidence(0, 40).starts_with("insufficient_evidence:"));
assert!(entity_type_model_abstained(0).starts_with("insufficient_evidence:"));
assert!(entity_type_suggestion_unusable("x").starts_with("unusable_suggestion:"));
}
}