sqlite_graphrag/i18n/validation/
messages_openrouter.rs1use crate::i18n::{current, Language};
7
8pub fn openrouter_api_key_not_found() -> String {
10 match current() {
11 Language::English => "OpenRouter API key not found; store it via \
12 `config add-key --provider openrouter`, or pass --openrouter-api-key \
13 (product env is deprecated)"
14 .to_string(),
15 Language::Portuguese => "chave de API OpenRouter não encontrada; armazene via \
16 `config add-key --provider openrouter`, ou passe --openrouter-api-key \
17 (env de produto está depreciada)"
18 .to_string(),
19 }
20}
21
22pub fn openrouter_chat_max_retries() -> String {
24 match current() {
25 Language::English => "max retries exceeded for OpenRouter chat request".to_string(),
26 Language::Portuguese => {
27 "número máximo de tentativas excedido para requisição de chat OpenRouter".to_string()
28 }
29 }
30}
31
32pub fn openrouter_chat_timed_out() -> String {
34 match current() {
35 Language::English => "OpenRouter chat request timed out".to_string(),
36 Language::Portuguese => "requisição de chat OpenRouter expirou (timeout)".to_string(),
37 }
38}
39
40pub fn openrouter_invalid_api_key_401() -> String {
42 match current() {
43 Language::English => "invalid OpenRouter API key (HTTP 401)".to_string(),
44 Language::Portuguese => "chave de API OpenRouter inválida (HTTP 401)".to_string(),
45 }
46}
47
48pub fn openrouter_model_required() -> String {
50 match current() {
51 Language::English => {
52 "--mode openrouter requires --openrouter-model (no default model is allowed)"
53 .to_string()
54 }
55 Language::Portuguese => {
56 "--mode openrouter exige --openrouter-model (nenhum modelo padrão é permitido)"
57 .to_string()
58 }
59 }
60}
61
62pub fn openrouter_server_error(status: &impl std::fmt::Display) -> String {
64 match current() {
65 Language::English => format!("OpenRouter server error: {status}"),
66 Language::Portuguese => format!("erro de servidor OpenRouter: {status}"),
67 }
68}
69
70pub fn openrouter_status_error(status: &impl std::fmt::Display, model: &str, body: &str) -> String {
72 match current() {
73 Language::English => {
74 format!("OpenRouter returned {status} for model '{model}': {body}")
75 }
76 Language::Portuguese => {
77 format!("OpenRouter retornou {status} para o modelo '{model}': {body}")
78 }
79 }
80}
81
82pub fn http_client_build_failed(err: &impl std::fmt::Display) -> String {
84 match current() {
85 Language::English => format!("failed to build HTTP client: {err}"),
86 Language::Portuguese => format!("falha ao construir cliente HTTP: {err}"),
87 }
88}
89
90pub fn http_request_failed(err: &impl std::fmt::Display) -> String {
92 match current() {
93 Language::English => format!("HTTP request failed: {err}"),
94 Language::Portuguese => format!("requisição HTTP falhou: {err}"),
95 }
96}
97
98pub fn unexpected_http_status(status: &impl std::fmt::Display, body: &str) -> String {
100 match current() {
101 Language::English => format!("unexpected HTTP {status}: {body}"),
102 Language::Portuguese => format!("HTTP inesperado {status}: {body}"),
103 }
104}
105
106pub fn failed_to_parse_chat_response(err: &impl std::fmt::Display) -> String {
108 match current() {
109 Language::English => format!("failed to parse chat response: {err}"),
110 Language::Portuguese => format!("falha ao parsear resposta de chat: {err}"),
111 }
112}
113
114pub fn failed_to_read_response_body(err: &impl std::fmt::Display) -> String {
116 match current() {
117 Language::English => format!("failed to read response body: {err}"),
118 Language::Portuguese => format!("falha ao ler corpo da resposta: {err}"),
119 }
120}
121
122pub fn invalid_json_schema_for_request(err: &impl std::fmt::Display) -> String {
124 match current() {
125 Language::English => {
126 format!("invalid JSON schema for OpenRouter request: {err}")
127 }
128 Language::Portuguese => {
129 format!("schema JSON inválido para requisição OpenRouter: {err}")
130 }
131 }
132}
133
134pub fn embedded_schema_invalid_json(name: &str, err: &impl std::fmt::Display) -> String {
136 match current() {
137 Language::English => format!("embedded schema for {name} is not valid JSON: {err}"),
138 Language::Portuguese => {
139 format!("schema embutido para {name} não é JSON válido: {err}")
140 }
141 }
142}
143
144pub fn model_json_parse_failed(model: &str, err: &impl std::fmt::Display) -> String {
146 match current() {
147 Language::English => format!(
148 "model '{model}' returned content that could not be parsed even after \
149 JSON repair: {err}"
150 ),
151 Language::Portuguese => format!(
152 "modelo '{model}' retornou conteúdo que não pôde ser parseado mesmo após \
153 reparo de JSON: {err}"
154 ),
155 }
156}
157
158pub fn model_non_object_json(model: &str, shape: &str) -> String {
160 match current() {
161 Language::English => format!(
162 "model '{model}' returned non-object JSON after repair (got {shape}); \
163 likely a refusal or malformed structured output"
164 ),
165 Language::Portuguese => format!(
166 "modelo '{model}' retornou JSON não-objeto após reparo (obteve {shape}); \
167 provavelmente uma recusa ou saída estruturada malformada"
168 ),
169 }
170}
171
172pub fn model_no_structured_content(model: &str) -> String {
174 match current() {
175 Language::English => format!(
176 "model '{model}' returned no structured content (incompatible with \
177 structured outputs, or refused the request)"
178 ),
179 Language::Portuguese => format!(
180 "modelo '{model}' não retornou conteúdo estruturado (incompatível com \
181 saídas estruturadas, ou recusou a requisição)"
182 ),
183 }
184}
185
186pub fn failed_to_parse_extraction(provider: &str, err: &impl std::fmt::Display) -> String {
188 match current() {
189 Language::English => {
190 format!("failed to deserialize {provider} output as ExtractionResult: {err}")
191 }
192 Language::Portuguese => {
193 format!("falha ao deserializar saída de {provider} como ExtractionResult: {err}")
194 }
195 }
196}
197
198pub fn failed_to_parse_entities_array(err: &impl std::fmt::Display) -> String {
200 match current() {
201 Language::English => format!("failed to parse entities array: {err}"),
202 Language::Portuguese => format!("falha ao parsear array de entidades: {err}"),
203 }
204}
205
206pub fn failed_to_parse_relationships_array(err: &impl std::fmt::Display) -> String {
208 match current() {
209 Language::English => format!("failed to parse relationships array: {err}"),
210 Language::Portuguese => {
211 format!("falha ao parsear array de relacionamentos: {err}")
212 }
213 }
214}