Report OpenAI quota errors in admin
This commit is contained in:
+5
-1
@@ -767,8 +767,12 @@ label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
|
||||
white-space: nowrap;
|
||||
}
|
||||
.translation-meta.translated { border-color: #b9dfca; background: #eef8f2; color: #1e7a47; }
|
||||
.translation-meta.failed { border-color: #f0b9b9; background: #fff1f1; color: #b42318; }
|
||||
.translation-meta.failed,
|
||||
.translation-meta.invalid_key,
|
||||
.translation-meta.bad_model { border-color: #f0b9b9; background: #fff1f1; color: #b42318; }
|
||||
.translation-meta.missing_key,
|
||||
.translation-meta.quota_exceeded,
|
||||
.translation-meta.rate_limited,
|
||||
.translation-meta.empty { border-color: #f1d29b; background: #fff7e8; color: #9a5b00; }
|
||||
.translation-meta.disabled,
|
||||
.translation-meta.skipped,
|
||||
|
||||
+15
-2
@@ -431,14 +431,23 @@ async function testOpenAiKey() {
|
||||
setOpenAiStatus("Testuji OpenAI klic...");
|
||||
const result = await api("/api/admin/ai/test", { method: "POST" }).catch((error) => error);
|
||||
if (result?.ok) {
|
||||
setOpenAiStatus(`Klic funguje (${result.key || "sk-..."}), dostupnych modelu: ${result.modelCount}.`);
|
||||
setOpenAiStatus(`Klic funguje (${result.key || "sk-..."}), model ${result.model || "AI"} umi prekladat.`);
|
||||
await loadAiModels().catch(() => {});
|
||||
return;
|
||||
}
|
||||
const message = result?.error === "missing_openai_api_key"
|
||||
? "Klic neni ulozeny. Nejdřív ho vloz a klikni na Ulozit AI nastaveni."
|
||||
: `Test selhal (${result?.error || "neznamá chyba"}).`;
|
||||
setOpenAiStatus(message);
|
||||
setOpenAiStatus(openAiTestMessage(result) || message);
|
||||
}
|
||||
|
||||
function openAiTestMessage(result) {
|
||||
if (result?.error === "missing_openai_api_key") return "Klic neni ulozeny. Nejdriiv ho vloz a klikni na Ulozit AI nastaveni.";
|
||||
if (result?.error === "quota_exceeded") return "OpenAI klic je ulozeny, ale chybi kredit nebo billing. Preklady zatim nepobezi.";
|
||||
if (result?.error === "invalid_key") return "OpenAI klic je spatny nebo nema pristup. Vloz novy klic.";
|
||||
if (result?.error === "bad_model") return "Zvoleny OpenAI model neni dostupny pro tento klic. Vyber jiny model.";
|
||||
if (result?.error === "rate_limited") return "OpenAI docasne omezuje pozadavky. Zkus test za chvili.";
|
||||
return "";
|
||||
}
|
||||
|
||||
function setOpenAiStatus(message) {
|
||||
@@ -624,6 +633,10 @@ function translationStatusLabel(status, source, target) {
|
||||
if (status === "translated") return `preklad: ${source} -> ${target}`;
|
||||
if (status === "same_language") return `preklad: ${source} = ${target}`;
|
||||
if (status === "failed") return `preklad: ${source} -> ${target} - chyba`;
|
||||
if (status === "quota_exceeded") return "preklad: neni kredit";
|
||||
if (status === "invalid_key") return "preklad: spatny klic";
|
||||
if (status === "bad_model") return "preklad: spatny model";
|
||||
if (status === "rate_limited") return "preklad: limit API";
|
||||
if (status === "missing_key") return "preklad: chybi klic";
|
||||
if (status === "disabled") return "preklad: vypnuto";
|
||||
if (status === "empty") return `preklad: ${source} -> ${target} - prazdny`;
|
||||
|
||||
Reference in New Issue
Block a user